12p Posted February 20, 2011 Share Posted February 20, 2011 (edited) Solved. Edited February 20, 2011 by Guest Link to comment
Kenix Posted February 20, 2011 Share Posted February 20, 2011 I made a simple script to make players to save their weapons when they leave, and load their weapons when they login. Someway it doesn't work, but I don't know why... It doesn't look like having any problem while /debugscript 3 And it works at full with custom debug, too... slots = { 1, 2, 3, 4, 5, 6 } function save.weapons ( ped, acc ) if not source then source = ped end if not acc then acc = getPlayerAccount ( source ) end takeAllWeapons ( ped ) for i, s in ipairs ( slots ) do setPedWeaponSlot ( source, s ) local w = getPedWeapon ( source ) local a = getPedTotalAmmo ( source, s ) local a = a + getPedAmmoInClip ( source ) setAccountData ( acc, "save:weapon"..tostring ( s ), w ) setAccountData ( acc, "save:ammo"..tostring ( s ), a ) end end function load.weapons ( ped, acc ) if not source then source = ped end if not acc then acc = getPlayerAccount ( source ) end if getAccountData ( acc, "save:name" ) then for i, s in ipairs ( slots ) do local w = getAccountData ( acc, "save:weapon"..tostring ( s ) ) local a = getAccountData ( acc, "save:ammo"..tostring ( s ) ) if w ~= 0 and a > 0 then giveWeapon ( source, w, a, false ) end end end end use getPedWeaponSlot Link to comment
DiSaMe Posted February 20, 2011 Share Posted February 20, 2011 No, not getPedWeaponSlot, but use a second parameter of getPedWeapon. Also, don't take away the weapons before saving them. Link to comment
12p Posted February 20, 2011 Author Share Posted February 20, 2011 LoL. I was wrong on takeAllWeapons; it must be before loading weapons, not saving ^^. Gonna test and check what happens now. EDIT: I'm getting a bit stupid or what? That was all the prob. (but weird, before I changed that code, it didn't work)... EDIT 2: WTF It works ok when I have 1 weapon to save, but when I have more than 1 weapon, it saves only 1 weapon's ammo... O_o Link to comment
eAi Posted February 20, 2011 Share Posted February 20, 2011 Don't go removing your original post like that. Leaving it there is helpful to other users. Link to comment
norby89 Posted February 20, 2011 Share Posted February 20, 2011 Don't go removing your original post like that. Leaving it there is helpful to other users. Glad someone quoted his post. Link to comment
12p Posted February 20, 2011 Author Share Posted February 20, 2011 It isn't helpful as that code is bugged... (and as I made that script, someone could STEAL it and take the credits from it -.-) 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