array must be indexed prob
#1

hi i created a offline ban cmd , /offban {params} , i want to check if the player is online server show this mssg : this player is online use /ban , when i use
if(IsPlayerConnected(params)
i got this error aray must be indexed can anyone help me with this please ?
Reply
#2

PHP Code:
new id;
if(
sscanf(params,"d",id))return SendClientMessage(playerid, -1"Usage....");
if(!
IsPlayerConnected(id))return SendClientMessage(playerid, -1"Player not connected"); 
Use this instead of params, or index params example params[1].
Reply
#3

Quote:
Originally Posted by PoniStar
View Post
hi i created a offline ban cmd , /offban {params} , i want to check if the player is online server show this mssg : this player is online use /ban , when i use
if(IsPlayerConnected(params)
i got this error aray must be indexed can anyone help me with this please ?
Show the code
Reply
#4

guys i think that error was for other line , i got argument type mismatch for ifplyrconnected =>


dcmd_offban(playerid,params[])
{
new string[128];
if(!strlen(params))
{
format(string, sizeof(string), "Usage : /offban [PlayerName]");
SCM(playerid,COLOR_ERROR,string);
return 1;
}
if(!udb_Exists(params))
{
format(string, sizeof(string), "Account Name Not Exist!");
SCM(playerid,COLOR_ERROR,string);
return 1;
}

if(IsPlayerConnected(params)) return SendClientMessage(playerid, GREY, "This Player Is Online Use /ban");

-> and ...

}


this is error :
F:\samp\gamemode\BaseMode(30783) : error 035: argument type mismatch (argument 1)
Reply
#5

GetPlayerName(params,pname,sizeof(pname));
dini_Set(SupaStat[PlayerInfo[params][HIDDEN]][HIDDEN], str3, "None");

and i have array must be indexed error here
Reply
#6

pawn Code:
dcmd_offban(playerid,params[])
{
    new string[128];
    if(!strlen(params))
    {
        format(string, sizeof(string), "Usage : /offban [PlayerName]");
        return SCM(playerid,COLOR_ERROR,string);
    }
    if(!udb_Exists(params))
    {
        format(string, sizeof(string), "Account Name Not Exist!");
        return SCM(playerid,COLOR_ERROR,string);
    }
    if(IsPlayerConnected(params)) return SendClientMessage(playerid, GREY, "This Player Is Online Use /ban");
}
IsPlayerConnected i used on id not names so if you wanna get name by their id use this way:-

pawn Code:
stock IsThisNameOnline(const name[])
{
    if(!name[0]) return INVALID_PLAYER_ID;

    static name2[MAX_PLAYER_NAME];
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
    if(IsPlayerConnected(i))
    {
        GetPlayerName(i, name2, sizeof(name2));
        if(!strcmp(name, name2))
        {
            return i;
        }
    }
    return INVALID_PLAYER_ID;
}

dcmd_offban(playerid,params[])
{
    new string[128];
    if(!strlen(params))
    {
        format(string, sizeof(string), "Usage : /offban [PlayerName]");
        return SCM(playerid,COLOR_ERROR,string);
    }
    if(!udb_Exists(params))
    {
        format(string, sizeof(string), "Account Name Not Exist!");
        return SCM(playerid,COLOR_ERROR,string);
    }
    if(IsPlayerConnected(IsThisNameOnline(params))) return SendClientMessage(playerid, GREY, "This Player Is Online Use /ban");
}
Reply
#7

Quote:
Originally Posted by PoniStar
View Post
GetPlayerName(params,pname,sizeof(pname));
dini_Set(SupaStat[PlayerInfo[params][HIDDEN]][HIDDEN], str3, "None");

and i have array must be indexed error here
what about this one ?
Reply
#8

same error same mistake, you should use GetPlayerName if you know player id, use the function i gave you find id by IsThisNameOnline which will return the ID, then use it to get player name for example

pawn Code:
new targetid = IsThisNameOnline(params);

if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "This Player is not online");
new pname[MAX_PLAYER_NAME];
GetPlayerName(targetid, pname, sizeof(pname));
Reply
#9

look i want too if the name was online server show a error and say use /ban , i put this :

new targetid = IsThisNameOnline(params);
if(IsPlayerConnected(targetid)) return SendClientMessage(playerid, GREY, "Error");

and not worked the command worked and there was no error mssgs
Reply
#10

Use sscanf 2.8.2, much easier and popular.
If you're going to use it, I can help you with it.
Reply
#11

thnx guys fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)