SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/01/2018, 10:05 AM   #1
zsoolt997
Little Clucker
 
zsoolt997's Avatar
 
Join Date: Aug 2015
Location: Hungary
Posts: 22
Reputation: 3
Default What is better?

Create a timer for all players (~500ms timer) or looping through all the connected players in a ~500ms timer too.

I will use y_timers.
zsoolt997 is offline   Reply With Quote
Old 10/01/2018, 10:14 AM   #2
RIDE2DAY
Huge Clucker
 
RIDE2DAY's Avatar
 
Join Date: Jul 2015
Location: Modena, Italy
Posts: 213
Reputation: 381
Default Re: What is better?

If the code you're going to execute isn't too heavy you might use a task and loop through the connected players with y_iterate:
PHP Code:
task my_task[500]()
{
    
// General code here.

    
foreach(new Player)
    {
        
// Per-player code here.
    
}

As an alternative, you might use a ptask, much better in my opinion:
PHP Code:
ptask my_player_task[500](playerid)
{
    
// Per-player code here.

Player tasks start to run when players connect while global tasks run always. You can read more about tasks here:
http://forum.sa-mp.com/showthread.php?t=571044

Anyway, if you're wondering what's better regarding your original question, a timer for each player is the way to go. Take a look to this thread:
http://forum.sa-mp.com/showthread.php?t=643553
RIDE2DAY is offline   Reply With Quote
Old 10/01/2018, 02:05 PM   #3
zsoolt997
Little Clucker
 
zsoolt997's Avatar
 
Join Date: Aug 2015
Location: Hungary
Posts: 22
Reputation: 3
Default Re: What is better?

Thanks!
zsoolt997 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



All times are GMT. The time now is 11:32 AM.


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