Multiple per-player timers or just one timer with a loop?
#1

So I'm thinking to do a bit of an update to my Cowly Cow FS, add some new functions, try to improve coding a li'l bit, etc.

But now I'm wondering on what's better: Having one timer that loops through ALL players and checks if the person is a cow or not, or simply use seperate timers per players, which get killed when the player isn't a cow anymore.

Any advice would be welcome ^^

Note: This script isn't made for mass usage, but for small amounts of people at a time.
Reply
#2

I think per player would be better, but I don't think it would make that big of a difference since its like you say for a small ammount of people
Reply
#3

I'd go with the single one and looping through the players (foreach would be a good thing to look into if you havent).

Also may i ask what this timer does (no idea what your cow fs does lol...) ? Depending on what it does, you can simply use OnPlayerUpdate; This isnt ideal if the code needs to be ran even when a player is afk though. As long as you make sure your code isn't being executed EVERY update / you dont need to the code ran when players are afk, its fine to use :P.
Reply
#4

if it can have it as no one is a cow I'd do per player timers
Reply
#5

Quote:
Originally Posted by Kyosaur
View Post
I'd go with the single one and looping through the players (foreach would be a good thing to look into if you havent).

Also may i ask what this timer does (no idea what your cow fs does lol...) ? Depending on what it does, you can simply use OnPlayerUpdate; This isnt ideal if the code needs to be ran even when a player is afk though. As long as you make sure your code isn't being executed EVERY update / you dont need to the code ran when players are afk, its fine to use :P.
It does around 4 floatsin/floatcas (4 Max, 2 minimum) calculations each time it gets executed, gets some positions and requires MapAndreas (Plugin) up to a max of one time at execution.



Quote:
Originally Posted by cessil
View Post
if it can have it as no one is a cow I'd do per player timers
Ah well, it has a command you must perform first, before being able to transform into a cow. So a server can have nobody being a cow, or everybody being a cow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)