weapon slots - 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)
+--- Thread: weapon slots (
/showthread.php?tid=543739)
weapon slots -
Bondage - 28.10.2014
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
Re: weapon slots -
Abagail - 28.10.2014
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]);
}
|
Re: weapon slots -
Bondage - 28.10.2014
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?
Re: weapon slots -
M4D - 28.10.2014
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.
Re: weapon slots -
Bondage - 28.10.2014
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