Jump to content

multi-player aircraft crash detection


Maxime

Recommended Posts

Here's my code:

tmps=0
local preFixes =  {"01", "02", "03", "04" , "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21" }
local PlayerCrashSpit = {}
for i = 1, 21 do
 PlayerCrashSpit[i]=SET_UNIT:New():FilterCategories("plane"):FilterStart("Pilot_Spit #0".. preFixes[i] ):FilterStart()
 PlayerCrashSpit=PlayerCrashSpit[i]
 PlayerCrashSpit:HandleEvent( EVENTS.Crash )
 function  PlayerCrashSpit:OnEventCrash( EventData )
   if timer.getTime() - tmps >2 then
     tmps=timer.getTime()
     nom = EventData.IniPlayerName
     Scoring:AddGoalScorePlayer( nom, "Pilot, it's crashed.", nom.." it's crashed  -5", -5 )
   end
 end 
end

I use Moose, this code works very well locally and when I create a server but as soon as there is more than one player on the server it doesn't work anymore. ???

Please help !

Link to comment
Share on other sites

tmps=0

 PlayerCrashSpit = SET_CLIENT:New():FilterCategories("plane"):FilterActive():FilterStart():HandleEvent(EVENTS.Crash)

 function  PlayerCrashSpit:OnEventCrash( EventData )

   if EventData.IniPlayerName ~= then

       if timer.getTime() - tmps >2 then -- i don't understant the argument, timer.getTime() gives mission current time its always going to be >2...? maybe for the first pass change the above to just tmps no value then, if tmps and tmps ~= nil then else end.

       tmps=timer.getTime()

       nom = EventData.IniPlayerName

       Scoring:AddGoalScorePlayer( nom, "Pilot, it's crashed.", nom.." it's crashed  -5", -5 ) -- i can't help you here I dont know the class at all.

       end
       
   else
   --add error?
   end
 end 

 

that's all you should need, if you really want to limit to those prefixes then maybe add string.find as an argument at the beginning to return if not the one you want.

 

I've not tested this and I'm tired...

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

Link to comment
Share on other sites

Actually I think there's something odd going on with MOOSE SET_CLIENT atm you might want to change it to GROUP instead.

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...