Jump to content

giveWeapon on first spawn in my server


kewizzle

Recommended Posts

sorry i keep asking for help lol... i just dont know where im going wrong. I am just learning LOL i wanna give new players 15 pistol ammo when they first spawn. 

addEventHandler("onPlayerLogin", getRootElement(), function(_, account)
    if not getAccountData(account, "FirstTime") then 
        setAccountData(account, "FirstTime", true) 
addEventHandler("onPlayerSpawn", getRootElement(), function(_, account)
			if getAccountData(account, "FirstTime", true)  then
				giveWeapon ( source, 22, 15 ) 
			end
		end)
	end
end)

 

Link to comment
local giveWeaponT = {}

addEventHandler("onPlayerLogin", getRootElement(), function(_, account)
	if not getAccountData(account, "FirstTime") then 
		setAccountData(account, "FirstTime", true)
		giveWeaponT[source] = true
	end
end)
addEventHandler("onPlayerSpawn", getRootElement(), function()
	if giveWeaponT[source] theN
		giveWeaponT[source] = false
		-- Give weapon
	end
end)

I think this one should work.

Link to comment
1 hour ago, NeXuS™ said:

local giveWeaponT = {}

addEventHandler("onPlayerLogin", getRootElement(), function(_, account)
	if not getAccountData(account, "FirstTime") then 
		setAccountData(account, "FirstTime", true)
		giveWeaponT[source] = true
	end
end)
addEventHandler("onPlayerSpawn", getRootElement(), function()
	if giveWeaponT[source] theN
		giveWeaponT[source] = false
		-- Give weapon
	end
end)

I think this one should work.

it doesnt work still also i fixed your then aswell

its okay i got it working with this

addEventHandler("onPlayerSpawn", getRootElement(), function()
getammo = getPedTotalAmmo(source)
		if getammo <= 14 then
		giveWeapon ( source, 22, 15 ) 
	end
end)

 

Link to comment

What you did above doesn't serve your purpose, It actually gives players weapons whenever they spawn with no weapon doesn't matter it was thier first or 20th time.

You will need I think;

function giveWeaponForOnce()
  local account = getPlayerAccount(source)
  if not getAccountData(account,"firstTime") then
    setAccountData(account,"firstTime",true)
    giveWeapon(source,22,15)
    end
  end
addEventHandler("onPlayerSpawn",root,giveWeaponForOnce)

 

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