GrinningTrout Posted June 3, 2016 Share Posted June 3, 2016 function hp(source) ammo=getPedTotalAmmo(source) weapon=getPedWeapon(source) playeraccount = getPlayerAccount ( source ) setAccountData(playeraccount,"playerWeapon",weapon) setAccountData(playeraccount,"playerammo",ammo) giveWeapon(source,weapon,ammo) end addEventHandler("onPlayerWasted",getRootElement(),hp) addCommandHandler("wer",hp) ---------------------------------------------------------------------- addEventHandler("onPlayerSpawn",getRootElement(),function () playeraccount = getPlayerAccount ( source ) weapon=getAccountData(playeraccount,"playerWapon") ammo=getAccountData(playeraccount,"playerammo") giveWeapon(source,weapon,ammo) end) can u guys fix this to me i want when player die save his weapons and ammo, when spawn give player what he had before die Link to comment
Gravestone Posted June 4, 2016 Share Posted June 4, 2016 onPlayerWasted's first parameter is the total ammo of the player who died so you by writing source in there, you were trying to fetch information about the ammo's total ammo and account name which is impossible lol. So here's the fixed code. function hp() ammo = getPedTotalAmmo(source) weapon = getPedWeapon(source) playeraccount = getPlayerAccount ( source ) setAccountData(playeraccount,"weapon",weapon) setAccountData(playeraccount,"ammo",ammo) end addEventHandler("onPlayerWasted",getRootElement(),hp) addEventHandler("onPlayerSpawn",getRootElement(), function () local playeraccount = getPlayerAccount ( source ) local weapon = getAccountData(playeraccount,"weapon") local ammo = getAccountData(playeraccount,"ammo") giveWeapon(source,weapon,ammo) end) Link to comment
GrinningTrout Posted June 4, 2016 Author Share Posted June 4, 2016 onPlayerWasted's first parameter is the total ammo of the player who died so you by writing source in there, you were trying to fetch information about the ammo's total ammo and account name which is impossible lol. So here's the fixed code. function hp() ammo = getPedTotalAmmo(source) weapon = getPedWeapon(source) playeraccount = getPlayerAccount ( source ) setAccountData(playeraccount,"weapon",weapon) setAccountData(playeraccount,"ammo",ammo) end addEventHandler("onPlayerWasted",getRootElement(),hp) addEventHandler("onPlayerSpawn",getRootElement(), function () local playeraccount = getPlayerAccount ( source ) local weapon = getAccountData(playeraccount,"weapon") local ammo = getAccountData(playeraccount,"ammo") giveWeapon(source,weapon,ammo) end) thnx that works but it gives theplayer just the ammo of the weapon which was in his hands right before dies, i want it to give all the weapons that he has Link to comment
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