Jump to content

give weapon


boro

Recommended Posts

Hi all is any way to give player weapon from client side

i try it with triger

triggerServerEvent ( "onGreeting", getLocalPlayer() ) 

function giveweapon ( ) 
    giveWeapon ( source, 31, 200 ) 
end 
addEvent( "onGreeting", true ) 
addEventHandler( "onGreeting", resourceRoot, giveweapon ) 

but it dont work

any ideas ?

Link to comment

It didn't work because you tried giving the weapon to the resource root.

client:

triggerServerEvent("onGreeting",localPlayer,localPlayer) 

server:

addEvent("onGreeting",true) 
addEventHandler("onGreeting",resourceRoot, 
function(p) 
giveWeapon(p,31,200) 
end) 

Link to comment

ty for reply but this dont work no errors and debug is clear

full script

function zombiedamaged (killer, weapon, bodypart ) 
        if ( killer and killer == getLocalPlayer() ) then 
triggerServerEvent("onGreetingtwo",getLocalPlayer(),getLocalPlayer()) 
    end 
end 
addEventHandler ( "onClientPedWasted", getRootElement ( ), zombiedamaged ) 

addEvent("onGreetingtwo",true) 
addEventHandler("onGreetingtwo",resourceRoot, 
function(p) 
giveWeapon(p,31,200) 
end) 

Link to comment
  • Moderators
addEvent("onGreetingtwo",true) 
addEventHandler("onGreetingtwo",root, 
function(p) 
giveWeapon(p,31,200) 
end) 

resourceRoot to root. When you use resourceRoot, only the resourceRoot can execute this function. When using root, all elements can execute this function.

This element will be also known as the source of the event. (the variable source holds this element(userdata))

The source element is the element you define in your triggerClient/ServerEvent, this one comes directly after the event name.

triggerClientEvent ( [table/element sendTo=getRootElement()], string name, [color=#FF0000]element sourceElement[/color], [arguments...] ) 
  
triggerServerEvent ( string event, [color=#FF0000]element theElement[/color], [arguments...] ) 

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