#1

Hello. I'm trying to add a /setadmin command but i get an error on this line:

PHP код:
 if(PlayerInfo[ID][AdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF"ERROR: That person is already this admin level!"); 
PHP код:
enum PlayerInfo
{
    
Pass[129],
    
Adminlevel,
    
Money,
    
Scores,
    
Kills,
    
Deaths,
}
new 
pInfo[MAX_PLAYERS][PlayerInfo];
new 
levels,ID,pname
The Errors Are:

Код:
error 028: invalid subscript (not an array or too many subscripts): "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
The Whole /setadmin Code:

PHP код:
CMD:setadmin(playeridparams[])
{
    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 6) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
    
if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0x99CEFFFF,"That user is not connected.");//Detect if the id/partofname is connected
    
if(PlayerInfo[ID][AdminLevel] == 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,NamMAX_PLAYER_NAME);//define the playerid name
    
GetPlayerName(ID,pname,MAX_PLAYER_NAME);//define the other person name
    
if(levels == 0)
    {
        
format(strsizeof(str),"%s has your Admin level to %d on the server. *cry *cry",Nam,levels);
        
SendClientMessage(ID,0xFF9900AA,str);
        
format(strsizeof(str),"You had set %s Admin level to %d!",pname,levels);
        
SendClientMessage(playerid,0xFF9900AA,str);
        
PlayerInfo[ID][AdminLevel] = levels;//this sets the player level
        
return 1;
    }
    
format(strsizeof(str),"%s has your Admin level to %d on the server.",Nam,levels);
    
SendClientMessage(ID,0xFF9900AA,str);
    
format(strsizeof(str),"You had set %s Admin level to %d!",pname,levels);
    
SendClientMessage(playerid,0xFF9900AA,str);
    
PlayerInfo[ID][AdminLevel] = levels;
    return 
1;

Reply
#2

enum PlayerInfo
{
Pass[129],
Adminlevel,
Money,
Scores,
Kills,
Deaths
}
new pInfo[MAX_PLAYERS][PlayerInfo];
// you could define this vars in the command if u use only in the command and not in the whole script :/
new levels,ID,pname;
Reply
#3

What do you mean? Sorry im abit new to this Pawno.
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=298218
tutorial for setadmin

pawn Код:
enum pInfo
{
    Pass[129],
    Adminlevel,
    Money,
    Scores,
    Kills,
    Deaths,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#5

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
I have been following it. But i don't understand how i will script it in into my Y_INI script.
Reply
#6

change the Admin Variable to pAdmin

pawn Код:
#include a_samp
#include zcmd
#include sscanf2

enum pInfo
{
    Pass[129],
    pAdmin,
    pMoney,
    pScores,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new str[256],levels,ID,Nam[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME];

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 > 6) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0x99CEFFFF,"That user is not connected.");//Detect if the id/partofname is connected
    if(PlayerInfo[ID][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[ID][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[ID][pAdmin] = levels;
    return 1;
}
Reply
#7

When i did that. It gave me this:

Код:
pawno\include\YSI\y_debug.inc(276) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_debug.inc(338) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_debug.inc(343) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_amx.inc(448) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_amx.inc(898) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_amx.inc(920) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_utils.inc(237) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_utils.inc(360) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_utils.inc(387) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_utils.inc(466) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_malloc.inc(487) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_malloc.inc(611) : warning 219: local variable "str" shadows a variable at a preceding level
pawno\include\YSI\y_ini.inc(1071) : warning 219: local variable "str" shadows a variable at a preceding level
roleplay.pwn(38) : warning 219: local variable "str" shadows a variable at a preceding level
roleplay.pwn(48) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
roleplay.pwn(48) : error 029: invalid expression, assumed zero
roleplay.pwn(48) : error 029: invalid expression, assumed zero
gamemodes\roleplay.pwn(48) : fatal error 107: too many error messages on one line

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


4 Errors.
HERE Is the Whole Script: http://pastebin.com/Au1TCgie
Reply
#8

Just replace all PlayerInfo in command setadmin to pInfo and replace

pawn Код:
new levels,ID,pname;
to

pawn Код:
new levels,ID,pname[24];
Reply
#9

Fixed Pastebin
Reply
#10

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
Fixed Pastebin
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)