Little help here. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Little help here. (
/showthread.php?tid=477257)
Little help here. -
Crystallize - 23.11.2013
Hello,
Can anyone help me to script a ban/unban offline command?
Re: Little help here. -
Stanford - 23.11.2013
Here you go, I've copied this from my own script, feel free to edit it..
-
pawn Код:
if(strcmp(cmd, "/banaccount", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new string2[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /banaccount [full name(case sensative)]");
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 4)
{
format(string, sizeof(string), "users/%s.ini",tmp);
if(dini_Exists(string))
{
if(dini_Int(string, "Band") == 0)
{
if(dini_Int(string, "AdminLvl") > PlayerInfo[playerid][pAdmin])
{
SendClientMessage(playerid, COLOR_GREY, "You can't ban higher level Admins !");
return 1;
}
dini_IntSet(string, "Band", 3);
string2 = dini_Get(string, "IP");
format(string, sizeof(string),"banip %s", string2);
SendRconCommand(string);
SendRconCommand("reloadbans");
format(string, 256, "AdmWarning: %s has banned account '%s' and IP '%s'.",PlayerName(playerid),tmp,string2);
ABroadCast(COLOR_LIGHTRED, string, 1);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "That player is already account-banned. You have banned their IP.");
string2 = dini_Get(string, "IP");
format(string, sizeof(string), "banip %s", string2);
SendRconCommand(string);
SendRconCommand("reloadbans");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "That player does not exist!");
}
}
}
return 1;
}
Re: Little help here. -
Joy_Freed - 23.11.2013
And to unban
Код:
if(strcmp(cmd, "/unban", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SyntaxMessage(playerid, "/unban [full name(case sensitive)]");
return 1;
}
if (PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pBanAppealer])
{
new file[128];
format(file,sizeof(file),"Users/%s.ini",tmp);
if(!fexist(file))
{
SendClientMessage(playerid, GREY, "Invalid player account.");
return 1;
}
else
{
new tmpip[20];
if(INI_Open(file))
{
INI_WriteInt("Band", 0);
INI_WriteInt("PermBan", 0);
INI_WriteString("BanReason", "None");
INI_ReadString(tmpip, "IP", 20);
format(string, sizeof(string), "unbanip %s", tmpip);
SendRconCommand(string);
SendRconCommand("reloadbans");
SendClientMessage(playerid, LIGHTRED, "* Member unbanned.");
format(string, sizeof(string), "{FF6347}%s has unbanned account '%s', and IP '%s'",PlayerName(playerid),tmp,tmpip);
ABroadCast(RED, string, 1);
INI_Save();
INI_Close();
}
return 1;
}
}
else
{
SendClientMessage(playerid, GREY, " You are not authorized to use this command.");
}
}
return 1;
}
Re: Little help here. -
LeeXian99 - 23.11.2013
Hope
this helps.
Re: Little help here. -
Crystallize - 24.11.2013
Thanks guys, I appreciate this.