SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/06/2020, 10:50 AM   #1
TheLittleFucker
Little Clucker
 
TheLittleFucker's Avatar
 
Join Date: Jul 2014
Location: Straya Mate
Posts: 19
Reputation: 0
Default Kick delay and message not working.

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!
__________________
TheLittleFucker is offline   Reply With Quote
Old 02/06/2020, 11:04 AM   #2
Ertouq
Huge Clucker
 
Ertouq's Avatar
 
Join Date: Jul 2014
Posts: 236
Reputation: 4
Default Re: Kick delay and message not working.

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
Ertouq is offline   Reply With Quote
Old 02/06/2020, 11:05 AM   #3
SharpenBlade
Huge Clucker
 
Join Date: May 2020
Posts: 202
Reputation: 25
Default Re: Kick delay and message not working.

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.
SharpenBlade is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delay kick question Leaky Scripting Help 6 06/02/2019 08:35 PM
Kick Message. BlueEyes Scripting Help 20 24/03/2015 03:18 AM
Kick message Tuntun Scripting Help 6 04/06/2014 06:19 PM
How can I add a delay to my kick? lramos15 Scripting Help 7 08/06/2013 01:11 AM
The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] zDivine Server Support 4 17/05/2013 09:29 PM


All times are GMT. The time now is 08:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.