SA-MP Forums Archive
Weapon system - 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: Weapon system (/showthread.php?tid=240182)



Weapon system - jorambo - 15.03.2011

Heey guys,

I am trying to make a non-spawnweapon system.

What I mean is that when you have 100 ammo for a 9mm and you shoot 2 bullets that when you relog that your ammo is 98 left.

So I need to make that when you relog or when I want that the player saves it he needs to pick up what ammo you need.

Now I found the GetPlayerWeaponData, but how do you save that?

pawn Код:
new weapons[13];
new ammo[13];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i], ammo[i]);
}
This is what I have and how do you save it ?

I use dini.


Re: Weapon system - Stigg - 15.03.2011

Something like:

pawn Код:
dini_IntSet(File, "WEAPON", PlayerInfo[playerid][WEAPON] = GetPlayerWeapon(playerid));



Re: Weapon system - jorambo - 15.03.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Something like:

pawn Код:
dini_IntSet(File, "WEAPON", PlayerInfo[playerid][WEAPON] = GetPlayerWeapon(playerid));
But when a player has more guns then this doesn't work right?


Re: Weapon system - jorambo - 15.03.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Something like:

pawn Код:
dini_IntSet(File, "WEAPON", PlayerInfo[playerid][WEAPON] = GetPlayerWeapon(playerid));
I have found the saving shit now.

Now I have:

pawn Код:
new weapons[13][2], Str[30];
for(new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
    format( Str, 30, "Weapon%d", i );
    dini_IntSet(udb_encode(playername), Str, weapons[i][0]);
    format( Str, 30, "Ammo%d", i );
    dini_IntSet(udb_encode(playername), Str, weapons[i][1]);
}
But when a player is comming in the server,
The scriptfile is now looking like weapon0 = ... weapon 1 = ....
You need to do with everyting like GivePlayerWeapon(playerid, weapon0);
Or is there an easier way?