dcmd_ban(playerid, params[])
{
if(AccountInfo[playerid][aLevel] < 1) SendClientMessage(playerid, COLOR_RED, "Ai nevoie de admin 1 pentru a folosii aceasta comanda!");
else
{
new ore = 60000;
new ID, reason[100], name[60], name2[60], string4[256], string5[256], string6[256], string2[256];
if(sscanf(params, "uis", ID, ore, reason)) SendClientMessage(playerid, COLOR_WHITE, "Scrie: /ban [id/nume] [zile] [motiv]");
else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, COLOR_RED, "Player-ul nu este conectat");
else
{
AccountInfo[ID][pBanned] = 1;
new zi = ore*24;
SetTimer("ban1",zi,1);
GetPlayerName(playerid, name, 60);
GetPlayerName(playerid, name2, 60);
format(string4, 256, "Admin %s[%d] ti-a dat ban pentru %s zile. (Motiv: %s)", name, playerid, zi, reason);
SCM(ID, COLOR_YELLOW, string4);
format(string5, 256, "Daca crezi ca ai luat ban degeaba poti face o cerere de unban pe:");
SCM(ID, COLOR_YELLOW, string5);
format(string6, 256, "http://cnrromania.1to.us/index.php?topic=3.0");
SCM(ID, COLOR_YELLOW, string6);
format(string2, 256, "Admin %s[%d] ia dat ban lui %s pentru %s zile. (Motiv: %s)", name, playerid, name2, zi, reason);
SendClientMessageToAll(COLOR_LIGHTRED, string2);
Kick(ID);
}
}
return 1;
}
|
Originally Posted by SA-MP Wiki
As of SA-MP 0.3x, any action taken directly before Ban() (such as sending a message with SendClientMessage) will not reach the player. A timer must be used to delay the ban.
|
#define FixedBan(%0) SetTimerEx("myFixedBan",250,false,"d",%0)
forward myFixedBan(playerid);
public myFixedBan(playerid)
{
Ban(playerid);
}
// Usage:
FixedBan(playerid);
new zile = floatround(float(ore)/24.0);
|
You should read the wiki, there says clearly:
The Kick/Ban function must be called with a delay just after the SendClientMessage function, that's how SA-MP works in this case. PHP код:
https://sampforum.blast.hk/showthread.php?tid=646264 Alright, here you have something else: doing hours * 24 doesn't return days! You must do hours/24 and round the result because that might be a float: PHP код:
|
|
You should read the wiki, there says clearly:
The Kick/Ban function must be called with a delay just after the SendClientMessage function, that's how SA-MP works in this case. PHP код:
https://sampforum.blast.hk/showthread.php?tid=646264 Alright, here you have something else: doing hours * 24 doesn't return days! You must do hours/24 and round the result because that might be a float: PHP код:
|
#define FixedKick(%0) SetTimerEx("myFixedKick",250,false,"d",%0)
forward myFixedKick(playerid);
public myFixedKick(playerid)
{
Kick(playerid);
}
dcmd_ban(playerid, params[])
{
new days;
new target_id;
new reason[50];
new string[144];
if(AccountInfo[playerid][aLevel] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Ai nevoie de admin 1 pentru a folosii aceasta comanda!");
return 1;
}
if(sscanf(params, "uis[50]", target_id, days, reason))
{
SendClientMessage(playerid, COLOR_WHITE, "Scrie: /ban [id] [zile] [motiv]");
return 1;
}
if(!IsPlayerConnected(target_id))
{
SendClientMessage(playerid, COLOR_RED, "Player-ul nu este conectat");
return 1;
}
format(string, sizeof(string), "Admin %s[%d] ti-a dat ban pentru %s zile (%s).", GetName(playerid), playerid, days, reason);
SendClientMessage(target_id, COLOR_YELLOW, string);
SendClientMessage(target_id, COLOR_YELLOW, "Daca crezi ca ai luat ban degeaba poti face o cerere de unban pe:");
SendClientMessage(target_id, COLOR_YELLOW, "http://cnrromania.1to.us/index.php?topic=3.0");
format(string, sizeof(string), "Admin %s[%d] ia dat ban lui %s pentru %s zile (motiv: %s).", GetName(playerid), playerid, GetName(target_id), days, reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
AccountInfo[target_id][pBanned] = 1; // This sould be saved somehow.
FixedKick(target_id);
return 1;
}
GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
public OnPlayerConnect(playerid)
{
InitFly(playerid);
new string[256], playername[MAX_PLAYER_NAME], file[255];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s s-a conectat la Romania Cops And Robbers!", playername);
Announce(string);
IsPlayerLogged[playerid] = 0;
RecentlyRobbed[playerid] = 0;
SelectBM[playerid] = 0;
AMMUBOX[playerid] = 0;
CSKINZ[playerid] = 0;
CSKINU[playerid] = 0;
ReportTime[playerid] = 0;
CSKIN[playerid] = 0;
CHALLBOX[playerid] = 0;
IcmdCar[playerid][CarcmdI] = -1;
IsSpawned[playerid] =0;
GPSTimer[playerid] = 0;
HaveGPS[playerid] = false;
Muted[playerid] = 0;
//Text Draws
TextDrawShowForPlayer(playerid, BOX);
TextDrawShowForPlayer(playerid, Welcome);
TextDrawShowForPlayer(playerid, text1);
TextDrawShowForPlayer(playerid, text2);
TextDrawShowForPlayer(playerid, text3);
HaveAmenda[playerid] = false;
HaveLive[playerid] = false;
HaveReport[playerid] = false;
EventActiv[playerid] = false;
InEvent[playerid] = false;
RequestLive[playerid] = false;
if(AccountInfo[playerid][pBanned] == 1)
{
SCM(playerid, blue, "---------------------------BANNED-------------------------------");
SCM(playerid, COLOR_ERROR, "Ai ban pe acest server");
SCM(playerid, COLOR_ERROR, "Daca crezi ca ai luat ban degeaba poti face o cerere de unban pe:");
SCM(playerid, COLOR_ERROR, "http://cnrromania.1to.us/index.php?topic=3.0");
SCM(playerid, blue, "---------------------------BANNED-------------------------------");
FixedKick(playerid);
}
new Registre[250];
format(file, sizeof(file), "%s.cfg", playername);
if(fexist(file))
{
GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
format(Registre,sizeof(Registre),"{FFFF00}Bun venit, {00FFFF}%s!\n\n{FFFF00}Intregistreaza-te inainte sa continui!",playername);
ShowPlayerDialog(playerid,LoginName,DIALOG_STYLE_INPUT,"Login",Registre,"Logare","Inchide");
}
else
if(!fexist(file))
{
GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
format(Registre,sizeof(Registre),"{FFFF00}Bun venit, {00FFFF}%s!\n\n{FFFF00}Intregistreaza-te inainte sa continui!",playername);
ShowPlayerDialog(playerid,RegisterName,DIALOG_STYLE_INPUT,"Register",Registre,"Inregistrare","Inchide");
}
return true;
}
if(AccountInfo[playerid][pBanned] == 1)
{
SCM(playerid, blue, "---------------------------BANNED-------------------------------");
SCM(playerid, COLOR_ERROR, "Ai ban pe acest server");
SCM(playerid, COLOR_ERROR, "Daca crezi ca ai luat ban degeaba poti face o cerere de unban pe:");
SCM(playerid, COLOR_ERROR, "http://cnrromania.1to.us/index.php?topic=3.0");
SCM(playerid, blue, "---------------------------BANNED-------------------------------");
FixedKick(playerid);
}