CMD:unban(playerid, params[]) { if(PlayerInfo[playerid][pAdminLevel] >= 2) { new path[124]; if(isnull(params)) return SendClientMessage(playerid, -1, "Syntax - /unban <Player Name>"); format(path,sizeof(path),"Accounts/%s.ini",params); if(fexist(path)) { new INI:file = INI_Open(path); INI_SetTag(file,"data"); INI_WriteInt(file,"Banned",0); INI_Close(file); new unbanstring[124]; format(unbanstring, sizeof(unbanstring), "You have unbanned the account: (%s)", params); SendClientMessage(playerid, -1, unbanstring); }else SendClientMessage(playerid,-1,"Account not found, make sure you type the exact name."); }else SendClientMessage(playerid, -1, "Error: You must be admin level 2 or higher."); return 1; }
CMD:unban(playerid, params[]) { if(PlayerInfo[playerid][pAdminLevel] >= 2) { new path[124]; if(isnull(params)) return SendClientMessage(playerid, -1, "Syntax - /unban <Player Name>"); format(path,sizeof(path),"Accounts/%s.ini",params); if(fexist(path)) { if(IS THE PLAYER ISN'T ALREADY BANNED) { new INI:file = INI_Open(path); INI_SetTag(file,"data"); INI_WriteInt(file,"Banned",0); INI_Close(file); new unbanstring[124]; format(unbanstring, sizeof(unbanstring), "You have unbanned the account: (%s)", params); SendClientMessage(playerid, -1, unbanstring); }else SendClientMessage(playerid,-1,"This account is not banned."); }else SendClientMessage(playerid,-1,"Account not found, make sure you type the exact name."); }else SendClientMessage(playerid, -1, "Error: You must be admin level 2 or higher."); return 1; }
new bool:test //Creates a boolean called "test" and it is automatically on false. new bool:Banned=true //A boolean called "Banned and it has been set to true.
new bool:Banned[MAX_PLAYERS]; //global variable CMD:unban(playerid, params[]) { if(PlayerInfo[playerid][pAdminLevel] >= 2) { new path[124]; if(isnull(params)) return SendClientMessage(playerid, -1, "Syntax - /unban <Player Name>"); format(path,sizeof(path),"Accounts/%s.ini",params); if(fexist(path)) { if(Banned[Here the variable to define target id] == false) { new INI:file = INI_Open(path); INI_SetTag(file,"data"); INI_WriteInt(file,"Banned",0); INI_Close(file); new unbanstring[124]; format(unbanstring, sizeof(unbanstring), "You have unbanned the account: (%s)", params); SendClientMessage(playerid, -1, unbanstring); }else SendClientMessage(playerid,-1,"This account is not banned."); }else SendClientMessage(playerid,-1,"Account not found, make sure you type the exact name."); }else SendClientMessage(playerid, -1, "Error: You must be admin level 2 or higher."); return 1; }
Aha! It took me a while to understand your problem, mate.
I have been struggling with /unban for a long time. My suggestion to you is to use a boolean. A boolean is a function which checks if the variable is true or false, nothing else. Код:
new bool:test //Creates a boolean called "test" and it is automatically on false. new bool:Banned=true //A boolean called "Banned and it has been set to true. Код:
new bool:Banned[MAX_PLAYERS]; //global variable CMD:unban(playerid, params[]) { if(PlayerInfo[playerid][pAdminLevel] >= 2) { new path[124]; if(isnull(params)) return SendClientMessage(playerid, -1, "Syntax - /unban <Player Name>"); format(path,sizeof(path),"Accounts/%s.ini",params); if(fexist(path)) { if(Banned[Here the variable to define target id] == false) { new INI:file = INI_Open(path); INI_SetTag(file,"data"); INI_WriteInt(file,"Banned",0); INI_Close(file); new unbanstring[124]; format(unbanstring, sizeof(unbanstring), "You have unbanned the account: (%s)", params); SendClientMessage(playerid, -1, unbanstring); }else SendClientMessage(playerid,-1,"This account is not banned."); }else SendClientMessage(playerid,-1,"Account not found, make sure you type the exact name."); }else SendClientMessage(playerid, -1, "Error: You must be admin level 2 or higher."); return 1; } ![]() |
Hmm, I'm a bit confused now. Do you want to unban someone or check if someone is banned with the command "unban"?
|
INI:filename[tag](name[], value[])
{
INI_Int("LEVEL", gLevel);
}
Checking the account file if the player is banned, is rather unnecessary due to the name might change of the player. So i am assuming you did save the bans in separate files named with their IP somewhere.
https://sampforum.blast.hk/showthread.php?tid=175565 pawn Код:
Now, in order to read the correct file you need to have saved the IP of the player into the account-file (i presume you did). Then you can load that IP, and set that as "filename" in the case above. If it finds any matching files with the same filename, you can make it delete the file. Simply enough you can use "fremove(pathhere)". Please Ignore the [tag] if you didn't add tags in your ini-file (simply remove it from the line) Makes more sense now ? ![]() |
Actually, I have the pBanned variable inside of a big file for each players stats, and if the pBanned variable is set to 1 and saved this is checked when the player joins.
|