/kick for certain time.
#1

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);

Reply
#2

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
Reply
#3

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)