AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Maybe a better way to check for flags.. (https://forums.alliedmods.net/showthread.php?t=240442)

girtslo 05-15-2014 13:57

Maybe a better way to check for flags..
 
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)


connoisseur 05-15-2014 14:08

Re: Maybe a better way to check for flags..
 
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.

joshknifer 05-15-2014 14:27

Re: Maybe a better way to check for flags..
 
Quote:

Originally Posted by girtslo (Post 2138121)
(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

Kia 05-15-2014 15:02

Re: Maybe a better way to check for flags..
 
Quote:

Originally Posted by joshknifer (Post 2138141)
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.

girtslo 05-16-2014 02:41

Re: Maybe a better way to check for flags..
 
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 ...

swapped 05-16-2014 03:37

Re: Maybe a better way to check for flags..
 
Quote:

Originally Posted by Kia (Post 2138159)
Indeed. The only reason why you save by nick is DProto.

spam-

Quote:

Originally Posted by girtslo (Post 2138415)
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;     } }

girtslo 05-16-2014 07:11

Re: Maybe a better way to check for flags..
 
@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...

swapped 05-20-2014 03:38

Re: Maybe a better way to check for flags..
 
Quote:

Originally Posted by girtslo (Post 2138480)
@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;     } }

Spawner30 05-20-2014 04:37

Re: Maybe a better way to check for flags..
 
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) )     } }

swapped 05-20-2014 04:40

Re: Maybe a better way to check for flags..
 
Quote:

Originally Posted by Spawner30 (Post 2140189)
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.


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

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