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

Maybe a better way to check for flags..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
girtslo
Member
Join Date: Aug 2011
Old 05-15-2014 , 13:57   Maybe a better way to check for flags..
Reply With Quote #1

Maybe a better way to check for flags..


(For example) this is very simple code that give players with admin flag hp..
Code:
#include <amxmodx> 
#include <fun> 
#include <hamsandwich> 

public plugin_init()    RegisterHam(Ham_Spawn, "player", "player_spawn", 1) 

public player_spawn(id) 
    if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_B) 
        set_user_health(id, get_user_health(id) + 500) 
All vip plugins work like this , when player spawns plugin checks if that player has any flags and if he does plugin give something ,for example HP and etc...

But the question is, is it posible to make vip plugin that check for flags only in 2 cases when player connects to server , and when players change nick (because most admin flags and vips are on the nick) and then executes plugin ...The reason i ask is it posible because in csdm players spawn all the time and each time someone spawns plugins asks if he hase flags , and its very inefficient way for checing the flags...




This is the part that kills all vip plugins..
Code:
public player_spawn(id) 
    if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_B)

Last edited by girtslo; 05-15-2014 at 14:01.
girtslo is offline
connoisseur
Senior Member
Join Date: Jan 2012
Old 05-15-2014 , 14:08   Re: Maybe a better way to check for flags..
Reply With Quote #2

You should have posted in the scripting help section.
Anyway, you can use client_authorized() and use a boolean variable to store if the player has the required flag.
Use client_infochanged() to check for name change.

Last edited by connoisseur; 05-15-2014 at 14:38. Reason: corrected function name
connoisseur is offline
joshknifer
Veteran Member
Join Date: Jun 2011
Location: Denver, CO
Old 05-15-2014 , 14:27   Re: Maybe a better way to check for flags..
Reply With Quote #3

Quote:
Originally Posted by girtslo View Post
(because most admin flags and vips are on the nick)
Why would this be the case? Setting Admin flags by SteamID is the best method.

Anyways i am pretty sure this is what connoissuer is saying (which you could have found if you just searched titles for get_user_flags..):

https://forums.alliedmods.net/showpo...86&postcount=4
__________________

Last edited by joshknifer; 05-15-2014 at 14:29.
joshknifer is offline
Send a message via Skype™ to joshknifer
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-15-2014 , 15:02   Re: Maybe a better way to check for flags..
Reply With Quote #4

Quote:
Originally Posted by joshknifer View Post
Why would this be the case? Setting Admin flags by SteamID is the best method.
Indeed. The only reason why you save by nick is DProto.
__________________
Kia is offline
girtslo
Member
Join Date: Aug 2011
Old 05-16-2014 , 02:41   Re: Maybe a better way to check for flags..
Reply With Quote #5

I simply wanted to know is it posible to replace this line
Code:
public player_spawn(id) if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_B)
With something else that will reduce draw calls because this
Code:
get_user_flags(id) & ADMIN_LEVEL_B
isnt inefficient .. Each time someone spawns plugin asks if he hase flags ..

It wold be match better if plugin would only ask 2 times for flags , first time when players connects to server , and remebers that this player hase flags and executes rest of plugin and dont ask evry spawn for flags ..
And second time should be if players change nick , then plugin would ask agien if he hase flags , if he hase remeber and executes rest of plugin.. All i want to do is reduce draw calls and it would reduce ping , lag , and server cpu usege ...

Last edited by girtslo; 05-16-2014 at 03:11.
girtslo is offline
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-16-2014 , 03:37   Re: Maybe a better way to check for flags..
Reply With Quote #6

Quote:
Originally Posted by Kia View Post
Indeed. The only reason why you save by nick is DProto.
spam-

Quote:
Originally Posted by girtslo View Post
I simply wanted to know is it posible to replace this line
Code:
public player_spawn(id) if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_B)
With something else that will reduce draw calls because this
Code:
get_user_flags(id) & ADMIN_LEVEL_B
isnt inefficient .. Each time someone spawns plugin asks if he hase flags ..

It wold be match better if plugin would only ask 2 times for flags , first time when players connects to server , and remebers that this player hase flags and executes rest of plugin and dont ask evry spawn for flags ..
And second time should be if players change nick , then plugin would ask agien if he hase flags , if he hase remeber and executes rest of plugin.. All i want to do is reduce draw calls and it would reduce ping , lag , and server cpu usege ...
I dont understand better you, but maybe this:

