Kick delay and message not working.
#1

Hello everyone, I know this is a pretty minor error. I can't for the life of me work it out, kick command; a message gets sent to all players, a message gets sent to the staff member who kicked, these 2 lines work correctly.

The line sending the message to the kicked player doesn't function properly tho, nothing is sent, and the delay doesn't seem to work either.

Would love some help with this

Code:
forward kickdelays(playerid);
forward KickTimer(playerid);
Code:
public kickdelays(playerid) { Kick(playerid); }
Code:
CMD:kick(playerid, params[])
{
	if(pInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, WHITE, "Server: Unknown command.");
	new stringadm[144];
	new str[144], id, reason[144];
    if(pInfo[playerid][pLogin] == 0) return SendClientMessage(playerid, RED, "Register or Login first before using this command!");
    if(pInfo[playerid][pAdmin] >= 1)
    {
	    if(sscanf(params, "us[30]", id, reason)) return SendClientMessage(playerid, RED, "USAGE: /kick [id] [reason]");
    	if (pInfo[id][pAdmin] > pInfo[playerid][pAdmin]) return SendClientMessage(playerid, RED, "ERROR: You cannot Kick Admins who are a higher Rank than you.");
		if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: Invalid ID!");
		if(id == playerid) return SendClientMessage(playerid, RED, "You cannot kick yourself!");
		format(str, sizeof(str), "%s (%d) has been kicked by %s (%d) | Reason: %s", GetName(id), id, GetName(playerid), playerid, reason);
		SendClientMessageToAll(RED, str); // informs all players somebody has been kicked.
		format(str, sizeof(str), "You have kicked %s (%d) | Reason: %s", GetName(id), id, reason);
		SendClientMessage(playerid, RED, str); // Informs the staff who kicked, they've kicked someone
		
		SetTimerEx("kickdelays", 3000, false, "i", id); // delay the kick
		format(str, sizeof(str), "%s (%d) kicked you | Reason: %s", GetName(playerid), id, reason);
		SendClientMessage(id, RED, str); // informs the kicked person they've been kicked.
		
		Kick(id);
		format(stringadm,sizeof(stringadm),"[ADM]: %s used /kick",GetName(playerid));
		SendToAdmin(COLOR_ADM,stringadm);
    }
    else return SendClientMessage(playerid, WHITE, "Server: Unknown command.");
	return 1;
}
Thank you for your time and assitance!
Reply
#2

PHP Code:
CMD:kick(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridWHITE"Server: Unknown command.");
    new 
stringadm[144];
    new 
str[144], idreason[144];
    if(
pInfo[playerid][pLogin] == 0) return SendClientMessage(playeridRED"Register or Login first before using this command!");
    if(
pInfo[playerid][pAdmin] >= 1)
    {
        if(
sscanf(params"us[30]"idreason)) return SendClientMessage(playeridRED"USAGE: /kick [id] [reason]");
        if (
pInfo[id][pAdmin] > pInfo[playerid][pAdmin]) return SendClientMessage(playeridRED"ERROR: You cannot Kick Admins who are a higher Rank than you.");
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridRED"ERROR: Invalid ID!");
        if(
id == playerid) return SendClientMessage(playeridRED"You cannot kick yourself!");
        
format(strsizeof(str), "%s (%d) has been kicked by %s (%d) | Reason: %s"GetName(id), idGetName(playerid), playeridreason);
        
SendClientMessageToAll(REDstr); // informs all players somebody has been kicked.
        
format(strsizeof(str), "You have kicked %s (%d) | Reason: %s"GetName(id), idreason);
        
SendClientMessage(playeridREDstr); // Informs the staff who kicked, they've kicked someone
        
        
format(strsizeof(str), "%s (%d) kicked you | Reason: %s"GetName(playerid), idreason);
        
SendClientMessage(idREDstr); // informs the kicked person they've been kicked.
        
SetTimerEx("kickdelays"3000false"i"id); // delay the kick
        
        
format(stringadm,sizeof(stringadm),"[ADM]: %s used /kick",GetName(playerid));
        
SendToAdmin(COLOR_ADM,stringadm);
    }
    else return 
SendClientMessage(playeridWHITE"Server: Unknown command.");
    return 
1;

You had a Kick(id); after the timer, that's why you didn't get the message or the timer worked because you kick it instantly. You had 2 kicks to the same player, one instantly and one 3 seconds. That's why it didn't work well. I removed the Kick(id) and ordered the timer after the message. As a suggestion, I would put half a second or a maximum of 1 second. 3 seconds seems very long to me. Maybe the player will do something in those 3 seconds.
PD: Why do you have a forward ''KickTimer''? According to your code, you don't use it
Reply
#3

PHP Code:
CMD:kick(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridWHITE"Server: Unknown command.");
    new 
stringadm[144];
    new 
str[144], idreason[144];
    if(
pInfo[playerid][pLogin] == 0) return SendClientMessage(playeridRED"Register or Login first before using this command!");
    
    if(
sscanf(params"us[30]"idreason)) return SendClientMessage(playeridRED"USAGE: /kick [id] [reason]");
    if (
pInfo[id][pAdmin] > pInfo[playerid][pAdmin]) return SendClientMessage(playeridRED"ERROR: You cannot Kick Admins who are a higher Rank than you.");
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridRED"ERROR: Invalid ID!");
    if(
id == playerid) return SendClientMessage(playeridRED"You cannot kick yourself!");
    
format(strsizeof(str), "%s (%d) has been kicked by %s (%d) | Reason: %s"GetName(id), idGetName(playerid), playeridreason);
    
SendClientMessageToAll(REDstr); // informs all players somebody has been kicked.
    
format(strsizeof(str), "You have kicked %s (%d) | Reason: %s"GetName(id), idreason);
    
SendClientMessage(playeridREDstr); // Informs the staff who kicked, they've kicked someone
    
    
format(strsizeof(str), "%s (%d) kicked you | Reason: %s"GetName(playerid), idreason);
    
SendClientMessage(idREDstr); // informs the kicked person they've been kicked.
    
SetTimerEx("kickdelays"3000false"i"id); // delay the kick
    
    
format(stringadm,sizeof(stringadm),"[ADM]: %s used /kick",GetName(playerid));
    
SendToAdmin(COLOR_ADM,stringadm);
    return 
1;

I think this could work. You was setting that timer to execute before you have sent the message, so the order matters. Also, above stringadm formating you was kicking the player. I removed that, so remains only the timer. Also, you don't need to check in the command again if admin level is higher than 1 because you already checked if the player admin level is 0 to return unknown command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)