Ping feature crashes in MP [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Ping feature crashes in MP [Solved]

Post by Noobasaurus »

As stated in the topic's title, the ping feature crashes the game once it happens in MP. It works fine for the most part on SP. Sometimes it doesn't work at all in SP but usually it's fine.
Hidden/Spoiler:
[code]
unitsAlive = {}

unitSpawn = OnCharacterSpawn(
function(character)
playerInfo = {playerUnit = GetCharacterUnit(character), playerTeam = GetCharacterTeam(character)--, this comma is only necessary if you add more info
--any other info you want to record
}
unitsAlive[character] = playerInfo
end)


pingtimer1 = CreateTimer("pingtimer1")
SetTimerValue(pingtimer1, 30)
OnTimerElapse(
function(timer)
for i, v in pairs(unitsAlive) do
unit = GetCharacterUnit(i) --**Add these lines**
playerTeam = GetCharacterTeam(i) --"
--local x, y, z = GetWorldPosition(unit)
if playerTeam == 2 and unit ~= nil then
pingcount = pingcount + 1;
CreateEntity("com_item_null", GetEntityMatrix(unit), "ping"..pingcount)
MapAddEntityMarker("ping"..pingcount, "hud_objective_icon1", 2.5, 1, "BLUE", true, true, true)
end
end
SetTimerValue(pingtimer1, 30)
StartTimer(pingtimer1)
StartTimer(pingtimer2)
end,
pingtimer1
)


pingtimer2 = CreateTimer("pingtimer2")
SetTimerValue(pingtimer2, 15)
OnTimerElapse(
function(timer)
if pingcount == 1 then
MapRemoveEntityMarker("ping1")
DeleteEntity("ping1")
end
if pingcount == 2 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
DeleteEntity("ping1")
DeleteEntity("ping2")
end
if pingcount == 3 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
end
if pingcount == 4 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
end
if pingcount == 5 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
end
if pingcount == 6 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping6")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
end
if pingcount == 7 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
end
if pingcount == 8 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
end
if pingcount == 9 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
end
if pingcount == 10 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
MapRemoveEntityMarker("ping10")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
DeleteEntity("ping10")
end
if pingcount == 11 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
MapRemoveEntityMarker("ping10")
MapRemoveEntityMarker("ping11")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
DeleteEntity("ping10")
DeleteEntity("ping11")
end
if pingcount == 12 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
MapRemoveEntityMarker("ping10")
MapRemoveEntityMarker("ping11")
MapRemoveEntityMarker("ping12")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
DeleteEntity("ping10")
DeleteEntity("ping11")
DeleteEntity("ping12")
end
if pingcount == 13 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
MapRemoveEntityMarker("ping10")
MapRemoveEntityMarker("ping11")
MapRemoveEntityMarker("ping12")
MapRemoveEntityMarker("ping13")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
DeleteEntity("ping10")
DeleteEntity("ping11")
DeleteEntity("ping12")
DeleteEntity("ping13")
end
if pingcount == 14 then
MapRemoveEntityMarker("ping1")
MapRemoveEntityMarker("ping2")
MapRemoveEntityMarker("ping3")
MapRemoveEntityMarker("ping4")
MapRemoveEntityMarker("ping5")
MapRemoveEntityMarker("ping7")
MapRemoveEntityMarker("ping8")
MapRemoveEntityMarker("ping9")
MapRemoveEntityMarker("ping10")
MapRemoveEntityMarker("ping11")
MapRemoveEntityMarker("ping12")
MapRemoveEntityMarker("ping13")
MapRemoveEntityMarker("ping14")
DeleteEntity("ping1")
DeleteEntity("ping2")
DeleteEntity("ping3")
DeleteEntity("ping4")
DeleteEntity("ping5")
DeleteEntity("ping6")
DeleteEntity("ping7")
DeleteEntity("ping8")
DeleteEntity("ping9")
DeleteEntity("ping10")
DeleteEntity("ping11")
DeleteEntity("ping12")
DeleteEntity("ping13")
DeleteEntity("ping14")
end
pingcount = 0;
SetTimerValue(pingtimer2, 15)
end,
pingtimer2
)


pingcount = 0
[/code]
Since I can't debug MP, I don't know what's wrong. Help is greatly appreciated.
Last edited by Noobasaurus on Fri Aug 08, 2014 1:13 pm, edited 1 time in total.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: Ping feature crashes in MP

Post by razac920 »

Actually, i think you CAN debug MP. Try hosting a dedicated server with DSManager, join that server, and try the ping feature. You should see a BFront2.log in the same folder as DSManager.exe appear. Try looking at that.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Ping feature crashes in MP

Post by Noobasaurus »

Okay, I'll try that.

So I did, and I got the map loaded in the dedicated server and everything looks fine when I run it, but it doesn't show up in the server list for LAN or Internet. I didn't see a BFront2.log generated anywhere either.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: Ping feature crashes in MP

Post by razac920 »

Hm, that is odd. I also loaded the map in a dedicated server, didn't seem to find it in the server list, but then i searched for it by name, and found it, and joined, but I crash the moment I join the server, every time. I did generate a log of the server, though it does not seem to give any useful information about the crash. When did you notice the crash? Does the crash affect the host or only clients?
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Ping feature crashes in MP

Post by Noobasaurus »

The crash happened 30 seconds after I spawned (AKA the ping timer). So right when the stuff above happens it crashes. It crashed me as the host. I don't know about clients.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Ping feature crashes in MP

Post by [RDH]Zerted »

First, it's better to quote all your timer names rather than pass around the timer variable. Always quoting reduces the changes of bug and you probably have one. You refer to pingtimer2 before you store anything in it. Change your code to be like: StartTimer("pingtimer2")
and pingtimer1 = CreateTimer("pingtimer1") to simply CreateTimer("pingtimer1")

Next, change all those if ... then ... end to if ... then ... else if ... else if ... ... end. It would be even better if you looped pingcount times and did MapRemoveEntityMarker("ping"..index) instead of using if statements, but you don't need to make that change.

If I had to guess (and I do since I don't know why it's crashing), I'd say DeleteEntity() could be causing issues. Try running that code only on the server (put an if host check around it).
LRKfm946
Master Sergeant
Master Sergeant
Posts: 163
Joined: Sun Feb 02, 2014 6:13 pm
Projects :: Battlefront II Hunger Games
Games I'm Playing :: SWBF2 BF3
Contact:

Re: Ping feature crashes in MP

Post by LRKfm946 »

When you use swbf2sm.exe, the bfront2.log is generated in C:\Users\*YOURNAME*\AppData\Local\VirtualStore\Program Files (x86)\LucasArts\Star Wars Battlefront II PC Server . It took me quite a while to find that there.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Ping feature crashes in MP

Post by Noobasaurus »

Thanks for the responses guys. Sorry about my late response, but I tried most of the stuff up there and even more errors came up in SP as well. So I reverted it back and found some places where a timer was started or made twice and I think it's good now.
Post Reply