Strcmp:makeadmin problem.
#1

Got a problem, still fairly new to scripting, and I cannot understand the issues.

pawn Код:
new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    else if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(Player[playerid][AdminLevel] >= 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;
               }
               giveplayerid = ReturnUser(tmp);
               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][AdminLevel] = 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][AdminLevel]);
                               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;
    }
Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(648) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(648) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(648) : error 001: expected token: ";", but found "if"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 017: undefined symbol "Player"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#2

do u have this ?
pawn Код:
enum pData
{
      AdminLevel,
}
new PlayerData[MAX_PLAYERS][pData];

    else if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
    //try change it to
    if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
Reply
#3

pawn Код:
if(Player[playerid][AdminLevel] >= 6); // 654
I need your Enum, if it's pInfo then do this

pawn Код:
if(pInfo[playerid][AdminLevel] >= 6); // 654
if it's pData then do this
pawn Код:
if(pData[playerid][AdminLevel] >= 6); // 654
Reply
#4

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
do u have this ?
pawn Код:
enum pData
{
      AdminLevel,
}
new PlayerData[MAX_PLAYERS][pData];

    else if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
    //try change it to
    if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
Yup, and it worked, now I only have these errors.

Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 017: undefined symbol "Player"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : fatal error 107: too many error messages on one line
Reply
#5

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
pawn Код:
if(Player[playerid][AdminLevel] >= 6); // 654
I need your Enum, if it's pInfo then do this

pawn Код:
if(pInfo[playerid][AdminLevel] >= 6); // 654
if it's pData then do this
pawn Код:
if(pData[playerid][AdminLevel] >= 6); // 654
yea that's true Rudy
Reply
#6

Enum:
pawn Код:
enum pInfo
{
   AdminLevel
}
Line with errors changed to:
pawn Код:
if(pInfo[playerid][AdminLevel] >= 6);
And I got new errors!
Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(62) : error 017: undefined symbol "Info"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(62) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#7

Quote:
Originally Posted by Cxnnor
Посмотреть сообщение
Yup, and it worked, now I only have these errors.

Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 017: undefined symbol "Player"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(654) : fatal error 107: too many error messages on one line
pawn Код:
#include <a_samp>

enum pData
{
      AdminLevel,
}
new PlayerData[MAX_PLAYERS][pData];

    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(pData[playerid][AdminLevel] >= 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;
               }
               giveplayerid = ReturnUser(tmp);
               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][AdminLevel] = 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][AdminLevel]);
                               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 this Cxnnor
Reply
#8

Thank you! It worked, but one more problem, sorry for bothering.

pawn Код:
public OnPlayerConnect(playerid)
{
    pData[playerid][AdminLevel] = 0;
    return 1;
}
Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 028: invalid subscript (not an array or too many subscripts): "pData"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

I am getting errors of one line now.
pawn Код:
public OnPlayerConnect(playerid)
{
    pData[playerid][AdminLevel] = 0;
    return 1;
}
Код:
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 028: invalid subscript (not an array or too many subscripts): "pData"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : warning 215: expression has no effect
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 001: expected token: ";", but found "]"
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : error 029: invalid expression, assumed zero
C:\Users\Connor\Desktop\Development\0.3E - SCRIPT\gamemodes\AGS.pwn(243) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#10

try this

pawn Код:
enum pInfo
{
      pAdmin,
};
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pAdmin] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmdtext, "/makeadmin",true)) // 648
    {
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if(pInfo[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;
               }
               giveplayerid = ReturnUser(tmp);
               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][AdminLevel] = 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][AdminLevel]);
                               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;
    }
change the variables to pInfo - PlayerInfo
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)