SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/01/2013, 10:25 AM   #1
101
Big Clucker
 
Join Date: Feb 2011
Location: Sarajevo
Posts: 185
Reputation: 2
Default Is it possible to auto kick paused players without using onplayerupdate?

Is it possible to auto kick paused players without using onplayerupdate? As onplayerupdate gets executed way too much times in a second.
__________________
101 is offline   Reply With Quote
Old 16/01/2013, 10:29 AM   #2
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,717
Reputation: 3070
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

You mean detect them? And firstly, did you try using OnPlayerUpdate and find that it caused a problem or did you just skip that step and assume it wouldn't be any good?
Y_Less is offline   Reply With Quote
Old 16/01/2013, 10:30 AM   #3
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,289
Reputation: 311
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

SetTimerEx for a playerid, for about 5-6 seconds, check if he is at the same position for more than 5 timer executions, if yes, kick him. But that would be a bit inaccurate. Best is the onplayerupdate thingy.
RajatPawar is offline   Reply With Quote
Old 16/01/2013, 11:02 AM   #4
101
Big Clucker
 
Join Date: Feb 2011
Location: Sarajevo
Posts: 185
Reputation: 2
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

Quote:
Originally Posted by Y_Less View Post
You mean detect them? And firstly, did you try using OnPlayerUpdate and find that it caused a problem or did you just skip that step and assume it wouldn't be any good?
It will work, and I did test it already. Problem is, onplayerupdate executes a dozen times in a second as far as I'm aware. Isn't that bad?
__________________
101 is offline   Reply With Quote
Old 16/01/2013, 11:03 AM   #5
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,717
Reputation: 3070
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

I don't know - is it? When you tested it on your server, what happened?
Y_Less is offline   Reply With Quote
Old 16/01/2013, 11:11 AM   #6
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,289
Reputation: 311
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

OnPlayerUpdate doesn't update a dozen times a second! I once by mistake, added a sendclientmessage under my OnPlayerUpdate, and on connecting, (my timestamp was active), I could see about 2 messages per second. Not bad. However, the frequency increased as I started running/driving.
RajatPawar is offline   Reply With Quote
Old 16/01/2013, 11:15 AM   #7
101
Big Clucker
 
Join Date: Feb 2011
Location: Sarajevo
Posts: 185
Reputation: 2
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

Quote:
Originally Posted by Y_Less View Post
I don't know - is it? When you tested it on your server, what happened?
Well nothing happened, I'm worried of the long term effect on lag on the server. I already have quite a few timers and will using onplayerupdate contribute to any lag? I don't think there is any other way to do this AFK thing without onplayerupdate.
__________________
101 is offline   Reply With Quote
Old 16/01/2013, 12:53 PM   #8
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,037
Reputation: 519
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

Code:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

forward AFKCheck(playerid);
public AFKCheck(playerid)
{
    new string[80];
    format(string, sizeof(string), "Player %s has been kicked | Reason: Away From Keyboard", playername);
    SendClientMessageToAll(0xFF0000FF, string);
    Kick(playerid);
    return 1;
}

Basically, the code above, sets a timer for 5 minutes, and whenever the player does something like move, type a command or speak, the timer will reset.
__________________

SERVER.LVCNR.NET:7777
Threshold is offline   Reply With Quote
Old 16/01/2013, 12:56 PM   #9
101
Big Clucker
 
Join Date: Feb 2011
Location: Sarajevo
Posts: 185
Reputation: 2
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

Quote:
Originally Posted by BenzoAMG View Post
Code:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    KillTimer(AFKCheck(playerid));
    SetTimerEx("AFKCheck", 300000, false, "i", playerid);
    return 1;
}

forward AFKCheck(playerid);
public AFKCheck(playerid)
{
    new string[80];
    format(string, sizeof(string), "Player %s has been kicked | Reason: Away From Keyboard", playername);
    SendClientMessageToAll(0xFF0000FF, string);
    Kick(playerid);
    return 1;
}

Basically, the code above, sets a timer for 5 minutes, and whenever the player does something like move, type a command or speak, the timer will reset.
I think this is worse than onplayerupdate lol.
__________________
101 is offline   Reply With Quote
Old 16/01/2013, 01:00 PM   #10
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,037
Reputation: 519
Default Re: Is it possible to auto kick paused players without using onplayerupdate?

Well you wanted something that wasn't called 3052 or whatever times a second, so there... be happy with it.
__________________

SERVER.LVCNR.NET:7777
Threshold 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
Detecting paused players? Twisted_Insane Scripting Help 6 14/04/2012 05:24 PM
Kicking Paused Players Michael[NBK] Scripting Help 3 11/11/2011 08:53 PM
Hey auto kick GTA-Roleplay Scripting Help 4 02/09/2011 07:34 AM
Auto-Kick help Sascha Help Archive 2 25/08/2010 04:06 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 08:27 AM.


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