justn Posted March 28, 2014 Share Posted March 28, 2014 (edited) The problem here is, when the player spawns, he doesn't get back the weapons he had before he died. can someone fix ? I already have another code kinda like this, but it works for players who's not in a group. local playerWeapons = { } function spawn () if ( getElementData(source, "Group" ) ~= "TMZ" ) then else if not( isGuestAccount (getPlayerAccount(source)) ) then if ( not playerWeapons [ source ] ) and ( getElementData(source, "Group" ) == "TMZ" ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo setTimer (spawnPlayer,5600,1,source,2296.646484375, 556.4404296875, 11.618446350098) giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end end end end end addEventHandler("onPlayerWasted", getRootElement( ), spawn) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( playerWeapons [ source ] ) and ( getElementData(source, "Group" ) == "TMZ" ) then for weapon, ammo in pairs ( playerWeapons [ source ] ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end playerWeapons [ source ] = nil end ) Edited March 28, 2014 by Guest Link to comment
Castillo Posted March 28, 2014 Share Posted March 28, 2014 Your saving code is a mess, you are respawning the player as many times as weapons the player has. Link to comment
justn Posted March 28, 2014 Author Share Posted March 28, 2014 ..Ah, so can you help please ? Link to comment
Castillo Posted March 28, 2014 Share Posted March 28, 2014 local playerWeapons = { } function spawn () if ( getElementData ( source, "Group" ) == "TMZ" ) then if ( not isGuestAccount ( getPlayerAccount ( source ) ) ) then if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end setTimer ( spawnPlayer, 5600, 1, source, 2296.646484375, 556.4404296875, 11.618446350098 ) end end end addEventHandler ( "onPlayerWasted", getRootElement( ), spawn ) Link to comment
justn Posted March 28, 2014 Author Share Posted March 28, 2014 Doesn't work, I think the problem may be in the other spawn ? Link to comment
Castillo Posted March 28, 2014 Share Posted March 28, 2014 Any errors in debugscript? Link to comment
justn Posted March 28, 2014 Author Share Posted March 28, 2014 @SolidSnake14 Nope @WhoAmI Yes I am logged in 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