Some errors and warnings in a command.
#1

Hello,

I am trying to make a command to set admins with, I searched and found one.. I changed it to suit my registration system but I am facing some problems:

pawn Код:
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_utils.inc(160) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_utils.inc(263) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_utils.inc(289) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_debug.inc(231) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_debug.inc(291) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_debug.inc(296) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\pawno\include\YSI\y_ini.inc(804) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(663) : warning 219: local variable "pname" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(678) : warning 219: local variable "ID" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(678) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(678) : warning 219: local variable "pname" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(780) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(781) : error 032: array index out of bounds (variable "PlayerInfo")
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(790) : error 032: array index out of bounds (variable "PlayerInfo")
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(797) : error 032: array index out of bounds (variable "PlayerInfo")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
The command:
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0; //This command only works for rcon
    if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /setadmin [ID] [Level 1-4]");//it will show this if you dont use the format properly
    if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,red,"That user is not connected.");//Detect if the id/partofname is connected
    if(PlayerInfo[MAX_PLAYERS][pAdmin] == levels) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That person is already this admin level!");//Detect if the guy is already the level you setted
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);//define the playerid name
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);//define the other person name
    if(levels == 0)
    {
        format(str, sizeof(str),"%s has your Admin level to %d on the server. *cry *cry",Nam,levels);
        SendClientMessage(ID,0xFF9900AA,str);
        format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
        SendClientMessage(playerid,0xFF9900AA,str);
        PlayerInfo[MAX_PLAYERS][pAdmin] = levels;//this sets the player level
        return 1;
    }
    format(str, sizeof(str),"%s has your Admin level to %d on the server.",Nam,levels);
    SendClientMessage(ID,0xFF9900AA,str);
    format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
    SendClientMessage(playerid,0xFF9900AA,str);
    PlayerInfo[MAX_PLAYERS][pAdmin] = levels;
    return 1;
}
The line on the top:

pawn Код:
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[128],ID;
EDIT: I am currently fixing the errors O.O.


Okay everything is fixed but this PlayerInfo problem is still.. 3 errors

pawn Код:
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(781) : error 032: array index out of bounds (variable "PlayerInfo")
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(790) : error 032: array index out of bounds (variable "PlayerInfo")
C:\Documents and Settings\Administrator\Desktop\server\gamemodes\gm.pwn(797) : error 032: array index out of bounds (variable "PlayerInfo")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Line 781:
pawn Код:
if(PlayerInfo[MAX_PLAYERS][pAdmin] == levels) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That person is already this admin level!")
Line 790:
pawn Код:
PlayerInfo[MAX_PLAYERS][pAdmin] = levels;
Line 797:
pawn Код:
PlayerInfo[MAX_PLAYERS][pAdmin] = levels;

Alright, everything is fixed I had to change from MAX_PLAYERS to playerid! Sorry for disturbing! You may close this one ^^.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)