#1

pawn Код:
CMD:slap(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, X, Y, Z);
    format(str, sizeof(str), "%s was slapped by %s", name, name);
    if(sscanf(params, "us[128]", playerid, str)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /slap <playerid>");
    else
    {
        PlayerPlaySound(playerid, 1190, X, Y, Z);
        SetPlayerPos(playerid, X, Y, Z+7);
        TogglePlayerControllable(playerid, true);
        SendClientMessageToAll(COLOR_DARKRED, str);
    }
    return 1;
}
Well I have it showing Usage: /slap <playerid> but I type my Id and it just shows this all the time?
Reply
#2

pawn Код:
sscanf(params, "u", playerid)
Reply
#3

Cheers bud, I'll try that now.

EDIT: It works, Cheers!

EDIT #2: How would I set it so it checks the player's ID??
Reply
#4

Sorry for this bump but I could do with this.
Reply
#5

What do you mean "checks the players ID"?
Reply
#6

pawn Код:
CMD:slap(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, str[128], id, name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /slap <player name/id>");
    else
    {
        GetPlayerPos(id, X, Y, Z);
        PlayerPlaySound(id, 1190, X, Y, Z);
        SetPlayerPos(id, X, Y, Z+7);
        TogglePlayerControllable(id, true);
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        GetPlayerName(id, name2, MAX_PLAYER_NAME);
        format(str, sizeof(str), "%s was slapped by %s", name2, name);
        SendClientMessageToAll(COLOR_DARKRED, str);
    }
    return 1;
}
Reply
#7

pawn Код:
CMD:slap(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, str[128], name[MAX_PLAYER_NAME];
    new Float:Health;
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health-25);
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, X, Y, Z);
    format(str, sizeof(str), "%s was slapped by %s", name, name);
    if(sscanf(params, "u", playerid)) {
        return SendClientMessage(playerid, 0xFF0000AA, "Usage: /slap <playerid>");
    }
    if (!IsPlayerConnected(playerid)) {
      return SendClientMessage(playerid, COLOR_DARKRED, "[ERROR:] This ID is has not been found.");
    }
    else
    {
        PlayerPlaySound(playerid, 1190, X, Y, Z);
        SetPlayerPos(playerid, X, Y, Z+7);
        TogglePlayerControllable(playerid, true);
        SendClientMessageToAll(COLOR_DARKRED, str);
    }
    return 1;
}
If you look I added
pawn Код:
if (!IsPlayerConnected(playerid)) {
      return SendClientMessage(playerid, COLOR_DARKRED, "[ERROR:] This ID is has not been found.");
    }
But it don't work so I was wondering how I could do it.. Although this is just a test so..

EDIT: Okay I'll try that.

EDIT #2: Yes, Gar's code works but still I need it to check the if the player is connected.
Reply
#8

This should do the trick...

pawn Код:
CMD:slap(playerid, params[])
{
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /slap <playerid>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_DARKRED, "[ERROR:] This ID is has not been found.");
    else
    {
        new Float:X, Float:Y, Float:Z, Float:Health, str[128], name[MAX_PLAYER_NAME];

        PlayerPlaySound(id, 1190, X, Y, Z);
        SetPlayerHealth(id, Health-25);

        GetPlayerPos(id, X, Y, Z);
        SetPlayerPos(id, X, Y, Z+7);

        GetPlayerName(id, pName, sizeof(name));
        GetPlayerName(id, aName, sizeof(name));
        format(str, sizeof(str), "%s was slapped by %s", pName, aName);
        SendClientMessageToAll(COLOR_DARKRED, str);
    }
    return 1;
}
Reply
#9

the variable 'id' = the player you want to slap
playerid = the player who typed the command
Reply
#10

Sorry about this but still it does not detect that the players ID is not connected..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)