How can I reset weapon, what's player holding? -
Riwerry - 14.11.2013
Hello guys, how I can reset just one player weapon, what he have on hand? Thx
Re: How can I reset weapon, what's player holding? -
Ghazal - 14.11.2013
PHP код:
dcmd_disarm(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params,"u",ID))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /disarm (Player Name/ID)");
return 1;
}
if(IsSpawned[ID] == 0)
{
format(string,sizeof(string),"%s(%d) is must be alive and spawned in order to give them a weapon.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
ResetPlayerWeapons(ID);
format(string,sizeof(string),"[ADMIN ACTION]%s(%d) Disarmed you.",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_ERROR,string);
format(string,sizeof(string),"[ADMIN ACTION]You Disarmed %s(%d).",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
Maybe Command Like This?
+ REP If helped
Re: How can I reset weapon, what's player holding? - Patrick - 14.11.2013
Quote:
Originally Posted by Maro06
PHP код:
dcmd_disarm(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params,"u",ID))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /disarm (Player Name/ID)");
return 1;
}
if(IsSpawned[ID] == 0)
{
format(string,sizeof(string),"%s(%d) is must be alive and spawned in order to give them a weapon.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
ResetPlayerWeapons(ID);
format(string,sizeof(string),"[ADMIN ACTION]%s(%d) Disarmed you.",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_ERROR,string);
format(string,sizeof(string),"[ADMIN ACTION]You Disarmed %s(%d).",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
Maybe Command Like This?
+ REP If helped
|
Sir you don't know
, he said a function that removes a weapon
Simple Function I made
pawn Код:
stock RemoveSpecificWeapon(playerid, weaponid)
return GivePlayerWeapon(playerid, weaponid, 0);
//Simple Command how to use 'RemoveSpecificWeapon' function
CMD:dropmp5(playerid, params[])
{
RemoveSpecificWeapon(playerid, mp5weaponid);
return 1;
}
Re: How can I reset weapon, what's player holding? -
Riwerry - 14.11.2013
1. I don't need command for disarm
2. This removes all player weapons, not only one what's he holding in hand
3. Anyway, thanks for response, but that's not it
EDIT// RemoveSpecificWeapon (playerid, weaponid);
What can I use to get weaponid of the weapon which he hold in hand?
Re: How can I reset weapon, what's player holding? -
Kingunit - 14.11.2013
You should get the current weapon id, store that somewhere in a variable and use the function above dynamically.
Re: How can I reset weapon, what's player holding? -
Riwerry - 14.11.2013
Tried this
pawn Код:
new weaponid[MAX_PLAYERS];
weaponid [playerid] = GetPlayerWeapon(playerid);
//AND THEN THIS
RemoveSpecificWeapon (playerid, weaponid [playerid]);
DIDN'T WORKED, ANY OTHER IDEAS pls?
Re: How can I reset weapon, what's player holding? -
Jefff - 14.11.2013
pawn Код:
RemovePlayerWeapon(playerid, weaponid)
{
new
pWeapon[13 char],
pAmmo[13]
;
for(new i=0; i != 13; i++)
GetPlayerWeaponData(playerid, i, pWeapon{i}, pAmmo[i]);
ResetPlayerWeapons(playerid);
for(new i=0; i != 13; i++)
if(pWeapon{i} != weaponid && pAmmo[i] > 0)
GivePlayerWeapon(playerid, pWeapon{i});
}
usage
pawn Код:
new Weapon = GetPlayerWeapon(playerid);
if(Weapon > 0)
RemovePlayerWeapon(playerid, Weapon);
and next time search [ RemovePlayerWeapon, ResetPlayerWeapon ]
http://forum.sa-mp.com/search.php?searchid=7417688
Re: How can I reset weapon, what's player holding? -
Riwerry - 14.11.2013
Well mate Thanks, I will try it.