unban - 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: unban (
/showthread.php?tid=597903)
unban -
saffierr - 06.01.2016
Hello guys, the cmd always returns a message "Player is not found in the database." even when the player does exist.
PHP код:
UserPath(playerid)
{
new string[75], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "/Users/%s.txt", pName);
return string;
}
PHP код:
CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
if(PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
new string[75], user[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /unban [playername]");
format(string, sizeof string, "/Users/%s.txt", user);
if(fexist(user))
{
new INI:File = INI_Open(user);
printf("Userfile opened");
INI_SetTag(File, "PlayerData");
INI_WriteInt(File, "Banned", 0);
printf("User unbanned");
INI_Close(File);
printf("File closed");
format(string, sizeof string, "You have succesfully unbanned the player.");
SendClientMessage(playerid, COLOR_YELLOW, string);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: The user is not found in the database!");
}
return 1;
}
Re: unban -
J4Rr3x - 06.01.2016
Replace
PHP код:
if(fexist(user))
With:
PHP код:
if(fexist(string))
Re: unban -
saffierr - 06.01.2016
Thanks,
How do I add that, when the variable Banned == 0, it returns a message "player is not banned".