[Tutorial] Making simple commands using zcmd and sscanf
#10

good tutorial, still-which i think would be more efficient using sscanf slots and fail to declare as much local variable, greetings and good luck.

pawn Код:
CMD:heal(playerid, params[])
{
    if(IsPlayerAdmin(playerid)) // Note: first is to check if you are an administrator.
    {
        if(sscanf(params, "u", params[0])) return SendClientMessage(playerid, -1, "usage: /heal [playerid/name].");
        if(IsPlayerConnected(params[0]) && params[0] != INVALID_PLAYER_ID)
        {
            new g_string[91]; // You don't need 128 in its string.
            SetPlayerHealth(params[0], 100.0);
            format(g_string, sizeof(g_string), "RCON Administrator %s(%d) has healed %s(%d).", Name(playerid), playerid, Name(params[0]), params[0]);
            SendClientMessage(params[0], -1, g_string);
        }
    }
    else
    {
        SendClientMessage(playerid, -1, " You are not authorized to use this command.");
    }
    return true;
}

stock Name(playerid)
{
    new name_player[24];
    GetPlayerName(playerid, name_player, 24);
    return name_player;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)