Jump to content

Zombies Weapons


BorderLine

Recommended Posts

Hi forum's people.

I need a big help, and is how i can give to zombies some weapons, like bat, or knife or other.

The script is the same of slothman, and i dont know how start :S

just i know how setteam to some ped, but i dont know if this is same.

If someone know how doit, please :)

my server is Biohazard, if someone want visit it :D (sorry offtopic, just say information)

Link to comment
ped = createPed( 19, -1634.5775, 1203.85, 7.1796 ) 
  
addCommandHandler( "give", 
  function ( player, command, id, amount ) 
    if not tonumber ( id ) then return end 
  
    if not tonumber ( amount ) then 
        amount = 9001 
    end 
  
    giveWeapon( ped, id, amount, true ) 
  end 
) 

You can give him a weapon with "give " command in console.

Link to comment
addEvent("Zomb_STFU",true) 
addEventHandler("Zomb_STFU",root, 
function ( zomb ) 
   if zomb and getElementType ( zomb ) == "ped" then 
        giveWeapon ( zomb, 8, 1, true ) 
        outputChatBox ( "zomb with weapon!" ) 
   end 
  
        outputChatBox ( "zombie spawned!" ) 
end) 

Try it and tell me what does it say when a zombie spawns.

Link to comment

dont show message, but im change Zomb_STFU to onZombieSpawn

  
  
addEvent("onZombieSpawn",true) 
addEventHandler("onZombieSpawn",root, 
function ( zomb ) 
   if zomb and getElementType ( zomb ) == "ped" then 
        giveWeapon ( zomb, 8, 1, true ) 
        outputChatBox ( "zomb with weapon!" ) 
   end 
  
        outputChatBox ( "zombie spawned!" ) 
end) 
  

then show message "zombie spawned!"

Link to comment

I just understood my mistake and why all doesn't work.

CLIENT.

addEvent("Zomb_STFU",true) 
addEventHandler("Zomb_STFU",root, 
function ( zomb ) 
   triggerServerEvent ( "onZombieSpawned", zomb ) 
end) 

SERVER:

addEvent("onZombieSpawned",true) 
addEventHandler("onZombieSpawned",root, 
function ( ) 
  giveWeapon ( source, 8, 1, true ) 
end) 

That should work :D

Link to comment

Why would the source be a player? lol.

In this case, do this:

  
addEvent( "onZombieSpawn", true ) 
--ADD THIS 
addEvent("onZombieCreate", 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 
        if table.getn ( everyZombie ) < newZombieLimit 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, 1000, 1, zomb ) 
                setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb ) 
                triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb ) 
                --ADD THIS 
                triggerEvent("onZombieCreate", zomb) 
            end 
        end 
    end 
end 
addEventHandler( "onZombieSpawn", getRootElement(), RanSpawn_Z ) 
  

In zombie_server.lua in the zombies resource.

Then, just use the onZombieCreate event.

Link to comment
Why would the source be a player?
function Spawn_Place(xcoord, ycoord) 
    local x,y,z = getElementPosition( getLocalPlayer() ) 
    local posx = x+xcoord 
    local posy = y+ycoord 
    local gz = getGroundPosition ( posx, posy, z+500 ) 
    triggerServerEvent ("onZombieSpawn", getLocalPlayer(), posx, posy, gz+1 ) 
end 

Also I already made a solution, why do you create another one? :P

Link to comment
I just understood my mistake and why all doesn't work.

CLIENT.

addEvent("Zomb_STFU",true) 
addEventHandler("Zomb_STFU",root, 
function ( zomb ) 
   triggerServerEvent ( "onZombieSpawned", zomb ) 
end) 

SERVER:

addEvent("onZombieSpawned",true) 
addEventHandler("onZombieSpawned",root, 
function ( ) 
  giveWeapon ( source, 8, 1, true ) 
end) 

That should work :D

This work perfect

thank a lot Benxamix2, and solid and jhon..

and the last question. i dont disturb.

how i can add more weapons.

I mean. not all zombies have same weapons, some chainsaw, others knife or katana

what is that fuction for do that?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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