SA-MP Forums Archive
error 033: array must be indexed (variable "minutes") - 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)
+--- Thread: error 033: array must be indexed (variable "minutes") (/showthread.php?tid=540640)



error 033: array must be indexed (variable "minutes") - XGreen - 06.10.2014

Code:
PHP код:
stock BanPlayerTemp(playerid,reason[],admin[],hours[],minutes[])
{
    new 
ppp[50];
    new 
exp=gettime()+(60*minutes)+(60*60*hours); //error line
    
GetPlayerIp(playerid,ppp,sizeof(ppp));
    new 
INI:File INI_Open(UserBanPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Banexp",exp);
    
INI_WriteInt(File,"BanPerm",0);
    
INI_WriteString(File,"BanAdmin",admin);
    
INI_WriteString(File,"Reason",reason);
    
INI_WriteString(File,"IP",ppp);
    
INI_Close(File);
    new 
banmt[300],targetn[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,targetn,sizeof(targetn));
    new 
INI:iFile INI_Open(UserIPPath(playerid));
    
INI_SetTag(iFile,"data");
    
INI_WriteInt(iFile,"Banexp",exp);
    
INI_WriteInt(iFile,"BanPerm",0);
    
INI_WriteString(iFile,"BanPlayer",targetn);
    
INI_WriteString(iFile,"BanAdmin",admin);
    
INI_WriteString(iFile,"Reason",reason);
    
INI_Close(iFile);
    new 
File:logg=fopen("BannedPlayers.txt",io_append);
    
fwrite(loggtargetn);
    
fwrite(logg,"\n");
    
fclose(logg);
    
format(banmt,sizeof(banmt),"{DC143C}Admin %s has banned you for %i hours %i minutes due to %s",admin,hours,minutes,reason);
    
SendClientMessage(playerid,-1,banmt);
    
SetTimerEx("KickPlayer",100,false,"i",playerid);




Re: error 033: array must be indexed (variable "minutes") - XGreen - 06.10.2014

Heres the cmd that using that stock:
PHP код:
CMD:bantempplayeridparams[ ] )
{
    if(
pInfo[playerid][pAdminLevel] >= 2) return SCM(playerid, -1"You are not authorized to use this command.");
    new 
idreason[64];
    if(
sscanfparams"us[64]"idreason ) ) return SendClientMessageplayerid, -1"Usage: /ban <Part Of Name> <hours> <minutes> <reason>" );
    if( !
IsPlayerConnectedid ) || id == INVALID_PLAYER_ID ) return SendClientMessageplayerid, -1"That player is not connected!" );
    new 
str128 ], pNameMAX_PLAYER_NAME ], aNameMAX_PLAYER_NAME ],hours,minutes;
    
GetPlayerNameplayeridaNameMAX_PLAYER_NAME );
    
GetPlayerNameidpNameMAX_PLAYER_NAME );
    
formatstrsizeofstr ), "{a7c0dc}%s was banned temporarily by administrator %s for %i hours and %i minutes (Reason: %s)"pNameaNamehoursminutesreason );
    
SendClientMessageToAll( -1str );
    
BanPlayerTemp(playerid,reason,aName,hours,minutes);
    return 
1;

Also, im using TimeStampToDate


Re: error 033: array must be indexed (variable "minutes") - biker122 - 06.10.2014

