SA-MP Forums Archive
Dont receive any messages? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dont receive any messages? (/showthread.php?tid=134954)



Dont receive any messages? - Torran - 18.03.2010

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?


Re: Dont receive any messages? - Hiitch - 18.03.2010

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



Re: Dont receive any messages? - Torran - 18.03.2010

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


Re: Dont receive any messages? - Nero_3D - 18.03.2010

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


Re: Dont receive any messages? - Torran - 18.03.2010

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..


Re: Dont receive any messages? - Nero_3D - 18.03.2010

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