SA-MP Forums Archive
what do I need to add - 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: what do I need to add (/showthread.php?tid=526356)



what do I need to add - saffierr - 17.07.2014

What did I miss?
when I do /resetweapon 2, it says "You removed the player's weapon" even when id 2 is not even connected...
What do I need to add, to say "Player is not connected"?

PHP код:
CMD:resetweapon(playeridparams[])
{
    if (!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"SERVER: Unknown command.");
    new 
targetid;
    if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /resetweapon [ID]");
    else if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Player is not connected.");
    
ResetPlayerWeapons(target);
    
    
SendClientMessage(playeridCOLOR_WARN"You removed the player's weapon.");
    
SendClientMessage(targetCOLOR_RED"You have been disarmed!");
    return 
1;




Re: what do I need to add - Battlezone - 17.07.2014

pawn Код:
CMD:resetweapon(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "SERVER: Unknown command.");

    new  id;

    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WARN, "USAGE: /resetweapon [ID]");

    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");

    ResetPlayerWeapons(id);
     
    SendClientMessage(playerid, COLOR_WARN, "You removed the player's weapon.");
    SendClientMessage(id, COLOR_RED, "You have been disarmed!");

    return 1;
}



Re: what do I need to add - Jack_Leslie - 17.07.2014

pawn Код:
CMD:resetweapon(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "SERVER: Unknown command.");

    new target;

    if(sscanf(params, "u", target)) return SendClientMessage(playerid, COLOR_WARN, "USAGE: /resetweapon [ID]");

    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_WARN, " That player is not connected !");

    ResetPlayerWeapons(target);

    SendClientMessage(playerid, COLOR_WARN, "You removed the player's weapon.");
    SendClientMessage(target, COLOR_RED, "You have been disarmed!");

    return 1;
}



Re: what do I need to add - saffierr - 17.07.2014

Thanks guys, See I knew I missed something, in this case I missed if(!IsPlayerConnected(target))


Re: what do I need to add - Jack_Leslie - 17.07.2014

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Thanks guys, See I knew I missed something, in this case I missed if(!IsPlayerConnected(target))
You didn't really miss anything, what you had should of worked, but the reason it didn't was due to your sscanf.

pawn Код:
new target, id;
if(sscanf(params, "u", target, id)) return SendClientMessage(playerid, COLOR_WARN, "USAGE: /resetweapon [ID]");
You have 'target' and 'id', then you only define 'target' in your sscanf. You didn't need the 'id', you only needed to use one. So either 'target' or 'id', not both, as there's only one parameter to this command which is one player. So if you just used either 'target' or 'id' instead of both, it would of worked.


Re: what do I need to add - saffierr - 17.07.2014

ehhehheheh Looolz, So that (!IsPlayerConnected(playerid)) is useless?


Re: what do I need to add - saffierr - 17.07.2014

FIXED - Lock


Re: what do I need to add - Jack_Leslie - 17.07.2014

Quote:
Originally Posted by saffierr
Посмотреть сообщение
ehhehheheh Looolz, So that (!IsPlayerConnected(playerid)) is useless?
No, it's not useless, it's just an alternative (another way) to use:
pawn Код:
else if(target == INVALID_PLAYER_ID)