Jump to content

giveWeapon for first join


Notorious^

Recommended Posts

Hello all,

I want give m4 to player when he first join.but my code not working.whats my mistake.can you help me ? :/

Quote

function joinPlayerGiveWeapon ( )
        giveWeapon ( source, 31, 200 ) 
end
addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon )

 

 

Edited by Notorious^
Link to comment

well if you want to give the player only for the first join, you can do this:

setElementData(source, "hasRecieved", false) -- Do this on your first join script or register


function joinPlayerGiveWeapon ( )
  		hasWeap = getElementData(source, "hasRecieved")
  		if not hasWeap then
        	giveWeapon ( source, 31, 200 ) 
    		setElementData(source, "hasRecieved", true)
    	end
end
addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon )

 

Link to comment
3 hours ago, LyricalMM said:

well if you want to give the player only for the first join, you can do this:


setElementData(source, "hasRecieved", false) -- Do this on your first join script or register


function joinPlayerGiveWeapon ( )
  		hasWeap = getElementData(source, "hasRecieved")
  		if not hasWeap then
        	giveWeapon ( source, 31, 200 ) 
    		setElementData(source, "hasRecieved", true)
    	end
end
addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon )

 

Element data won't work correctly because when the player leaves the server the data will be gone, the only way to make it is by using accounts data or databases.

  • Like 1
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...