OTHER PROBLEM!
#1

I'm have a problem:
I'm maked a /ban command and Banned player not receive message before kick.
Код:
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;
}
Why?
Thanks!
Reply
#2

You should read the wiki, there says clearly:
Quote:
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.
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 код:
#define FixedBan(%0)    SetTimerEx("myFixedBan",250,false,"d",%0)
forward myFixedBan(playerid);
public 
myFixedBan(playerid)
{
    
Ban(playerid);
}
// Usage:
FixedBan(playerid); 
On the other hand, the code from your command is really bad in terms of optimization. You should go through all this:
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 код:
new zile floatround(float(ore)/24.0); 
Reply
#3

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
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 код:
#define FixedBan(%0)    SetTimerEx("myFixedBan",250,false,"d",%0)
forward myFixedBan(playerid);
public 
myFixedBan(playerid)
{
    
Ban(playerid);
}
// Usage:
FixedBan(playerid); 
On the other hand, the code from your command is really bad in terms of optimization. You should go through all this:
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 код:
new zile floatround(float(ore)/24.0); 
And.. how to make save with dini?
Reply
#4

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
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 код:
#define FixedBan(%0)    SetTimerEx("myFixedBan",250,false,"d",%0)
forward myFixedBan(playerid);
public 
myFixedBan(playerid)
{
    
Ban(playerid);
}
// Usage:
FixedBan(playerid); 
On the other hand, the code from your command is really bad in terms of optimization. You should go through all this:
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 код:
new zile floatround(float(ore)/24.0); 
THANKS,i'm modified Ban(playerid); with Kick(playerid); and works!
Reply
#5

Your code should look something like this:
PHP код:
#define FixedKick(%0)        SetTimerEx("myFixedKick",250,false,"d",%0)
forward myFixedKick(playerid);
public 
myFixedKick(playerid)
{
    
Kick(playerid);
}
dcmd_ban(playeridparams[])
{
    new 
days;
    new 
target_id;
    new 
reason[50];
    new 
string[144];
    if(
AccountInfo[playerid][aLevel] < 1)
    {
        
SendClientMessage(playeridCOLOR_RED"Ai nevoie de admin 1 pentru a folosii aceasta comanda!");
        return 
1;
    }
    if(
sscanf(params"uis[50]"target_iddaysreason))
    {
        
SendClientMessage(playeridCOLOR_WHITE"Scrie: /ban [id] [zile] [motiv]");
        return 
1;
    }
    if(!
IsPlayerConnected(target_id))
    {
        
SendClientMessage(playeridCOLOR_RED"Player-ul nu este conectat");
        return 
1;
    }
    
format(stringsizeof(string), "Admin %s[%d] ti-a dat ban pentru %s zile (%s)."GetName(playerid), playeriddaysreason);
    
SendClientMessage(target_idCOLOR_YELLOWstring);
    
SendClientMessage(target_idCOLOR_YELLOW"Daca crezi ca ai luat ban degeaba poti face o cerere de unban pe:");
    
SendClientMessage(target_idCOLOR_YELLOW"http://cnrromania.1to.us/index.php?topic=3.0");
    
format(stringsizeof(string), "Admin %s[%d] ia dat ban lui %s pentru %s zile (motiv: %s)."GetName(playerid), playeridGetName(target_id), daysreason);
    
SendClientMessageToAll(COLOR_LIGHTREDstring);
    
AccountInfo[target_id][pBanned] = 1// This sould be saved somehow.
    
FixedKick(target_id);
    return 
1;
}
GetName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;

I cannot explain right now why I put it like that, research by yourself. You should make an unban script also, there isn't any. Oh, and check if a player is banned when he connects.

Notice how messages without specifiers like %s, %d, etc. don't use format but SendClientMessage directly.
Reply
#6

Код:
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;
}
In onplayerconnect with:
Код:
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);
 	}
Is correct to kick player when connect?
Reply
#7

NOBODY can help me?
Reply
#8

Stop making more topics. Show some patience and do research by yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)