Jump to content

Give weapon


Recommended Posts

Hi there, I have a problem with my code, its just simple triggering but I dont know why it doesn't works

-- Server sided 
root = getRootElement() 
function gW(gid,gammo) 
giveWeapon(source,gid,gammo) 
end 
addEvent("giveW",true) 
addEventHandler("giveW",root,gW) 
-- client sided 
function giveWeapon(wID,wAmmo) 
triggerServerEvent("giveW",getLocalPlayer(),id,ammo) 
end 

I am trying to use it as,

--client 
function onSpawn() 
gang = guiGridListGetSelectedItem(gangName) 
skin = guiGridListGetSelectedItem(gangSkins) 
if gang == grove then 
giveWeapon(22,100) 
giveWeapon(29,300) 
giveWeapon(30,350) 
giveWeapon(27,99) 
if skin == skin1 then spawnSkin = 105 
elseif skin == skin2 then spawnSkin = 106 
elseif skin == skin3 then spawnSkin = 107 
elseif skin == skin4 then spawnSkin = 207 
end 
end 
end 

---there are more ---

event I am using is

addEventHandler("onClientGUIClick",button,onSpawn,false) 

and trying to give the weapon when player spawns

Thanks

Link to comment

client side:

function giveWeapon(wID,wAmmo) 
triggerServerEvent("giveW",getLocalPlayer(),wID,ammo) 
end 

server side:

root = getRootElement() 
function gW(gid,gammo) 
giveWeapon(source,tostring(gid),tostring(gammo)) 
end 
addEvent("giveW",true) 
addEventHandler("giveW",root,gW) 

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...