Jump to content

Crear sistema de zombies


Soren

Recommended Posts

Client:

addEventHandler("onClientResourceStart",root, 
  
function() 
  
triggerServerEvent("onSpawnSlothBot",localPlayer) -- ahi el source es el localPlayer 
  
end 
) 

Server:

function onSpawnSlothBot() 
    local x, y, z = getElementPosition (source) 
    local rot = 0 
    local int = getElementInterior(source) 
    local dim = getElementDimension(source) 
    local weapon =  0 
    local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin 
    for i = 1,10 do 
call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, nil, weapon) 
  
 end 
end 
addEvent("onSpawnSlothBot",true) 
addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) 
  

<meta>   
    <info author="iSoRen" name="Zday script" version="3.0.1" type="script" description="Zombie Infestation script" /> 
    <script src="server.lua" type="server" /> 
    <script src="client.lua" type="client" /> 
  
</meta> 

Link to comment

A mi me pasaba lo mismo xD...Nunca use el SlothBot, seguramente si estan todos el mismo team no se pegan (pones friendlyfire,false)

Fijate con esto (no estoy seguro) :

  
local teamZombie = createTeam("Zombies") 
  
function onSpawnSlothBot() 
    local x, y, z = getElementPosition (source) 
    local rot = 0 
    local int = getElementInterior(source) 
    local dim = getElementDimension(source) 
    local weapon =  0 
    local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin 
    setTeamFriendlyFire(teamZombie,false) 
    for i = 1,10 do 
call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
  
 end 
end 
addEvent("onSpawnSlothBot",true) 
addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) 
  
  

Link to comment
A mi me pasaba lo mismo xD...Nunca use el SlothBot, seguramente si estan todos el mismo team no se pegan (pones friendlyfire,false)

Fijate con esto (no estoy seguro) :

  
local teamZombie = createTeam("Zombies") 
  
function onSpawnSlothBot() 
    local x, y, z = getElementPosition (source) 
    local rot = 0 
    local int = getElementInterior(source) 
    local dim = getElementDimension(source) 
    local weapon =  0 
    local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin 
    setTeamFriendlyFire(teamZombie,false) 
    for i = 1,10 do 
call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
  
 end 
end 
addEvent("onSpawnSlothBot",true) 
addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) 
  
  

Funciono perfecto!! eres todo un genio!! solo hace falta lograr arreglar lo dde los respawns de los slothbots :)

Link to comment

Es que pensa que el evento solamente se hace cuando empieza el resource...Si queres que respawneen tendrias que usar el evento "onBotWasted"

  
 local teamZombie = createTeam("Zombies") 
function onSpawnSlothBot() 
    local x, y, z = getElementPosition (source) 
    local rot = 0 
    local int = getElementInterior(source) 
    local dim = getElementDimension(source) 
    local weapon =  0 
    setTeamFriendlyFire(teamZombie,false) 
    local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin 
    for i = 1,10 do 
call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
  
 end 
end 
addEvent("onSpawnSlothBot",true) 
addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) 
  
function onBotWasted(attacker,weapon,bodypart) 
  
local x,y,z = getElementPosition(attacker) 
local rot = 0 
local int = getElementInterior(attacker) 
local dim = getElementDimension(attacker) 
local weapon =  0 
local skin = math.random(math.floor(21,23))  
    call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
     
end 
addEventHandler("onBotWasted",getRootElement(),onBotWasted) 
  

EDIT : Castillo, pera no entiendo...lo que quizo el era que cuando empezaba el recurso aparezcan los zombies, y entonces aparecen 10 en fila

Link to comment
El evento "onSpawnSlothBot" seguro se ejecuta cuando un bot spawnea, entonces vos estas creando los bots cuando otro bot spawnea.

P.D: Para usar un evento creado por el script tambien tenes que usar addEvent.

No , lo cree yo el "onSpawnSlothBot" jaja. Soy muy malo poniendo nombres a eventos. Mira el full code

Client

addEventHandler("onClientResourceStart",root, 
  
function() 
  
triggerServerEvent("onSpawnSlothBot",localPlayer) -- ahi el source es el localPlayer 
  
end 
) 

Server

local teamZombie = createTeam("Zombies") 
function onSpawnSlothBot() 
    local x, y, z = getElementPosition (source) 
    local rot = 0 
    local int = getElementInterior(source) 
    local dim = getElementDimension(source) 
    local weapon =  0 
    setTeamFriendlyFire(teamZombie,false) 
    local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin 
    for i = 1,10 do 
call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
  
 end 
end 
addEvent("onSpawnSlothBot",true) 
addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) 
  
function onBotWasted(attacker,weapon,bodypart) 
  
local x,y,z = getElementPosition(attacker) 
local rot = 0 
local int = getElementInterior(attacker) 
local dim = getElementDimension(attacker) 
local weapon =  0 
local skin = math.random(math.floor(21,23))  
    call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
     
end 
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(),onBotWasted) 
  

Fijate que lo cambie ahora y le puse el onBotWasted

Link to comment

De ultima proba poniendo el de

  
  
function onBotWasted(attacker,weapon,bodypart) 
  
local x,y,z = getElementPosition(attacker) 
local rot = 0 
local int = getElementInterior(attacker) 
local dim = getElementDimension(attacker) 
local weapon =  0 
local skin = math.random(math.floor(21,23)) 
    call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) 
    
end 
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(),onBotWasted) 
  
  

Eso en el script de "slothbot" (osea lo pegas adentro del lado server). Se que no es lo mejor, pero no se como exportarlo.

Link to comment
  • 1 month later...
  • Recently Browsing   0 members

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