[HELP]freeze and unfreeze
#1

i made freeze and unfreeze commands...
but i dont know how to do that if the player is already froze dont send him again the message %s froze you...
same with unfreeze... if player is not frozen, dont send any message to the client. just send a message to the admin
"This Player Is already frozen"/"This Player is not frozen"(there i no errors with my code i just dont know how to do ^^)
sorry for my bad english...
code:
PHP код:
if(strcmp(cmd"/unfreeze"true) == 0){
new 
tmp[256];
tmp strtok(cmdtextidx);
if(!
strlen(tmp)) {
  
SendClientMessage(playeridCOLOUR_ORANGE"Usage : /unfreeze [playerid]");
  return 
1;
  }
  
new 
victim;
  
victim strval(tmp);
  
  new 
string[128];
  new 
playername[MAX_PLAYER_NAME];
  
GetPlayerName(playeridplayernamesizeof(playername));
  new 
playername2[MAX_PLAYER_NAME];
  
GetPlayerName(victimplayername2sizeof(playername2));
 
 
format(stringsizeof(string), "%s unfrozed you."playername);
  
SendClientMessage(victimCOLOUR_YELLOWstring);
TogglePlayerControllable(victim1);
format(stringsizeof(string), "You unfrozed %s."playername2);
  
SendClientMessage(playeridCOLOUR_YELLOWstring);
  return 
1;
  }
 
 if(
strcmp(cmd"/freeze"true) == 0) {
 new 
tmp[256];
tmp strtok(cmdtextidx);
if(!
strlen(tmp)) {
  
SendClientMessage(playeridCOLOUR_ORANGE"Usage : /freeze [playerid]");
  return 
1;
  }
  
  new 
victim;
  
victim strval(tmp);
  
 new 
string[128];
  new 
playername[MAX_PLAYER_NAME];
  
GetPlayerName(playeridplayernamesizeof(playername));
  new 
playername2[MAX_PLAYER_NAME];
  
GetPlayerName(victimplayername2sizeof(playername2));
 
  
format(stringsizeof(string), "%s froze you."playername);
  
SendClientMessage(victimCOLOUR_YELLOWstring);
TogglePlayerControllable(victim0);
format(stringsizeof(string), "You froze %s."playername2);
  
SendClientMessage(playeridCOLOUR_YELLOWstring);
  return 
1;
  } 
Reply
#2

Do you mean, like if a person is frozen you cant do it to them /froze [pid]
Reply
#3

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Do you mean, like if a person is frozen you cant do it to them /froze [pid]
yes, and if the player is not froze you cant do /unfreeze [pid]
Reply
#4

pawn Код:
if(strcmp(cmd, "/unfreeze", true) == 0)
{
    new tmp[256];
    tmp = strtok(cmdtext, idx);

    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /unfreeze [playerid]");
        return 1;
    }

    new victim;
    victim = strval(tmp);

    if(GetPVarInt(victim, "frozen") == 0) return SendClientMessage(playerid, COLOUR_ORANGE, "Hes not frozen.");

    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(victim, playername2, sizeof(playername2));
    SetPVarInt(victim, "frozen", 0);
    format(string, sizeof(string), "%s unfrozed you.", playername);
    SendClientMessage(victim, COLOUR_YELLOW, string);
    TogglePlayerControllable(victim, 1);

    format(string, sizeof(string), "You unfrozed %s.", playername2);
    SendClientMessage(playerid, COLOUR_YELLOW, string);
    return 1;
}


if(strcmp(cmd, "/freeze", true) == 0)
{
    new tmp[256];
    tmp = strtok(cmdtext, idx);

    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /freeze [playerid]");
        return 1;
    }

    new victim;
    victim = strval(tmp);
    if(GetPVarInt(victim, "frozen") == 1) return SendClientMessage(playerid, COLOUR_ORANGE, "Hes frozen!.");
    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(victim, playername2, sizeof(playername2));

    SetPVarInt(victim, "frozen", 1);

    format(string, sizeof(string), "%s froze you.", playername);
    SendClientMessage(victim, COLOUR_YELLOW, string);
    TogglePlayerControllable(victim, 0);

    format(string, sizeof(string), "You froze %s.", playername2);
    SendClientMessage(playerid, COLOUR_YELLOW, string);
    return 1;
}
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/unfreeze", true) == 0)
{
    new tmp[256];
    tmp = strtok(cmdtext, idx);

    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /unfreeze [playerid]");
        return 1;
    }

    new victim;
    victim = strval(tmp);

    if(GetPVarInt(victim, "frozen") == 0) return SendClientMessage(playerid, COLOUR_ORANGE, "Hes not frozen.");

    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(victim, playername2, sizeof(playername2));
    SetPVarInt(victim, "frozen", 0);
    format(string, sizeof(string), "%s unfrozed you.", playername);
    SendClientMessage(victim, COLOUR_YELLOW, string);
    TogglePlayerControllable(victim, 1);

    format(string, sizeof(string), "You unfrozed %s.", playername2);
    SendClientMessage(playerid, COLOUR_YELLOW, string);
    return 1;
}


if(strcmp(cmd, "/freeze", true) == 0)
{
    new tmp[256];
    tmp = strtok(cmdtext, idx);

    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /freeze [playerid]");
        return 1;
    }

    new victim;
    victim = strval(tmp);
    if(GetPVarInt(victim, "frozen") == 1) return SendClientMessage(playerid, COLOUR_ORANGE, "Hes frozen!.");
    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(victim, playername2, sizeof(playername2));

    SetPVarInt(victim, "frozen", 1);

    format(string, sizeof(string), "%s froze you.", playername);
    SendClientMessage(victim, COLOUR_YELLOW, string);
    TogglePlayerControllable(victim, 0);

    format(string, sizeof(string), "You froze %s.", playername2);
    SendClientMessage(playerid, COLOUR_YELLOW, string);
    return 1;
}
thx, but can you plz explain the line that you add? (its 2 lines but only diffrences is 1-0)
Reply
#6

Add a pvar and set it, then make a if statement etc..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)