pawn Код:
CMD:bantemp( playerid, params[ ] )
{
    if(pInfo[playerid][pAdminLevel] >= 2) return SCM(playerid, -1, "You are not authorized to use this command.");
    new id, reason[64], hours, minutes;
    if(sscanf( params, "uiis[64]", id,  hours, minutes, reason ) ) return SendClientMessage( playerid, -1, "Usage: /ban <Part Of Name> <hours> <minutes> <reason>" );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
    new str[ 128 ], pName[ MAX_PLAYER_NAME ], aName[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, aName, MAX_PLAYER_NAME );
    GetPlayerName( id, pName, MAX_PLAYER_NAME );
    format( str, sizeof( str ), "{a7c0dc}%s was banned temporarily by administrator %s for %i hours and %i minutes (Reason: %s)", pName, aName, hours, minutes, reason );
    SendClientMessageToAll( -1, str );
    BanPlayerTemp(playerid,reason,aName,hours,minutes);
    return 1;
}
Try to use this command.
Also change the stock like this:
pawn Код:
stock BanPlayerTemp(playerid,reason[],admin[],hours,minutes)
{
    new ppp[50];
    new exp=gettime()+(60*minutes)+(60*60*hours); //error line
    GetPlayerIp(playerid,ppp,sizeof(ppp));
    new INI:File = INI_Open(UserBanPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banexp",exp);
    INI_WriteInt(File,"BanPerm",0);
    INI_WriteString(File,"BanAdmin",admin);
    INI_WriteString(File,"Reason",reason);
    INI_WriteString(File,"IP",ppp);
    INI_Close(File);
    new banmt[300],targetn[MAX_PLAYER_NAME];
    GetPlayerName(playerid,targetn,sizeof(targetn));
    new INI:iFile = INI_Open(UserIPPath(playerid));
    INI_SetTag(iFile,"data");
    INI_WriteInt(iFile,"Banexp",exp);
    INI_WriteInt(iFile,"BanPerm",0);
    INI_WriteString(iFile,"BanPlayer",targetn);
    INI_WriteString(iFile,"BanAdmin",admin);
    INI_WriteString(iFile,"Reason",reason);
    INI_Close(iFile);
    new File:logg=fopen("BannedPlayers.txt",io_append);
    fwrite(logg, targetn);
    fwrite(logg,"\n");
    fclose(logg);
    format(banmt,sizeof(banmt),"{DC143C}Admin %s has banned you for %i hours %i minutes due to %s",admin,hours,minutes,reason);
    SendClientMessage(playerid,-1,banmt);
    SetTimerEx("KickPlayer",100,false,"i",playerid);
    return 1;
}



Re: error 033: array must be indexed (variable "minutes") - XGreen - 06.10.2014

Quote:
Originally Posted by biker122
Посмотреть сообщение
pawn Код:
CMD:bantemp( playerid, params[ ] )
{
    if(pInfo[playerid][pAdminLevel] >= 2) return SCM(playerid, -1, "You are not authorized to use this command.");
    new id, reason[64], hours, minutes;
    if(sscanf( params, "uiis[64]", id,  hours, minutes, reason ) ) return SendClientMessage( playerid, -1, "Usage: /ban <Part Of Name> <hours> <minutes> <reason>" );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
    new str[ 128 ], pName[ MAX_PLAYER_NAME ], aName[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, aName, MAX_PLAYER_NAME );
    GetPlayerName( id, pName, MAX_PLAYER_NAME );
    format( str, sizeof( str ), "{a7c0dc}%s was banned temporarily by administrator %s for %i hours and %i minutes (Reason: %s)", pName, aName, hours, minutes, reason );
    SendClientMessageToAll( -1, str );
    BanPlayerTemp(playerid,reason,aName,hours,minutes);
    return 1;
}
Try to use this command.
Also change the stock like this:
pawn Код:
stock BanPlayerTemp(playerid,reason[],admin[],hours,minutes)
{
    new ppp[50];
    new exp=gettime()+(60*minutes)+(60*60*hours); //error line
    GetPlayerIp(playerid,ppp,sizeof(ppp));
    new INI:File = INI_Open(UserBanPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banexp",exp);
    INI_WriteInt(File,"BanPerm",0);
    INI_WriteString(File,"BanAdmin",admin);
    INI_WriteString(File,"Reason",reason);
    INI_WriteString(File,"IP",ppp);
    INI_Close(File);
    new banmt[300],targetn[MAX_PLAYER_NAME];
    GetPlayerName(playerid,targetn,sizeof(targetn));
    new INI:iFile = INI_Open(UserIPPath(playerid));
    INI_SetTag(iFile,"data");
    INI_WriteInt(iFile,"Banexp",exp);
    INI_WriteInt(iFile,"BanPerm",0);
    INI_WriteString(iFile,"BanPlayer",targetn);
    INI_WriteString(iFile,"BanAdmin",admin);
    INI_WriteString(iFile,"Reason",reason);
    INI_Close(iFile);
    new File:logg=fopen("BannedPlayers.txt",io_append);
    fwrite(logg, targetn);
    fwrite(logg,"\n");
    fclose(logg);
    format(banmt,sizeof(banmt),"{DC143C}Admin %s has banned you for %i hours %i minutes due to %s",admin,hours,minutes,reason);
    SendClientMessage(playerid,-1,banmt);
    SetTimerEx("KickPlayer",100,false,"i",playerid);
    return 1;
}
Same.


Re: error 033: array must be indexed (variable "minutes") - XGreen - 06.10.2014

Ok, I Fixed it, i just changed ( playerid, parmas[ ] ) to (playerid, params[])

BTW, thanks for your concern biker122 +1


Re: error 033: array must be indexed (variable "minutes") - biker122 - 06.10.2014

It's not actually the same. Check the code fully once.

Quote:

i just changed ( playerid, params[ ] ) to (playerid, params[])

Are you even serious?


Re: error 033: array must be indexed (variable "minutes") - GGRoleplay - 06.10.2014

Quote:
Originally Posted by biker122
Посмотреть сообщение
It's not actually the same. Check the code fully once.


Are you even serious?
He put a space between the []