array must be indexed prob -
PoniStar - 31.10.2018
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 ?
Re: array must be indexed prob -
v1k1nG - 31.10.2018
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].
Re: array must be indexed prob -
TheToretto - 31.10.2018
Quote:
Originally Posted by PoniStar
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
Re: array must be indexed prob -
PoniStar - 31.10.2018
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)
Re: array must be indexed prob -
PoniStar - 31.10.2018
GetPlayerName(params,pname,sizeof(pname));
dini_Set(SupaStat[PlayerInfo[params][HIDDEN]][HIDDEN], str3, "None");
and i have array must be indexed error here
Re: array must be indexed prob -
ReD_HunTeR - 31.10.2018
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");
}
Re: array must be indexed prob -
PoniStar - 31.10.2018
Quote:
Originally Posted by PoniStar
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 ?
Re: array must be indexed prob -
ReD_HunTeR - 31.10.2018
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));
Re: array must be indexed prob -
PoniStar - 31.10.2018
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
Re: array must be indexed prob -
TheToretto - 31.10.2018
Use
sscanf 2.8.2, much easier and popular.
If you're going to use it, I can help you with it.
Re: array must be indexed prob -
PoniStar - 31.10.2018
thnx guys fixed