What is this error.
#1

I just getting an error for trying to check if player got banned's or not.. when connected but always I got this error

PHP код:
    if(!isnull(params)) BannedFromServer[params] = true
Error is: error 033: array must be indexed (variable "params")

FULL COMMAND:

PHP код:
CMD:ban(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 2)
        return 
SendClientMessage(playeridCOLOR_GREY"{FF0000}Error: {FFFFFF}Wrong command!! {FF0000}Check availables commands from here `{FFFFFF}/cmds{FF0000}`.");
    new
        
pName[MAX_PLAYER_NAME],
        
tName[MAX_PLAYER_NAME],
        
targetid,
        
string[128],
        
reason[80]
    ;
    if(!
aDuty[playerid])
        return 
SendClientMessage(playeridCOLOR_GREY"{FF0000}Error: {FFFFFF}You must be ADMIN ON DUTY to kick someone.");
    if(
sscanf(params"us[80]"targetidreason))
        return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: /ban [playerid] [reason]");
    if(!
IsPlayerConnected(targetid))
        return 
SendClientMessage(playeridCOLOR_GREY"{FF0000}Error: {FFFFFF}INVAILD PLAYER ID / NAME.");
    if(
PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin])
        return 
SendClientMessage(playeridCOLOR_GREY"{FF0000}Error: {FFFFFF}Player has a higher admin level than you. [CAN'T BANNED]!");
    if(!
isnull(params)) BannedFromServer[params] = true;
    
GetPlayerName(playerid,pName,sizeof(pName));
    
GetPlayerName(targetid,tName,sizeof(tName));
    
format(stringsizeof(string), "{FB00FF}[BANNED]: PLAYER %s(%d) has been BANNED by Admin %s(%d), REASON: %s."tName,targetidpName,playeridreason);
    
SendClientMessageToAll(-1string);
    
GameTextForPlayer(targetid"~P~BANNED"100003);
    
SetTimerEx("Banned",5200,false,"i",targetid);
    return 
1;

Reply
#2

params is a string (You can determine that by the two square brackets after the parameter, "params[]")
So how you use it, you expect it to work as an integer (index in the array). To do that, you need to convert the string to an integer.

Try using strval(params) instead of params only at the last variable. This makes it be an integer.

Remember that strval() returns 0 for text as well.
https://sampwiki.blast.hk/wiki/Strval

PHP код:
  if(!isnull(params)) BannedFromServer[strval(params)] = true
And if you want to save his ban, you need to save it to a file/database and read from it in order to check if he is banned.

Your current method won't hold up.
Reply
#3

You want see if player are banned ?
Reply
#4

Guys! I just want to check Example: I banned someone from the server when the player trying to re-joined the server And he was banned they must send him a message Example: You cannot joined this server while you are banned. How
Reply
#5

You need save the player banned. And if the file exists you kick player
Reply
#6

And how to do that?
Reply
#7

What is the saved system of your server ?
Reply
#8

Quote:
Originally Posted by denNorske
Посмотреть сообщение
params is a string (You can determine that by the two square brackets after the parameter, "params[]")
So how you use it, you expect it to work as an integer (index in the array). To do that, you need to convert the string to an integer.

Try using strval(params) instead of params only at the last variable. This makes it be an integer.

Remember that strval() returns 0 for text as well.
https://sampwiki.blast.hk/wiki/Strval

PHP код:
  if(!isnull(params)) BannedFromServer[strval(params)] = true
And if you want to save his ban, you need to save it to a file/database and read from it in order to check if he is banned.

Your current method won't hold up.
I'm trying to that that and I've adding this code to OnPlayerConnect but it always showen to me when joined the server and I banned "You are banned from this server" Why?

PHP код:
public OnPlayerConnect(playerid)
{
    if(
BannedFromServer[playerid])
    {
        
SendClientMessage(playerid, -1" You are banned ! ");
        return 
Kick(playerid);
    } 
Quote:
Originally Posted by AndreProgrammer
Посмотреть сообщение
What is the saved system of your server ?
Exause me?
Reply
#9

You don't save everything ? You use DOF2, MySQL, dini how ?
Reply
#10

Uhh I used DOF2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)