Empty statement & Invalid expression.
#1

Eh, I am getting some troubles with my administrator system, I will post the enumerator, code and errors below. Please help me, if you succeed in doing so you shall gain REP.

ENUM:
pawn Код:
enum pInfo
{
      pAdmin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
OnPlayerConnect:
pawn Код:
PlayerInfo[playerid][pAdmin] = 0;
Command:
pawn Код:
new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmdtext, "/makeadmin",true))
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(PlayerInfo[playerid][pAdmin] == 6); // 654
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOR_GREY, "FUNCTION: Player will be an admin.");
                       return 1;
               }
               tmp = strtok(cmdtext, idx);
               new level = strval(tmp);
               if(giveplayerid != INVALID_PLAYER_ID)
               {
                       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                       GetPlayerName(playerid, player, sizeof(player));
                       PlayerInfo[giveplayerid][pAdmin] = level;
                       printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                       format(string, sizeof(string), "You are now an administrator level %d.", level,  player);
                       SendClientMessage(giveplayerid, COLOR_GREY, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][pAdmin]);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
       }
       else // 682
       {
           SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command!");
       }
       return 1;
    }
Errors:
Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 036: empty statement
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(682) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#2

pawn Код:
new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmdtext, "/makeadmin",true))
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(PlayerInfo[playerid][pAdmin] == 6)
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOR_GREY, "FUNCTION: Player will be an admin.");
                       return 1;
               }
               tmp = strtok(cmdtext, idx);
               new level = strval(tmp);
               if(giveplayerid != INVALID_PLAYER_ID)
               {
                       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                       GetPlayerName(playerid, player, sizeof(player));
                       PlayerInfo[giveplayerid][pAdmin] = level;
                       printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                       format(string, sizeof(string), "You are now an administrator level %d.", level,  player);
                       SendClientMessage(giveplayerid, COLOR_GREY, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][pAdmin]);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
       }
       else
       {
           SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command!");
       }
       return 1;
    }
Try replace the command with the code I gave you
Reply
#3

if(PlayerInfo[playerid][pAdmin] == 6);
change to
if(PlayerInfo[playerid][pAdmin] == 6)
Reply
#4

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
pawn Код:
new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmdtext, "/makeadmin",true))
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(PlayerInfo[playerid][pAdmin] == 6)
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOR_GREY, "FUNCTION: Player will be an admin.");
                       return 1;
               }
               tmp = strtok(cmdtext, idx);
               new level = strval(tmp);
               if(giveplayerid != INVALID_PLAYER_ID)
               {
                       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                       GetPlayerName(playerid, player, sizeof(player));
                       PlayerInfo[giveplayerid][pAdmin] = level;
                       printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                       format(string, sizeof(string), "You are now an administrator level %d.", level,  player);
                       SendClientMessage(giveplayerid, COLOR_GREY, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][pAdmin]);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, COLOR_GREY, string);
               }
       }
       else
       {
           SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command!");
       }
       return 1;
    }
Try replace the command with the code I gave you
Fixed, thank you very much, +REP.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)