#1

Hello guys...
Yesterday i made cmd that freezes player, heres code:
pawn Код:
CMD:freeze(playerid, params[])
{
    new id;
    new msg[50], string[128], string1[128], string2[128];
    if(sscanf(params,"us[50]",id,msg)) return SendClientMessage(playerid, -1, "Usage: /freeze [id] [reason]");
    TogglePlayerControllable(id,0);
    SetPVarInt(id,"freeze",1);
    format(string, sizeof(string), "You have frozen %s for reason: %s", PlayerName(id),msg);
    SendClientMessage(playerid, COLOR_GREEN, string);
    format(string1, sizeof(string1), "You have been frozen by Admin, reason: %s", msg);
    SendClientMessage(id, COLOR_RED, string1);
    format(string2, sizeof(string2), "%s has been frozen by Admin (%s)", PlayerName(id), msg);
    SendClientMessageToAll(COLOR_RED, string2);
    if(id == playerid) return SendClientMessage(playerid, COLOR_YELLOW, "Error: You cannot use this command on yourself");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_YELLOW, "Error: This player is not connected");
    return 1;
}
now...i want to make this cmd to check is player already frozen so if i type /freeze id reason but player is already frozen it will say to me: Error: this player is already frozen.
Reply
#2

First make array
pawn Код:
new IsPlayerFrozen[MAX_PLAYER_NAME]
then u check i player frozen
pawn Код:
CMD:freeze(playerid, params[])
 {
//HERE U CHECK IS PLAYER FROZEN
if(IsPlayerFrozen[playerid] == 0){
 new id;
 new msg[50], string[128], string1[128], string2[128];
 if(sscanf(params,"us[50]",id,msg)) return SendClientMessage(playerid, -1, "Usage: /freeze [id] [reason]");
 TogglePlayerControllable(id,0);
 IsPlayerFrozen[playerid] = 1;//HERE U SET THE VARIBLE FOR PLAYERID SO THE SERVER KNOWS THIS PLAYER IS FROZEN
 SetPVarInt(id,"freeze",1);
 format(string, sizeof(string), "You have frozen %s for reason: %s", PlayerName(id),msg);
 SendClientMessage(playerid, COLOR_GREEN, string);
 format(string1, sizeof(string1), "You have been frozen by Admin, reason: %s", msg);
 SendClientMessage(id, COLOR_RED, string1);
 format(string2, sizeof(string2), "%s has been frozen by Admin (%s)", PlayerName(id), msg);
 SendClientMessageToAll(COLOR_RED, string2);
 if(id == playerid) return SendClientMessage(playerid, COLOR_YELLOW, "Error: You cannot use this command on yourself");
 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_YELLOW, "Error: This player is not connected");
}
else{

}
 return 1;
 }
Reply
#3

pawn Код:
new Freeze[MAX_PLAYERS];

CMD:freeze2(playerid, params[])
{
    new id;
    new msg[50], string[128], string1[128], string2[128];
    if(Freeze[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"That Player is already in Frozen Mode!");
    }
    if(sscanf(params,"us[50]",id,msg)) return SendClientMessage(playerid, -1, "Usage: /freeze [id] [reason]");
    else if(id == playerid) return SendClientMessage(playerid, COLOR_YELLOW, "Error: You cannot use this command on yourself");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_YELLOW, "Error: This player is not connected");
    else
    {
        TogglePlayerControllable(id,0);
        SetPVarInt(id,"freeze",1);
        format(string, sizeof(string), "You have frozen %s for reason: %s", PlayerName(id),msg);
        SendClientMessage(playerid, COLOR_GREEN, string);
        format(string1, sizeof(string1), "You have been frozen by Admin, reason: %s", msg);
        SendClientMessage(id, COLOR_RED, string1);
        format(string2, sizeof(string2), "%s has been frozen by Admin (%s)", PlayerName(id), msg);
        SendClientMessageToAll(COLOR_RED, string2);
        Freeze[playerid] = 1;
    }
    return 1;
}
not tested ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)