25.01.2013, 09:13
Hello!
I am trying to make a "ban" command, and it is supposed to show information about the ban when you join the server again.
I wrote all the information to the INI-file when banning, and it loads OnPlayerConnect. It should..
Here is OnPlayerConnect:
And here is the command itself (Note: I have tested the ini writing and loading, it looks like it works fine)
The thing is, When i join with my banned account, it should appear a dialog box, with the text i coded above. There is no errors in my script, and the box only shows up sometimes.
When i join the server, it says: connected, joining the game... Connecting to 127.0.0.1:5000... and keeps going.
My thought is: Is the server too fast closing my connection, so my dialog wont show in time ?
Is there any wrong things in my script? It is quite annoying, because its a useful thing to have for banned players. (will add IP when everything works fine so far)
Thanks in advance, looking forward to learn what's wrong :P
I am trying to make a "ban" command, and it is supposed to show information about the ban when you join the server again.
I wrote all the information to the INI-file when banning, and it loads OnPlayerConnect. It should..
Here is OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
loggedin=0;
if(fexist(INI_PATH(playerid)))
{
INI_ParseFile(INI_PATH(playerid),"loadacc_%s", .bExtra = true, .extra = playerid);
if (AccInfo[playerid][banned] ==1)
{
new string[600];
new string2[180];
format(string, sizeof(string),""cred"Hello %s! \n\n "cwhite" Your account is banned, and you will have\n to make an unban application at %s if you want to \nget unbanned again \n\n "corange"BAN INFORMATIOM: \n"cwhite" - %s \n - Reason of ban: %s\n - Admin who banned you: %s\n - Your Name: %s\n\n", PlayerName(playerid), forum, AccInfo[playerid][bantime], AccInfo[playerid][banreason], AccInfo[playerid][adminban], PlayerName(playerid));
format(string2,sizeof(string2), "%s got kicked from %s, because the account was banned.",PlayerName(playerid), servername);
SendClientMessageToAll(grey, string2);
ShowPlayerDialog(playerid, BanDialog, DIALOG_STYLE_MSGBOX, "Banned!", string,"ok","");
//SetTimer("kick", 4000, 0);
Kick(playerid);
return 1;
}
else
{
ShowPlayerDialog(playerid,login,DIALOG_STYLE_PASSWORD,"Login",""cgreen"Welcome back! This account is registered. "cblue"\n\n Please insert your password to login:","Login","Quit");
}
}
else
{
ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register",""cgreen"Welcome! This account is NOT registered, "cblue"\n\n Please insert a password to register your account","Register","Quit");
}
return 1;
}
And here is the command itself (Note: I have tested the ini writing and loading, it looks like it works fine)
pawn Код:
CMD:ban(playerid, params[])
{
new suspect, string[200];
if(sscanf(params, "us[200]", suspect, AccInfo[playerid][banreason]))
return SendClientMessage(playerid, orange, " - USAGE: "cblue"/BAN [playerid/name] [reason of ban] - "corange"Will ban the selected player from the server");
if(suspect == INVALID_PLAYER_ID)
return SendClientMessage(playerid, orange, " - - - - - Player was not found online / Wrong name/id - - - - - -");
if(suspect == playerid)
{
ShowPlayerDialog(playerid, KICK_WARNING, DIALOG_STYLE_MSGBOX, "Confirm:", "Are you sure you want to ban yourself?", "Yep", "No");
AccInfo[suspect][adminban]=PlayerName(playerid);
return 1;
}
AccInfo[suspect][adminban]=PlayerName(playerid);
if(AccInfo[suspect][aLevel] == 5)
{
SendClientMessage(playerid, orange, "You can't kick the Owner! - He is now warned about this.");
new string1[1000];
format(string1, sizeof(string1), " - [Warning]: Admin %s just attempted to kick you with the command "cblue"/kick -", PlayerName(playerid));
SendClientMessage(suspect, orange, string1);
return 1;
}
else
{
format(string, sizeof(string), " - - Administrator %s has banned %s from %s . "cwhite"[REASON]: %s", PlayerName(playerid), PlayerName(suspect), servername, AccInfo[playerid][banreason]);
SendClientMessageToAll(red, string);
AccInfo[suspect][banned] = 1;
new year,month,date, hour,minute,second, string5[150];
getdate(year, month, date);
gettime(hour,minute,second);
format(string5,sizeof(string5), "Date: %d/%02d/%02d -||- Time: %02d:%02d:%02d",date, month, year, hour, minute, second);
AccInfo[suspect][bantime] = string5;
new INI:acc = INI_Open(INI_PATH(suspect));
INI_SetTag(acc, "Account");
INI_WriteInt(acc, "Banned", AccInfo[suspect][banned]);
INI_WriteString(acc, "BanTime", AccInfo[suspect][bantime]);
INI_WriteString(acc, "AdminName", AccInfo[suspect][adminban]);
INI_WriteString(acc, "BanReason", AccInfo[suspect][banreason]);
INI_Close(acc);
Kick(suspect);
}
return 1;
}
The thing is, When i join with my banned account, it should appear a dialog box, with the text i coded above. There is no errors in my script, and the box only shows up sometimes.
When i join the server, it says: connected, joining the game... Connecting to 127.0.0.1:5000... and keeps going.
My thought is: Is the server too fast closing my connection, so my dialog wont show in time ?
Is there any wrong things in my script? It is quite annoying, because its a useful thing to have for banned players. (will add IP when everything works fine so far)
Thanks in advance, looking forward to learn what's wrong :P