How can I reset weapon, what's player holding?
#1

Hello guys, how I can reset just one player weapon, what he have on hand? Thx
Reply
#2

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
Reply
#3

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;
}
Reply
#4

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?
Reply
#5

You should get the current weapon id, store that somewhere in a variable and use the function above dynamically.
Reply
#6

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?
Reply
#7

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
Reply
#8

Well mate Thanks, I will try it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)