KruTolic_rus Posted January 6, 2014 Share Posted January 6, 2014 Здраствуйте... Я менял код slothmana на зомби под себя,вроде бы,ничего такого трудного не было,поэтому ничего не спрашивал,но когда я сделал так,что бы в радиусе 50 метров было не больше 10 зомби,я обнаружил,что это глобальная задача.То есть,максимум,у меня может быть на сервере 10 зомби.Они делятся между игроками,ведь если больше 10,то зомби уже не спавняться. Мне нужно провести проверку так,что бы брало всех игроков и у каждого индивидуально была проверка,а потом,если около него больше 10 зомби,то именно возле него прекратить спавн.А другим игрокам ничего не запрещать,пока тоже не наберут 10 зомби... Обьяснил как то...может и поняли. Вот кусок кода: server: addEvent( "onZombieSpawn", true ) function RanSpawn_Z ( gx, gy, gz, rot) local safezone = 0 local allradars = getElementsByType("radararea") for theKey,theradar in ipairs(allradars) do if getElementData(theradar, "zombieProof") == true then if isInsideRadarArea ( theradar, gx, gy ) then safezone = 1 end end end if safezone == 0 then LimitZombie = 0 local allplayers = getElementsByType ( "player" ) for ZombKey,theZomb in ipairs(everyZombie) do if isElement(theZomb) then if (getElementData (theZomb, "zombie") == true) then far = 1 local Zx, Zy, Zz = getElementPosition( theZomb ) for theKey,thePlayer in ipairs(allplayers) do local Px, Py, Pz = getElementPosition( thePlayer ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if distance < 50 then LimitZombie = LimitZombie + 1 end if distance > 30 then chaseanim = "sprint_civi" end if distance < 30 then chaseanim = "run_civi" end end end end end if table.getn ( everyZombie ) < newZombieLimit and LimitZombie < 10 then if not rot then rot = math.random (1,359) end randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) ) local zomb = createPed( tonumber( ZombiePedSkins[randomZskin] ), gx, gy, gz ) if zomb ~= false then setElementData ( zomb, "zombie", true ) table.insert( everyZombie, zomb ) setTimer ( function (zomb, rot) if ( isElement ( zomb ) ) then setPedRotation ( zomb, rot ) end end, 500, 1, zomb, rot ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setPedAnimation ( zomb, "ped", chaseanim, -1, true, true, true ) end end, 1500, 1, zomb ) setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb ) triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb ) end end end end addEventHandler( "onZombieSpawn", getRootElement(), RanSpawn_Z ) И на всякий... спавн зомби function SpawnZombie () local pacecount = 0 while pacecount < 7 do --7 ZOMBIES AT A TIME TO PREVENT FPS DROP if (table.getn( everyZombie )+pacecount < newZombieLimit ) and (ZombieStreaming == 1) then local xcoord = 0 local ycoord = 0 local xdirection = math.random(1,2) if xdirection == 1 then xcoord = math.random(15,40) else xcoord = math.random(-40,-15) end local ydirection = math.random(1,2) if ydirection == 1 then ycoord = math.random(15,40) else ycoord = math.random(-40,-15) end local liveplayers = getAlivePlayers () if (table.getn( liveplayers ) > 0 ) then local lowestcount = 999 local lowestguy = nil for PKey,thePlayer in ipairs(liveplayers) do if isElement(thePlayer) then if (getElementData (thePlayer, "dangercount")) and (getElementData(thePlayer, "zombieProof") ~= true) and (getElementData(thePlayer, "alreadyspawned" ) == true) then if (getElementData (thePlayer, "dangercount") < lowestcount) then local safezone = 0 local gx, gy, gz = getElementPosition( thePlayer ) local allradars = getElementsByType("radararea") for theKey,theradar in ipairs(allradars) do if getElementData(theradar, "zombieProof") == true then if isInsideRadarArea ( theradar, gx, gy ) then safezone = 1 end end end if safezone == 0 then lowestguy = thePlayer lowestcount = getElementData (thePlayer, "dangercount") end end end end end pacecount = pacecount+1 if isElement(lowestguy) then triggerClientEvent ( "Spawn_Placement", lowestguy, ycoord, xcoord ) else pacecount = pacecount+1 end else pacecount = pacecount+1 end else pacecount = pacecount+1 end end 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