Dont receive any messages?
#1

pawn Код:
CMD:setlevel(playerid, params[])
{
  new tmp[128], tmp2[128], index;
  tmp = strtok(params, index), tmp2 = strtok(params, index);

  new giveplayerid, level;
  giveplayerid = strval(tmp), level = strval(tmp2);

  if(PlayerInfo[playerid][AdminLevel] > 4 || IsPlayerAdmin(playerid)) {
    if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
    if(isnull(tmp)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
    if(isnull(tmp2)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
    if(level == PlayerInfo[giveplayerid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Player is already this level");
    if(level < 0 || level > 5) return SendClientMessage(playerid, COLOR_RED, "Invalid level");
    if(IsPlayerConnected(giveplayerid)) {
      new string[128], playername[MAX_PLAYER_NAME], giveplayername[MAX_PLAYER_NAME];
      GetPlayerName(playerid, playername, sizeof playername); GetPlayerName(giveplayerid, giveplayername, sizeof giveplayername);

      format(string, sizeof string, "Administrator %s has set your admin level to %d", playername, level);
      SendClientMessage(giveplayerid, COLOR_BLUE, string);
      format(string, sizeof string, "You have set %s admin level to %d", giveplayername, level);
      SendClientMessage(playerid, COLOR_BLUE, string);

      PlayerInfo[giveplayerid][AdminLevel] = level;
    }
    else return SendClientMessage(playerid, COLOR_RED, "Player not Connected");
  }
  else return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
  return 1;
}
It sets my level and everything, But i dont see the messages..
Why?
Reply
#2

Why do you check if the parameters are null? Just do a comparison between what you want the numbers, or letters to be.
Reply
#3

Huh? Sorry im new to doing this, I dont normally do it this way
Reply
#4

Use sscanf

Quote:
Originally Posted by Joe Torran C
Huh? Sorry im new to doing this, I dont normally do it this way
And a good suggestion, do it on your own way
Reply
#5

My own way is sscanf but it all went wrong,
For example using rcon aswell as admin level,

And we agreed to do it this way so..
Reply
#6

Quote:
Originally Posted by Joe Torran C
My own way is sscanf but it all went wrong,
For example using rcon aswell as admin level,

And we agreed to do it this way so..
And where is now the problem with sscanf ?
if something went wrong, fix it

pawn Код:
CMD:setlevel(playerid, params[])
{
  if(!(PlayerInfo[playerid][AdminLevel] > 4 || IsPlayerAdmin(playerid)))
    return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
  new id, level;
  if(sscanf(params, "ui", id, level))
    return SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel [PlayerID/PartOfName] [Level]");
  else if(!IsPlayerConnected(id))
    return SendClientMessage(playerid, COLOR_RED, "Player not Connected");
  else if(0 > level || level > 5)
    return SendClientMessage(playerid, COLOR_RED, "Invalid level");
  else if(level == PlayerInfo[id][AdminLevel])
    return SendClientMessage(playerid, COLOR_RED, "Player is already this level");
  new string[70];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  format(string, sizeof string, "Administrator %s has set your admin level to %d", string, level);
  SendClientMessage(id, COLOR_BLUE, string), GetPlayerName(id, string, MAX_PLAYER_NAME);
  format(string, sizeof string, "You have set %s admin level to %d", string, level);
  SendClientMessage(playerid, COLOR_BLUE, string);
  PlayerInfo[id][AdminLevel] = level;
  return 1;
}
And to your main problem that the messages didnt appeared
The code was correct so the cause is/was somewhere else
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)