SA-MP Forums Archive
[Help] Saving Weapons - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Saving Weapons (/showthread.php?tid=93634)



[Help] Saving Weapons - Nakash - 26.08.2009

Hey,i have looked everywhere for a script that will save the weapon in a file,
and when someone comes in it'll give him the gun.
the script will check if the player has a gun,if he does it will save it and it's ammo in a file,
the file can be his name.gun or his name.txt,
I heard thats easy.


Re: [Help] Saving Weapons - Gamer_Z - 26.08.2009

pawn Код:
stock LoadWeapons(playerid){
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i; i < 13; i++){
        format(amm, sizeof amm, "Ammo%d", i);format(wep, sizeof wep, "Weapon%d", i);GivePlayerWeapon(playerid, dUserINT(pname).(wep), dUserINT(pname).(amm));
    }
    return true;
}
stock SaveWeapons(playerid){
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i, cwep, camm; i < 13; i++){
        format(amm, sizeof amm, "Ammo%d", i);format(wep, sizeof wep, "Weapon%d", i);GetPlayerWeaponData(playerid, i, cwep, camm);
        dUserSetINT(pname).(amm, camm);dUserSetINT(pname).(wep, cwep);
    }
    return true;
}
the code is not mine! i found it somewhere on samp forum, sry dunno where it was.. long time ago..
but here you go..i assuem you know how to use it?.. in onplayerspawn, onplayerdisconnect.. etc


Re: [Help] Saving Weapons - Nakash - 26.08.2009

Thank you but it's not working..stock is black and not blue,i tried to change it to public,didnt work.
i have dudb.inc,it gives me 6 errors:

D:\zz\ъйчйд згщд\skrp.pwn(275 : error 029: invalid expression, assumed zero
D:\zz\ъйчйд згщд\skrp.pwn(275 : error 017: undefined symbol "SaveWeapons"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "Stock"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "LoadWeapons"
D:\zz\ъйчйд згщд\skrp.pwn(3650) : warning 225: unreachable code
D:\zz\ъйчйд згщд\skrp.pwn(7910) : error 021: symbol already defined: "strtok"
D:\zz\ъйчйд згщд\skrp.pwn(7925) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.



Re: [Help] Saving Weapons - Gamer_Z - 26.08.2009

D:\zz\ъйчйд згщд\skrp.pwn(275 : error 029: invalid expression, assumed zero
Код:
D:\zz\ъйчйд згщд\skrp.pwn(2758) : error 017: undefined symbol "SaveWeapons"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "Stock"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "LoadWeapons"
WTF WHAT DID U DO?... it's working either for me lol -.-
Код:
D:\zz\ъйчйд згщд\skrp.pwn(3650) : warning 225: unreachable code
check your returns and brackets
Код:
D:\zz\ъйчйд згщд\skrp.pwn(7910) : error 021: symbol already defined: "strtok"
dudb has already strtok.. delete the one from your gm/fs
Код:
D:\zz\ъйчйд згщд\skrp.pwn(7925) : error 047: array sizes do not match, or destination array is too small
what to say -,-.. somewhere like new blabla[bad_boy1] / new blabla [badboy1][badboy2].. ot something,,


Re: [Help] Saving Weapons - Nakash - 26.08.2009

I put the SaveWeapons at the OnPlayerDisconnect right ?
and the LoadWeapons at OnPlayerSpawn,
i don't know ;( is stock blue ?
maybe it's strok lol ?


Re: [Help] Saving Weapons - dice7 - 26.08.2009

Quote:

D:\zz\ъйчйд згщд\skrp.pwn(275 : error 029: invalid expression, assumed zero
D:\zz\ъйчйд згщд\skrp.pwn(275 : error 017: undefined symbol "SaveWeapons"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "Stock"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "LoadWeapons"

It's stock, not Stock


Re: [Help] Saving Weapons - Nakash - 26.08.2009

Quote:
Originally Posted by dice7
Quote:

D:\zz\ъйчйд згщд\skrp.pwn(275 : error 029: invalid expression, assumed zero
D:\zz\ъйчйд згщд\skrp.pwn(275 : error 017: undefined symbol "SaveWeapons"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "Stock"
D:\zz\ъйчйд згщд\skrp.pwn(3641) : error 017: undefined symbol "LoadWeapons"

It's stock, not Stock
I tried stock,it didn't work so i did Stock.


Re: [Help] Saving Weapons - Gamer_Z - 26.08.2009

u need to put these functions at the end of your script and at onplayerconnect LoadWeapons(playerid); and at disconnect SaveWeapons(playerid);



Re: [Help] Saving Weapons - Nakash - 26.08.2009

Quote:
Originally Posted by gamer_Z
u need to put these functions at the end of your script and at onplayerconnect LoadWeapons(playerid); and at disconnect SaveWeapons(playerid);
Still,i get these errors :

D:\zz\skrp.pwn(2220) : warning 225: unreachable code
D:\zz\skrp.pwn(2220) : error 029: invalid expression, assumed zero
D:\zz\skrp.pwn(2220) : error 017: undefined symbol "LoadWeapons"
D:\zz\skrp.pwn(2774) : error 029: invalid expression, assumed zero
D:\zz\skrp.pwn(2774) : error 017: undefined symbol "SaveWeapons"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Please help me



Re: [Help] Saving Weapons - snoob - 27.08.2009

try this
http://snoob-community.wikispaces.com/CLFS.pwn
its not only weapon but it should work.