kewizzle Posted April 1, 2017 Posted April 1, 2017 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)
NeXuS™ Posted April 1, 2017 Posted April 1, 2017 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.
kewizzle Posted April 1, 2017 Author Posted April 1, 2017 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)
_DrXenon Posted April 2, 2017 Posted April 2, 2017 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now