SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 06/11/2012, 06:59 PM   #1
Jochemd
High-roller
 
Jochemd's Avatar
 
Join Date: Jul 2009
Location: The Netherlands
Posts: 2,220
Reputation: 844
Default PlayerAverage Calc. v1.0

Introduction
Hello. This simple library contains a function to retrieve the average of players over a particular time.

How does it work
You can choose to calculate a new player average each second, minute, or hour. Modify the define "TIME_USED" in the include if you'd like to change the default (= each second). It even saves the average when you shut down your server (it saves the amount of checks, and the total amount of players. Average is calculated by dividing the players with the amount of checks using floatdiv).

You can retrieve the average by using the function 'GetServerAveragePlayers()'. This returns a float, the average calculated players.

Download
Click here to download version 1

Is there anything you need to know?
Yeah, credits to Dracoblue for Dini. Also, I planned to make all measures of central tendency in the future (average, mode, median). For now you have the first one.

Jochem
__________________
Jochemd is offline   Reply With Quote
Old 06/11/2012, 07:10 PM   #2
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,333
Reputation: 251
Default Re: PlayerAverage Calc. v1.0

This is more a snippet than an include. You just used Dini as a crap saving method, some variables and hooking....Improve it.... Waiting for it

Edit: Why timer? If players joins and the server restarts (including crashes etc...) the average will not save.
__________________
TheArcher is offline   Reply With Quote
Old 06/11/2012, 07:15 PM   #3
Jochemd
High-roller
 
Jochemd's Avatar
 
Join Date: Jul 2009
Location: The Netherlands
Posts: 2,220
Reputation: 844
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by TheArcher View Post
This is more a snippet than an include. You just used Dini as a crap saving method, some variables and hooking....Improve it.... Waiting for it

Edit: Why timer? If players joins and the server restarts (including crashes etc...) the average will not save.
Dini is good for this as I do not need to save COMPLETE userdata files.

For the rest, you should take a closer look at the code. It's crash-safe.
__________________
Jochemd is offline   Reply With Quote
Old 06/11/2012, 07:22 PM   #4
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,333
Reputation: 251
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by Jochemd View Post
Dini is good for this as I do not need to save COMPLETE userdata files.

For the rest, you should take a closer look at the code. It's crash-safe.
I'm not talking about the include-crash but the server itself for unknown reasons. It could happen, trust me re-write it .
__________________
TheArcher is offline   Reply With Quote
Old 06/11/2012, 07:55 PM   #5
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 3,306
Reputation: 2184
Default Re: PlayerAverage Calc. v1.0

Oh come on dini is not the source of aids. Yes, it is slower than y_ini or the native functions, but it's definitely not going to make your server crash or eat your bandwith. Stop hating on it all the time, optimization is totally overrated.

OT: I'm wondering why you're using timers, I could think of a way more effective and accurate way to do this without missing any players at all !
__________________
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Old 06/11/2012, 08:03 PM   #6
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,333
Reputation: 251
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by Hiddos View Post
Oh come on dini is not the source of aids. Yes, it is slower than y_ini or the native functions, but it's definitely not going to make your server crash or eat your bandwith. Stop hating on it all the time, optimization is totally overrated.

OT: I'm wondering why you're using timers, I could think of a way more effective and accurate way to do this without missing any players at all !
LOL dude optimizing the server is what you have to do! Faster = best am I right? Why should I use out-dated scripts? I'm not hating this though, I appreciate the effort but if you really want to help the community, do something serious then.
__________________
TheArcher is offline   Reply With Quote
Old 06/11/2012, 08:19 PM   #7
Emmet_
Guest
 
Posts: n/a
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by Hiddos View Post
Oh come on dini is not the source of aids. Yes, it is slower than y_ini or the native functions, but it's definitely not going to make your server crash or eat your bandwith. Stop hating on it all the time, optimization is totally overrated.
This. If you're saving like 2 variables, it wouldn't hurt to use it.

On a second note, this is nice! I'm probably going to use this for a script I'm making.
  Reply With Quote
Old 06/11/2012, 08:32 PM   #8
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,333
Reputation: 251
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by Emmet_ View Post
This. If you're saving like 2 variables, it wouldn't hurt to use it.

On a second note, this is nice! I'm probably going to use this for a script I'm making.
Yes, it doesn't hurt for 10 000 lines but not for 100 000+ lines. I saw a lot of your posts and you were criticized by ****** but I liked your work and saying this is great but as you know saying something to improve basics things is different than saying this is a complex algorithm and you should change it a bit...
__________________
TheArcher is offline   Reply With Quote
Old 07/11/2012, 01:30 AM   #9
SuperViper
High-roller
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 1,178
Reputation: 315
Default Re: PlayerAverage Calc. v1.0

Quote:
Originally Posted by TheArcher View Post
Yes, it doesn't hurt for 10 000 lines but not for 100 000+ lines. I saw a lot of your posts and you were criticized by ****** but I liked your work and saying this is great but as you know saying something to improve basics things is different than saying this is a complex algorithm and you should change it a bit...
The amount of lines in a script tells nothing about the amount of resources it uses.
__________________
Release NameUse
FairPlayKeep the cheaters out of your server
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
SlopeClimb up a steep hill against other players with cars falling down

I do not play on any SAMP server. Anyone with the name Ricky Phelps in-game is an imposter.
SuperViper is offline   Reply With Quote
Old 07/11/2012, 06:54 AM   #10
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,338
Reputation: 138
Default Re: PlayerAverage Calc. v1.0

nice work , will be waiting for that median / mode workouts
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy 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
speed calc help THE_KNOWN Help Archive 0 27/03/2011 05:28 AM
Calc money with distance me-borno Help Archive 2 19/07/2010 09:31 AM


All times are GMT. The time now is 09:02 PM.


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