Jump to content

giveWeapon for first join


Notorious^

Recommended Posts

Posted (edited)

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^
Posted (edited)

Should be working, make sure this script is running on server side and als make sure in meta.xml file there's actually code of line that uses that file as server side script.

Edited by Fist
Posted
1 hour ago, Fist said:

Should be working, make sure this script is running on server side and als make sure in meta.xml file there's actually code of line that uses that file as server side script.

ı checked again now.all is good man.why not working ı dont know :C

Posted

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 )

 

Posted (edited)
2 minutes ago, Notorious^ said:

ı tried 3 times not working mate. :/

wired you are sure have it in mtaa folder resource also trtied to restart the resource after change it?

Edited by Dimos7
Posted
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

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