SA-MP Forums Archive
Slap command help - 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: Slap command help (/showthread.php?tid=498511)



Slap command help - Vasu99 - 03.03.2014

I'm having some troubles with this following slap command. As I perform it, it always shows up my, the "slap-pers", name, which is quite annoying. I mean, lets say I'm Subject 1 and I'm slapping Subject 2 due to Non-RP. It will still generate and show me the following message.

Quote:

You have successfully slapped Subject 1 || [Non-RP]

pawn Код:
CMD:slap(playerid, params[])
{
    if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid, 0xF69521AA, "You can't use this command!");//Checking if the player has admin level 1, if not it sends him a message.
    new id, reason[100];
    if(sscanf(params,"us[100]",id, reason)) return SendClientMessage(playerid, 0xa10000,"USAGE: /slap [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xF69521AA,"The specified player is currently not connected!");//Checking if the selected user is connected or not.

    new string[128], Float: PPos[3];
    GetPlayerPos(id, PPos[0], PPos[1], PPos[2]);
    SetPlayerPos(id, PPos[0], PPos[1], PPos[2]+4);

    GetPlayerName(playerid, string, 21);
    format(string, sizeof(string), "You have successfully slapped %s! || %s", string, reason);
    SendClientMessage(playerid, 0xF69521AA, string);
    return 1;
}



Re: Slap command help - Aerotactics - 03.03.2014

pawn Код:
GetPlayerName(id, string, 21);
Since you defined variable "id," You should use that to get the other player's name.


Re: Slap command help - Vasu99 - 03.03.2014

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
pawn Код:
GetPlayerName(id, string, 21);
Since you defined variable "id," You should try to use that to get the other player's name.
How do I do that? Not really that experienced with pawno.


Re: Slap command help - PrivatioBoni - 03.03.2014

Quote:
Originally Posted by Vasu99
Посмотреть сообщение
How do I do that? Not really that experienced with pawno.
Replace
pawn Код:
GetPlayerName(playerid, string, 21);
with
pawn Код:
GetPlayerName(id, string, 21);



Re: Slap command help - BKarner - 03.03.2014

Код:
GetPlayerName(playerid, string, 21);
    format(string, sizeof(string), "You have successfully slapped %s! || %s", string, reason);
    SendClientMessage(playerid, 0xF69521AA, string);
    return 1;
Here, you are getting the name of the person who DID /slap.

Код:
GetPlayerName(id, string, 21);
    format(string, sizeof(string), "You have successfully slapped %s! || %s", string, reason);
    SendClientMessage(playerid, 0xF69521AA, string);
    return 1;
This is what you need to change it to.


Re: Slap command help - Nurgle4 - 03.03.2014

First of all you have to get the name of the player you slapped so you have to make it like this:
pawn Код:
GetPlayerName(id, string, 21);
Instead of:
pawn Код:
GetPlayerName(playerid, string, 21);
So it will be like this:
pawn Код:
CMD:slap(playerid, params[])
{
    if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid, 0xF69521AA, "You can't use this command!");//Checking if the player has admin level 1, if not it sends him a message.
    new id, reason[100];
    if(sscanf(params,"us[100]",id, reason)) return SendClientMessage(playerid, 0xa10000,"USAGE: /slap [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xF69521AA,"The specified player is currently not connected!");//Checking if the selected user is connected or not.

    new string[128], Float: PPos[3];
    GetPlayerPos(id, PPos[0], PPos[1], PPos[2]);
    SetPlayerPos(id, PPos[0], PPos[1], PPos[2]+4);

    GetPlayerName(id, string, 21);
    format(string, sizeof(string), "You have successfully slapped %s! || %s", string, reason);
    SendClientMessage(playerid, 0xF69521AA, string);
    return 1;
}