GetPlayerWeapon
#1

Hey , I'm working on a saving weapon system , but the GetPlayerWeapon will get only the armed one isn't it ? how to use the 'GetPlayerWeapon' properly?

thanks.
Reply
#2

To get all weapons a player has, you need GetPlayerWeaponData function.
Reply
#3

Loop through all of the weapon slots and save them to an array:

pawn Код:
new Weapons[MAX_PLAYERS][13][2];
for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, Weapons[playerid][i][0], Weapons[playerid][i][1]);
Loop through all the weapon slots in an array and load them:

pawn Код:
new Weapons[MAX_PLAYERS][13][2];
for (new a = 0; a < 13; a++)
{
    if(Weapons[playerid][a][1] < 0) Weapons[playerid][a][1] = 99999;
    GivePlayerWeapon(playerid, Weapons[playerid][a][0], Weapons[playerid][a][1]);
}
Reply
#4

thank you ! but the [13] is slots ? please SKAzini I need explaination of your code (to learn it well).

waiting for your answer

EDIT:

I think I got it so Weapons is the variable that I must save it ?
Reply
#5

Player weapons will be saved in Weapons

[a] = Is the slot ID
[a][0] = Is weapon id
[a][1] = Is ammo of the weapon

[13] Means max weapon slots
Reply
#6

I understand now , but it only will save it in the server , but when disconnecting I should add that ?(don't think good to do that):
pawn Код:
dini_IntSet(file[playerid], "Weapons", Weapons[playerid]);
i'm using dini
Reply
#7

for (new i = 0; i < 13; i ++)
{
format(str, sizeof str, "Weapons_i%d", i);
dini_IntSet(file[playerid], str, Weapons[playerid][i][0]);
format(str, sizeof str, "Weapons_a%d", i);
dini_IntSet(file[playerid], str, Weapons[playerid][i][1]);
}
Reply
#8

Thanks ! one question OT:
Is there any way creating Buyable & savable Houses/cars using only Dini+dcmd+samp includes?
Reply
#9

Yes.

(Anyway dini is not the best saving system)
Reply
#10

MySQL is easier and better imo.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)