weapon slots
#1

Hello guys,
i've got a simple doubt and need help regarding it, i'm wondering whether it would be possible to save the players weapon slots (like how many weapons they have and ammo). Ive been thinking of an event but in that players should not be able to use weapons so before joining the event their weapons should be reset and on the same time it should be saved, after they exit the event they should get back the same weapons and ammo. Is it possible to do that, if so could you show me the example script? It'd be appreciated.

Thanks
Reply
#2

See GetPlayerWeaponData on the WIKI(https://sampwiki.blast.hk/wiki/GetPlayerWeaponData),

Quote:
Originally Posted by SAMP Wiki
// Common use: get all weapons and store info in an array containing 13 slots
// The first value is the weapon ID, and second is the ammo

new weapons[13][2];

for (new i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
Reply
#3

Quote:
Originally Posted by Abagail
Посмотреть сообщение
GetPlayerWeaponData[/url]),
I get it, GetPlayerWeaponData is used to save the player weapons but how it could be given back after a player get disarmed?
Reply
#4

Hi.
before event you have to save players weapon data into variable, reset their weapon and do event.
after event reset their weapon again and give back weapons by variable.
i'll give you an e.g.

pawn Код:
//>Top Of You Script:
new PlayerWeaponID[MAX_PLAYERS][13];
new PlayerWeaponAmmo[MAX_PLAYERS][13];

//>Before Start Event Save Player Weapon...

for (new i = 0; i <= 12; i++)
{
    GetPlayerWeaponData(playerid, i, PlayerWeaponID[playerid][i], PlayerWeaponAmmo[playerid][i]);
}

//>you saved player weapons into "PlayerWeaponID" and "PlayerWeaponAmmo" Variable. now you can reset player weapon
//>if you want do this for all players use foreach or loop
//>for example:
//>X is player ids..
foreach(Player, x)
{
 for (new i = 0; i <= 12; i++)
 {
    GetPlayerWeaponData(x, i, PlayerWeaponID[x][i], PlayerWeaponAmmo[x][i]);
 }
}

ResetPlayerWeapons(playerid); //For event.
now event finished and you want to give back weapons.

pawn Код:
//>its for all players. if you want you can do this for one player...
foreach(Player, x)
{
//>First reset weapons.
 ResetPlayerWeapons(x);
//>Now give back weapons...
 for (new i = 0; i <= 12; i++)
 {
   GivePlayerWeapon(x, PlayerWeaponID[x][i], PlayerWeaponAmmo[x][i]);
 }
}
Hope i helped.
Reply
#5

Quote:
Originally Posted by M4D
Посмотреть сообщение
Hi.
before event you have to save players weapon data into variable, reset their weapon and do event.
after event reset their weapon again and give back weapons by variable.
i'll give you an e.g.

pawn Код:
//>Top Of You Script:
new PlayerWeaponID[MAX_PLAYERS][13];
new PlayerWeaponAmmo[MAX_PLAYERS][13];

//>Before Start Event Save Player Weapon...

for (new i = 0; i <= 12; i++)
{
    GetPlayerWeaponData(playerid, i, PlayerWeaponID[playerid][i], PlayerWeaponAmmo[playerid][i]);
}

//>you saved player weapons into "PlayerWeaponID" and "PlayerWeaponAmmo" Variable. now you can reset player weapon
//>if you want do this for all players use foreach or loop
//>for example:
//>X is player ids..
foreach(Player, x)
{
 for (new i = 0; i <= 12; i++)
 {
    GetPlayerWeaponData(x, i, PlayerWeaponID[x][i], PlayerWeaponAmmo[x][i]);
 }
}

ResetPlayerWeapons(playerid); //For event.
now event finished and you want to give back weapons.

pawn Код:
//>its for all players. if you want you can do this for one player...
foreach(Player, x)
{
//>First reset weapons.
 ResetPlayerWeapons(x);
//>Now give back weapons...
 for (new i = 0; i <= 12; i++)
 {
   GivePlayerWeapon(x, PlayerWeaponID[x][i], PlayerWeaponAmmo[x][i]);
 }
}
Hope i helped.
Thanks both of you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)