Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- iCounter = 0;
- function createRandomPed()
- local player = getRandomPlayer();
- if not player then
- return;
- end
- local x,y,z = getElementPosition(player);
- x = x + math.random(-50,50);
- y = y + math.random(-50,50);
- z = z + 5;
- iCounter = iCounter + 1;
- createPed(iCounter%200,x,y,z);
- end
- function destroyRandomPed()
- for i,ped in ipairs(getElementsByType("ped")) do --this way it destroys less peds when there is not many peds.
- if math.random(0,5) == 1 then
- destroyElement(ped);
- return;
- end
- end
- end
- function keepPedsBelowHundred()
- local iCount = #getElementsByType("ped");
- if iCount > 99 then
- for i,ped in ipairs(getElementsByType("ped")) do
- if math.random(0,1) == 1 then
- destroyElement(ped);
- end
- end
- end
- end
- function setPedSyncer()
- for i,ped in ipairs(getElementsByType("ped")) do
- setElementSyncer(ped,getRandomPlayer());
- end
- end
- -- function init()
- -- done in onResourceStart
- -- end
- addEventHandler("onResourceStart",getResourceRootElement(),
- function()
- setTimer(createRandomPed,100,0);
- setTimer(destroyRandomPed,200,0);
- setTimer(keepPedsBelowHundred,1000,0);
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement