SA-MP Forums Archive
What is this error. - 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: What is this error. (/showthread.php?tid=657084)



What is this error. - Man43 - 31.07.2018

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;




Re: What is this error. - denNorske - 31.07.2018

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.


Re: What is this error. - AndreProgrammer - 31.07.2018

You want see if player are banned ?


Re: What is this error. - Man43 - 31.07.2018

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


Re: What is this error. - AndreProgrammer - 31.07.2018

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


Re: What is this error. - Man43 - 31.07.2018

And how to do that?


Re: What is this error. - AndreProgrammer - 31.07.2018

What is the saved system of your server ?


Re: What is this error. - Man43 - 31.07.2018

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?


Re: What is this error. - AndreProgrammer - 31.07.2018

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


Re: What is this error. - Man43 - 31.07.2018

Uhh I used DOF2