Code:
#include <amxmodx> #include <fun> #include <hamsandwich> new bool:is_vip[33]; // Acces: #define THE_ACCES   "abcd" public plugin_init( )    {     RegisterHam( Ham_Spawn, "player", "player_spawn", 1 ) } public player_spawn( id ) {     if( is_user_alive( id ) && is_vip[ id ] )     {         set_user_health( id, get_user_health( id ) + 500 )     } } public client_authorized( id ) {     if( get_user_flags( id , read_flags( THE_ACCES ) ) )     {         is_vip [ id ] = true;     }     else     {         is_vip [ id ] = false;     } }
swapped is offline
girtslo
Member
Join Date: Aug 2011
Old 05-16-2014 , 07:11   Re: Maybe a better way to check for flags..
Reply With Quote #7

@swapped plugin doesn`t work(doesnt give hp)... Basically all i want to know IS IT POSIBLE to make same plugin , but with out checking every spawn each player for flags...I want something that will only check once and then every next spawn plugin will remeber that this Player hase flags ,and if this player hase not flags plugin will remember that , and will not check them agien ....I dont know how to explain this even simpler...

Last edited by girtslo; 05-16-2014 at 07:16.
girtslo is offline
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-20-2014 , 03:38   Re: Maybe a better way to check for flags..
Reply With Quote #8

Quote:
Originally Posted by girtslo View Post
@swapped plugin doesn`t work(doesnt give hp)... Basically all i want to know IS IT POSIBLE to make same plugin , but with out checking every spawn each player for flags...I want something that will only check once and then every next spawn plugin will remeber that this Player hase flags ,and if this player hase not flags plugin will remember that , and will not check them agien ....I dont know how to explain this even simpler...
*facepalm* [ thats because you are non-steamer ]

maybe if u try this ...

Code:
#include <amxmodx> #include <fun> #include <hamsandwich> new bool:is_vip[33]; // Acces: #define THE_ACCES   "abcd" public plugin_init( )    {     RegisterHam( Ham_Spawn, "player", "player_spawn", 1 ) } public player_spawn( id ) {     if( is_user_alive( id ) && is_vip[ id ] )     {         set_user_health( id, get_user_health( id ) + 500 )     } } public client_putinserver( id ) {     if( get_user_flags( id , read_flags( THE_ACCES ) ) )     {         is_vip [ id ] = true;     }     else     {         is_vip [ id ] = false;     } }

Last edited by swapped; 05-20-2014 at 04:41.
swapped is offline
Spawner30
BANNED
Join Date: Dec 2013
Location: I Don't Know Yet
Old 05-20-2014 , 04:37   Re: Maybe a better way to check for flags..
Reply With Quote #9

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <fun> #include <hamsandwich> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Spawner" #define is_user_vip(%1)    ( get_user_flags(%1) == read_flags("abcd")) new gHealth public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         RegisterHam( Ham_Spawn, "player", "player_spawn", 1 )         gHealth = register_cvar("max_health","500") } public player_spawn(id){     if(is_user_alive( id ) && is_user_vip(id))     {         set_user_health( id, get_user_health( id ) + get_pcvar_num(gHealth) )     } }

Last edited by Spawner30; 05-20-2014 at 07:51.
Spawner30 is offline
Send a message via Skype™ to Spawner30
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-20-2014 , 04:40   Re: Maybe a better way to check for flags..
Reply With Quote #10

Quote:
Originally Posted by Spawner30 View Post
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <fun> #include <hamsandwich> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Spawner" #define is_user_vip(%1) (get_user_flags(%1) & ADMIN_LEVEL_H)* new gHealth public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         RegisterHam( Ham_Spawn, "player", "player_spawn", 1 )         gHealth = register_cvar("max_health","500") } public player_spawn(id){     if(is_user_alive( id ) && is_user_vip(id))     {         set_user_health( id, get_user_health( id ) + get_pcvar_num(gHealth) )     } }
He want a better way , creating a boolean and named true when client connect if they have required flags is more faster insteand of checking his flags everytime his is respawning.
swapped is offline
Old 05-21-2014, 03:07
girtslo
This message has been deleted by girtslo.
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 01:31.


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