YCMD:offlineban(playerid, params[], help)
{
new
TargetID;
if( !sscanf(params, "u", TargetID))
{
new string[32];
format(string,sizeof(string),PATH,TargetID);
new INI:File = INI_Open(PATH);
if(!fexist(string)) return SendClientMessage(playerid, -1, "Invalid player name.");
INI_WriteInt(File,"Banned",true);
//BanEx( TargetID, "offlineban" );
SendClientMessage(playerid,-1, "You have now banned the player..");
INI_Close(File);
}
else
return SendClientMessage(playerid, -1, "USAGE: /offlineban [playername]");
return 1;
}
new TargetID;
if( !sscanf(params, "u", TargetID))
new TargetID[MAX_PLAYER_NAME];
if( !sscanf(params, "s[24]", TargetID))
You need to use a string specifier instead of the u specifier
pawn Код:
pawn Код:
|
YCMD:offlineban(playerid, params[])
{
new playerb[32], string[128], file[32];
if(sscanf(params, "s[32]s[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /offlineban [playername] [reason]");
format(file, sizeof(file), "users/%s.ini", playerb);
if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
format(string, sizeof(string), "AdmCmd: %s has been offline-banned by %s, reason: %s", playerb, RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "AdmCmd: %s has been offline-banned by %s (%s), reason: %s", playerb, GetPlayerName(playerid) , PIP(playerid), params);
// Banning
dini_IntSet(file, "pBanned", 1);
// BanList
new File:ban = fopen("ban.cfg", io_append);
format(string, sizeof(string), "%s\r\n", dini_Get(file, "IP"));
fwrite(ban, string);
fclose(ban);
return 1;
}
//and somewhere on the bottom of the script
stock PIP(playerid)
{
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
return ip;
}
YCMD:offlineban(playerid, params[], help)
{
new
name[24]; //Name instead (string)
if( !sscanf(params, "s[24]", name)) //Cannot be 'u' because the player is not online.
{
new string[32];
format(string,sizeof(string),PATH,name);
// Changed from TargetID -> Name. You may need to change the path
//because you were using an integer before (TargetID wasn't a string).
new INI:File = INI_Open(string); //Shouldn't be path, should be string.
if(!fexist(string)) return SendClientMessage(playerid, -1, "Invalid player name."); //All good here
INI_WriteInt(File,"Banned",1); //Just put a 1, makes it easier.
//BanEx( TargetID, "offlineban" ); <--- No need for that :).
SendClientMessage(playerid,-1, "You have now banned the player.."); //Sweet.
INI_Close(File); //Closed
}
else
return SendClientMessage(playerid, -1, "USAGE: /offlineban [playername]"); //Yep
return 1; //Sweet
}
pawn Код:
|