Raised This Month: $51 Target: $400
 12% 

pev_frags crashing after update, either my code is bad


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2013 , 11:50   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #11

get_players was returning false results when using flag "e" with dead players, and only in some situations, it has been fix some time ago.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 08-19-2013 , 12:51   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #12

Quote:
Originally Posted by ConnorMcLeod View Post
get_players was returning false results when using flag "e" with dead players, and only in some situations, it has been fix some time ago.
I can't finde where ist fixed get_players in amxx shortlog list.
dFF is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-19-2013 , 12:54   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #13

Each method in a loop of 10 000 000 times.
Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> public plugin_init() {     register_plugin("Test Plugin 7", "", "");         set_task(5.0, "test1") } #define LOOPS   10000000 public test1() {         new MaxClients = global_get(glb_maxClients);     new Timer = get_systime();         for ( new c = 0 ; c < LOOPS ; c++ ) {         new Players[32], PlayersNum;         get_players(Players, PlayersNum, "ace", "TERRORIST");         for ( new i = 0 ; i <= PlayersNum ; i++ ) { }     }         server_print("Method 1: %d", get_systime() - Timer);     Timer = get_systime();         for ( new c = 0 ; c < LOOPS ; c++ ) {         new team[32];         for ( new i = 1 ; i <= MaxClients ; i++ ) {             if ( is_user_alive(i) && ! is_user_bot(i) && get_user_team(i, team, charsmax(team)) == 1 ) { }         }     }         server_print("Method 2: %d", get_systime() - Timer);     Timer = get_systime();             for ( new c = 0 ; c < LOOPS ; c++ ) {         for ( new i = 1 ; i <= MaxClients ; i++ ) {             if ( is_user_alive(i) && ! is_user_bot(i) && cs_get_user_team(i) == CS_TEAM_T ) { }         }     }         server_print("Method 3: %d", get_systime() - Timer); }

Code:
Method 1: 2
Method 2: 19
Method 3: 18
Bare in mind though that this was a server with no players.
Get players will still use the team name to retrieve a team ID before looping players.
It's still faster than both other methods, which are only calling is_user_alive() since it will return false. Maybe the time is just being spent in the actual looping than just calling natives.
__________________

Last edited by Black Rose; 08-19-2013 at 15:19.
Black Rose is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 08-19-2013 , 13:00   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #14

Quote:
Originally Posted by dFF View Post
@r0ck, you was used get_players in zombie mod ? Explain better (with some code example if you can) what is the problem exactly.
Maybe sometimes get_players with team-flag can result wrong in zombie mod, because zombiemod change team a lot of times and can't be updately instantly.. or somethings like this (with some private datas, scoreboard, etc.).
For Example xPaws Deathrun Manager in my multimod server ( experienced a lot till i changed get_players )
( Semiclip Code )

Quote:
Originally Posted by ConnorMcLeod View Post
get_players was returning false results when using flag "e" with dead players, and only in some situations, it has been fix some time ago.
ohk... but what about get_players not working till we didn't restarted the server ? isn't that weird ?
Btw it was fixed in 1.8.2 or 1.8.1 ?
Thanks

EDIT : Black Rose , we know get_players is fast but its just about bug...
__________________
Preparing to release my plugins..

Last edited by r0ck; 08-19-2013 at 13:03.
r0ck is offline
seriousspot
BANNED
Join Date: Mar 2013
Location: Lithuania / Norway
Old 08-19-2013 , 13:35   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #15

Quote:
Originally Posted by Black Rose View Post
Each method in a loop of 10 000 000 times.
Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> public plugin_init() {     register_plugin("Test Plugin 7", "", "");         set_task(5.0, "test1") } #define LOOPS   10000000 public test1() {         new MaxClients = global_get(glb_maxClients);     new Timer = get_systime();         for ( new c = 0 ; c < LOOPS ; c++ ) {         new Players[32], PlayersNum;         get_players(Players, PlayersNum, "ace", "TERRORIST");         for ( new i = 0 ; i <= PlayersNum ; i++ ) { }     }         server_print("Method 1: %d", get_systime() - Timer);     Timer = get_systime();         for ( new c = 0 ; c < LOOPS ; c++ ) {         new team[32];         for ( new i = 1 ; i <= MaxClients ; i++ ) {             if ( is_user_alive(i) && ! is_user_bot(i) && get_user_team(i, team, charsmax(team)) == 1 ) { }         }     }         server_print("Method 2: %d", get_systime() - Timer);     Timer = get_systime();             for ( new c = 0 ; c < LOOPS ; c++ ) {         for ( new i = 1 ; i <= MaxClients ; i++ ) {             if ( is_user_alive(i) && ! is_user_bot(i) && cs_get_user_team(i) == CS_TEAM_T ) { }         }     }         server_print("Method 3: %d", get_systime() - Timer); }

Code:
Method 1: 2
Method 2: 19
Method 3: 18
Bare in mind though that this was a server with no players.
Get players will still use the team name to retrieve a team ID before looping players.
It's still faster than both other methods, which are only calling is_user_alive() since it will return false. Maybe the time is just being spent in the actual looping than just calling natives.

For those of you that get false results with the team flag, at which point is the function called? Event, command, forward et.c.
dumb comparision also i am using cached values, ands theres only 32-33 loops depends on get_maxplayers
seriousspot is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-19-2013 , 15:19   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #16

Of course it's a dumb comparison. I don't have any players on my server.

The loops are basically the same. I used glb_MaxClients. get_players() also limits the loop to maxplayers. The difference being that the loop is running as a plugin or as a module. Obviously the module is faster.

You didn't understand my usage of LOOPS. I ran the player loops 10 000 000 times. It's a 2 dimensional loop. I didn't search for 10 000 000 players. So 32*10 000 000 = 320 000 000 possible players to process. If you divide the 19 seconds by 10000000 to get the time of one run it would be .0019 milliseconds. That is of course with no players.

In the end the difference, unless ran in like client_prethink(), won't really make an impact. You select your way of coding.
__________________

Last edited by Black Rose; 08-19-2013 at 15:21.
Black Rose is offline
seriousspot
BANNED
Join Date: Mar 2013
Location: Lithuania / Norway
Old 08-19-2013 , 18:13   Re: pev_frags crashing after update, either my code is bad
Reply With Quote #17

Quote:
Originally Posted by Black Rose View Post
Of course it's a dumb comparison. I don't have any players on my server.

The loops are basically the same. I used glb_MaxClients. get_players() also limits the loop to maxplayers. The difference being that the loop is running as a plugin or as a module. Obviously the module is faster.

You didn't understand my usage of LOOPS. I ran the player loops 10 000 000 times. It's a 2 dimensional loop. I didn't search for 10 000 000 players. So 32*10 000 000 = 320 000 000 possible players to process. If you divide the 19 seconds by 10000000 to get the time of one run it would be .0019 milliseconds. That is of course with no players.

In the end the difference, unless ran in like client_prethink(), won't really make an impact. You select your way of coding.
hmm interesting, would like to see real life comparision, there could be bots instead players
seriousspot is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 04:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode