18.10.2012, 10:12
Is it possible to ban a player that isn't connected?
If so can you tell me how using strcmp
++Rep if you do
If so can you tell me how using strcmp
++Rep if you do
if(strcmp(cmd,"/oban",true)==0)
{
new string[124],string1[124], giveplayerid;
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "/oban [playername]");
}
format(string,sizeof(string),"Users/%s.ini",params);
if(fexist(string))
{
new INI:file = INI_Open(string);
INI_WriteInt(file,"Banned",1);
INI_Close(file);
format(string1,sizeof(string1),"AdmCmd: %s was banned when he isn't in game by %s.",GetPlayerName(giveplayerid), GetPlayerName(playerid));
SendClientMessage(playerid,-1,string1);
}
else SendClientMessage(playerid,-1,"Account not found");
return 1;
}
PHP код:
|
dcmd_oban(playerid, params[])
{
new accountname[MAX_PLAYER_NAME], reason[256], string[256], string2[256];
if(sscanf( params, "sds", accountname, reason))
{
if(PlayerInfo[playerid][pAdminLevel] >= 2)
{
SendClientMessage( playerid, COLOR_WHITE, "{00E6E6}* Correct Usage: {FFFFFF}/oban [account name - case sensative] [reason]");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] You are not authorized to use this command.");
}
}
else
{
if(PlayerInfo[playerid][pAdminLevel] >= 2)
{
format(string, sizeof(string), "accounts/%s.ini", accountname);
if(dini_Exists(string))
{
new tmp[MAX_PLAYER_NAME];
format(tmp, sizeof(tmp), "%s", PlayerName(playerid));
if(strcmp(accountname, tmp, true) != -1)
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] You cannot offline-ban yourself.");
}
else if(dini_Int(string, "AdminLevel") > PlayerInfo[playerid][pAdminLevel])
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] You cannot offline-ban higher-level administrators.");
}
else if(dini_Int(string, "Banned") == 1)
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] That player account is already banned.");
}
else if(strlen(reason) > 128)
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] Ban reason should not exceed 128 characters in length.");
}
else
{
dini_IntSet(string, "Banned", 1);
dini_Set(string, "BanReason", reason);
dini_Set(string, "BannedBy", PlayerName(playerid));
format(string, sizeof(string2), "AdmCmd: %s has been offline-banned by %s, reason: %s", accountname, PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string2);
Log("logs/bans.log", string2);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "[ERROR] That player account does not exist.");
}
}
}
return 1;
}
CMD:banofflineplayer(playerid,params[])
{
new string[90],tname[200];
if(sscanf(params, "s[200]", tname)) return SendClientMessage(playerid,Yellow,"Correct Usage: /banofflineplayer [Player Name]");
new filestring[128];
format(filestring, sizeof(filestring), "/Users/%s.ini", tname);
if(!fexist(filestring)) return SendClientMessage(playerid,Lime, "That name doesn't exist");
else
{
new INI:File = INI_Open(filestring);
INI_SetTag(File, "data");
INI_WriteInt(File, "Banned",1);
INI_Close(File);
format(string, sizeof(string),"Success! You have banned %s", tname);
SendClientMessage(playerid, Lime,string);
}
return 1;
}