Chaos Posted December 4, 2014 Share Posted December 4, 2014 hey guys, i want to prevent zombies keep spawning in the water it's really annoying and most of zombies are spawning in water. I'm using default zombies script.. any idea ? Link to comment
MTA Team 0xCiBeR Posted December 4, 2014 MTA Team Share Posted December 4, 2014 Just add a line after the createPed function like this: if isElementInWater ( zomb ) then destroyElement( zomb ) end Remember to kill anything else that has to do with that ped. Link to comment
Chaos Posted December 4, 2014 Author Share Posted December 4, 2014 Just add a line after the createPed function like this: if isElementInWater ( zomb ) then destroyElement( zomb ) end Remember to kill anything else that has to do with that ped. there is no createPed function you mean here ? --EXPORTED FUNCTIONS!!!!!!!!!!!!!! function createZombie ( x, y, z, rot, skin, interior, dimension ) if (table.getn( everyZombie ) < newZombieLimit ) then --this part handles the args if not x then return false end if not y then return false end if not z then return false end if not rot then rot = math.random (1,359) end if not skin then randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) ) skin = ZombiePedSkins[randomZskin] end if not interior then interior = 0 end if not dimension then dimension = 0 end --this part spawns the ped local zomb = createPed (tonumber(skin),tonumber(x),tonumber(y),tonumber(z))--spawns the ped --if successful, this part applies the zombie settings/args if (zomb ~= false) then setTimer ( setElementInterior, 100, 1, zomb, tonumber(interior)) --sets interior setTimer ( setElementDimension, 100, 1, zomb, tonumber(dimension)) --sets dimension setElementData ( zomb, "zombie", true ) setElementData ( zomb, "forcedtoexist", true ) setTimer ( function (zomb, rot) if ( isElement ( zomb ) ) then setPedRotation ( zomb, rot ) end end, 500, 1, zomb, rot ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "forcedtoexist", true ) end end, 1000, 1, zomb ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then table.insert( everyZombie, zomb ) end end, 1000, 1, zomb ) triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb ) return zomb --returns the zombie element else return false --returns false if there was a problem end else return false --returns false if there was a problem end end Link to comment
MTA Team 0xCiBeR Posted December 4, 2014 MTA Team Share Posted December 4, 2014 Yes...Exactly after the createPed function as stated before. Link to comment
Chaos Posted December 4, 2014 Author Share Posted December 4, 2014 Yes...Exactly after the createPed function as stated before. it's not working function createZombie ( x, y, z, rot, skin, interior, dimension ) if (table.getn( everyZombie ) < newZombieLimit ) then --this part handles the args if not x then return false end if not y then return false end if not z then return false end if not rot then rot = math.random (1,359) end if not skin then randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) ) skin = ZombiePedSkins[randomZskin] end if not interior then interior = 0 end if not dimension then dimension = 0 end --this part spawns the ped local zomb = createPed (tonumber(skin),tonumber(x),tonumber(y),tonumber(z))--spawns the ped if isElementInWater ( zomb ) then outputChatBox("it's Working",root) destroyElement( zomb ) end --if successful, this part applies the zombie settings/args if (zomb ~= false) then setTimer ( setElementInterior, 100, 1, zomb, tonumber(interior)) --sets interior setTimer ( setElementDimension, 100, 1, zomb, tonumber(dimension)) --sets dimension setElementData ( zomb, "zombie", true ) setElementData ( zomb, "forcedtoexist", true ) setTimer ( function (zomb, rot) if ( isElement ( zomb ) ) then setPedRotation ( zomb, rot ) end end, 500, 1, zomb, rot ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "forcedtoexist", true ) end end, 1000, 1, zomb ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then table.insert( everyZombie, zomb ) end end, 1000, 1, zomb ) triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb ) return zomb --returns the zombie element else return false --returns false if there was a problem end else return false --returns false if there was a problem end end Link to comment
MTA Team 0xCiBeR Posted December 4, 2014 MTA Team Share Posted December 4, 2014 It should work, though i'm not sure that's the function that uses when you spawn zombies randomly. You could use a timer, maybe when the conditional is passed, the zombie is not yet created. Link to comment
.:HyPeX:. Posted December 4, 2014 Share Posted December 4, 2014 setTimer(function() for i,v in ipairs(getElementsByType("ped")) do if not getPlayerName(v) then if isElementInWater(v) then destroyElement(v) end end end end, 1000,0) Maybe..? Link to comment
Moderators IIYAMA Posted December 4, 2014 Moderators Share Posted December 4, 2014 Clientside checks are more reliable, you should use clients to find the spawn-positions. Those functions come in handy. https://wiki.multitheftauto.com/wiki/Te ... ainstWater https://wiki.multitheftauto.com/wiki/ProcessLineOfSight It is more work, but it will use less network traffic because the zombies don't become useless when they spawn. "Spawning them underwater will require the network from all players, while a simply secure check will only use 1 client." @ .:HyPeX:. Peds never have names. Link to comment
Chaos Posted December 4, 2014 Author Share Posted December 4, 2014 (edited) Clientside checks are more reliable, you should use clients to find the spawn-positions.Those functions come in handy. https://wiki.multitheftauto.com/wiki/Te ... ainstWater https://wiki.multitheftauto.com/wiki/ProcessLineOfSight It is more work, but it will use less network traffic because the zombies don't become useless when they spawn. "Spawning them underwater will require the network from all players, while a simply secure check will only use 1 client." @ .:HyPeX:. Peds never have names. Understood i was wondering why my server lagging as hell i think because that. is that what you mean? addEvent( "Zomb_STFU", true ) function Zstfu ( ped ) if (isElement(ped)) then setPedVoice(ped, "PED_TYPE_DISABLED") if isPedOnGround(ped) then local px, py, pz = getElementPosition(ped) if testLineAgainstWater(px, py, pz, px, py, pz - 500) then destroyElement(ped) end end end end addEventHandler( "Zomb_STFU", getRootElement(), Zstfu ) Edited December 4, 2014 by Guest Link to comment
Moderators IIYAMA Posted December 4, 2014 Moderators Share Posted December 4, 2014 You can't destroy serverside peds, clientside. and use this before you spawn the ped, not when you already created it. Link to comment
Chaos Posted December 4, 2014 Author Share Posted December 4, 2014 You can't destroy serverside peds, clientside.and use this before you spawn the ped, not when you already created it. testLineAgainstWater function is client side and the spawn function in the server side how can i do it then ? Link to comment
Feche1320 Posted December 4, 2014 Share Posted December 4, 2014 Destroying the ped after spawn is a 'fast fix', why don't you look at the main problem instead? How does your script use the function createZombie? Link to comment
Moderators IIYAMA Posted December 4, 2014 Moderators Share Posted December 4, 2014 @Feche1320 Because preventing is better then fixing. If you disagree with that, then you are just stupid. @Chaos --(serverside) -- request positions x,y,z near the player triggerClientEvent(targetPlayer,"event",resourceRoot,x,y,z -- --(clientside) addEvent("event",true) addEventHandler("event",root, function(x,y,z) --... -- check the position testLineAgainstWater processLineOfSight -- if the position fails use a random positions near that point math.random() -- and check again until you find a right spot. Use a loop. testLineAgainstWater processLineOfSight -- if you found a point successfully, send it back to serverside so it can make a new zombie. triggerServerEvent("event2",localPlayer,x,y,z) -- if you didn't find a point, let the server know that there aren't spawn points. triggerServerEvent("event2",localPlayer,false) Link to comment
Feche1320 Posted December 5, 2014 Share Posted December 5, 2014 Because preventing is better then fixing. If you disagree with that, then you are just stupid. HAHAHAHAHAHAHAHAHAH thanks god that 2014 didn't end yet. You sir, are in the 2014 #1 ranking of stupids persons. Link to comment
Moderators IIYAMA Posted December 5, 2014 Moderators Share Posted December 5, 2014 Lol, that is exacly the definition of stupid behaviour. Link to comment
MTA Team 0xCiBeR Posted December 5, 2014 MTA Team Share Posted December 5, 2014 Please stay on topic. Link to comment
Saml1er Posted December 5, 2014 Share Posted December 5, 2014 O_o function createZombie ( x, y, z, rot, skin, interior, dimension ) if (table.getn( everyZombie ) < newZombieLimit ) then --this part handles the args if not x then return false end if not y then return false end if not z then return false end if not rot then rot = math.random (1,359) end if z < 0 then return end if not skin then randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) ) skin = ZombiePedSkins[randomZskin] end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now