SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/01/2019, 12:04 PM   #1
MacGyverr
Little Clucker
 
Join Date: Aug 2014
Posts: 49
Reputation: 3
Default /kick for certain time.

How could i get player kicked for certain amount of time, and also display msg to all and when the player tries to join, he/she will get message example "You are kicked for 4minutes"

PHP Code:
CMD:kick(playeridparams[], help)
{
    if(
Info[playerid][Level] >= 2)
    {
        new 
idreason[50],string[128];
        if(
sscanf(params"uS()[50]"idreason)) return SCM(playeridred"Kick player: /kick <PlayerID> <Reason>");
        if(
id == INVALID_PLAYER_ID) return SCM(playeridred"Invalid player id");

        if(
Info[playerid][Level] <= Info[id][Level]) return ShowMessage(playeridred6);
        if(!
isnull(reason))
        
format(string,sizeof(string),"%s %s has kicked %s: %s",GetLevel(playerid),GetName(playerid),GetName(id),reason);
        else 
format(string,sizeof(string),"%s %s has kicked %s",GetLevel(playerid),GetName(playerid),GetName(id));
        
SendClientMessageToAll(red,string);
        return 
DelayKick(id);
    }
    else return 
ShowMessage(playeridred1);

MacGyverr is offline   Reply With Quote
Old 19/01/2019, 12:34 PM   #2
Heress
Huge Clucker
 
Heress's Avatar
 
Join Date: Mar 2018
Location: Lithuania
Posts: 262
Reputation: 7
Default Re: /kick for certain time.

Use timer

Code:
SetTimerEx("KickTimer", 1000, false, "is", id, reason);
Code:
forward KickTimer(playerid, reason[]);
public KickTimer(playerid, reason[])
{
    Kick(playerid);
    SendCLientMessageToAll(BLUE, reason);
    return 1;
}
also you can format message in timer and show time
__________________
==============
Sorry for my bad English









Respect: Kalcor, ******. Thank you for this great game!
Heress is offline   Reply With Quote
Old 19/01/2019, 12:47 PM   #3
Chyakka
Big Clucker
 
Join Date: Jul 2015
Location: England
Posts: 61
Reputation: 10
Default Re: /kick for certain time.

You could create a new variable in the player info enum for kick time and utilize
Code:
Info[id][newkickvariable] = gettime()+240; //4 minutes
when you kick them, save it to a database and when they attempt to connect.

Code:
public OnPlayerConnect(playerid) {
    if(Info[id][newkickvariable] > gettime())
    {
        //send message and kick them
        DelayKick(playerid);
    }
}
Although you'd probably want to change it to run that last bit of logic after it loads all the player data from the database otherwise it won't work.
Chyakka is offline   Reply With Quote
Old 19/01/2019, 12:50 PM   #4
Bolex_
Gangsta
 
Bolex_'s Avatar
 
Join Date: Aug 2015
Location: Croatia.
Posts: 586
Reputation: 124
Default Re: /kick for certain time.

Quote:
Originally Posted by Heress View Post
Use timer

Code:
SetTimerEx("KickTimer", 1000, false, "is", id, reason);
Code:
forward KickTimer(playerid, reason[]);
public KickTimer(playerid, reason[])
{
    Kick(playerid);
    SendCLientMessageToAll(BLUE, reason);
    return 1;
}
also you can format message in timer and show time

Obviously, you just came here to post a nonsense code without reading what he's looking for exactly.
Bolex_ 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
[Ajuda] Comando : /kick | Não aparece ao player o motivo do kick! ScripterInicianteBR Português/Portuguese 3 31/01/2015 08:04 PM
No login in time = Kick (Help +Rep) Alex_Obando Scripting Help 12 17/10/2013 09:40 AM
Made /kick Command to Kick Player from Virtual World... MAFIAWARS Scripting Help 11 28/09/2013 03:39 PM
Auto-AFK kick and Ping Kick Garc1a Help Archive 3 28/07/2010 07:26 PM


All times are GMT. The time now is 03:23 PM.


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