Raised This Month: $32 Target: $400
 8% 

Solved Set player flags question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-17-2022 , 21:01   Set player flags question
Reply With Quote #1

I have a problem that is at least annoying, the flags are not being set in the players, tested on windows and linux.

Code:
amxx version
AMX Mod X 1.10.0.5461 (http://www.amxmodx.org)
Authors:
        David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
        Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
        Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
        Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Dec  6 2021 17:37:35
Built from: https://github.com/alliedmodders/amxmodx/commit/ec82e3f3
Build ID: 5461:ec82e3f3
Core mode: JIT+ASM32
Code:
version
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.10.0.759-dev
Build date: 15:34:13 Jun 22 2021 (2628)
Build from: https://github.com/dreamstalker/rehlds/commit/ad6f6ad
Code:
Currently loaded plugins:
      description   stat pend  file                  vers          src  load  unload
 [ 1] AMX Mod X     RUN   -    amxmodx_mm.dll        v1.10.0.5461  ini  Start ANY
 [ 2] Ham Sandwich  RUN   -    hamsandwich_amxx.dll  v1.10.0.5461  pl1  ANY   ANY
 [ 3] CSX           RUN   -    csx_amxx.dll          v1.10.0.5461  pl1  ANY   ANY
 [ 4] FakeMeta      RUN   -    fakemeta_amxx.dll     v1.10.0.5461  pl1  ANY   ANY
4 plugins, 4 running
Code:
Currently loaded plugins:
       id  name                    version     author            url                              file         status   
 [  1] 0   Admin Base              1.10.0.546  AMXX Dev Team                                      admin.amxx   running  
 [  2] 1   Admin Commands          1.10.0.546  AMXX Dev Team                                      admincmd.am  running  
 [  3] 2   Admin Help              1.10.0.546  AMXX Dev Team                                      adminhelp.a  running  
 [  4] 3   Slots Reservation       1.10.0.546  AMXX Dev Team                                      adminslots.  running  
 [  5] 4   Multi-Lingual System    1.10.0.546  AMXX Dev Team                                      multilingua  running  
 [  6] 5   Menus Front-End         1.10.0.546  AMXX Dev Team                                      menufront.a  running  
 [  7] 6   Commands Menu           1.10.0.546  AMXX Dev Team                                      cmdmenu.amx  running  
 [  8] 7   Players Menu            1.10.0.546  AMXX Dev Team                                      plmenu.amxx  running  
 [  9] 8   Maps Menu               1.10.0.546  AMXX Dev Team                                      mapsmenu.am  running  
 [ 10] 9   Plugin Menu             1.10.0.546  AMXX Dev Team                                      pluginmenu.  running  
 [ 11] 10  Admin Chat              1.10.0.546  AMXX Dev Team                                      adminchat.a  running  
 [ 12] 11  Anti Flood              1.10.0.546  AMXX Dev Team                                      antiflood.a  running  
 [ 13] 12  Scrolling Message       1.10.0.546  AMXX Dev Team                                      scrollmsg.a  running  
 [ 14] 13  Info. Messages          1.10.0.546  AMXX Dev Team                                      imessage.am  running  
 [ 15] 14  Admin Votes             1.10.0.546  AMXX Dev Team                                      adminvote.a  running  
 [ 16] 15  NextMap                 1.10.0.546  AMXX Dev Team                                      nextmap.amx  running  
 [ 17] 16  Nextmap Chooser         1.10.0.546  AMXX Dev Team                                      mapchooser.  running  
 [ 18] 17  TimeLeft                1.10.0.546  AMXX Dev Team                                      timeleft.am  running  
 [ 19] 18  Pause Plugins           1.10.0.546  AMXX Dev Team                                      pausecfg.am  running  
 [ 20] 19  Stats Configuration     1.10.0.546  AMXX Dev Team                                      statscfg.am  running  
 [ 21] 20  StatsX                  1.10.0.546  AMXX Dev Team                                      statsx.amxx  paused   
 [ 22] 21  Tag VIP                 1.0         iceeedR                                            TagImputer.  running  
22 plugins, 21 running
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define CC_COLORS_TYPE CC_COLORS_SHORT
#include <cromchat>

#define PLUGIN  "Tag VIP"
#define VERSION "1.0"
#define AUTHOR  "iceeedR"

enum cVars
{
        
VarChatPrefix[MAX_NAME_LENGTH],
        
VarClanPrefix[MAX_NAME_LENGTH],
        
VarFlags[MAX_NAME_LENGTH]
}

new 
gCvars[cVars]
new 
g_szPlayerName[MAX_PLAYERS 1]

public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)

        
bind_pcvar_string(create_cvar("vip_chatprefix""iceeedR", .description "Prefix do chat."), gCvars[VarChatPrefix], charsmax(gCvars[VarChatPrefix]))
        
bind_pcvar_string(create_cvar("vip_prefix""iceeedR - ", .description "Tag do clan."), gCvars[VarClanPrefix], charsmax(gCvars[VarClanPrefix]))
        
bind_pcvar_string(create_cvar("vip_flags""b", .description "Flags que o VIP recebe."), gCvars[VarFlags], charsmax(gCvars[VarFlags]))

        
AutoExecConfig()

        
register_saycmd("tag""setTag")
}

public 
OnConfigsExecuted()
{
        
CC_SetPrefix(fmt("^4[^3%s^4]^1"gCvars[VarChatPrefix]))
}

public 
setTag(id)
{
        
remove_user_flags(id, -1)

        new 
flags get_user_flags(id), sflags[MAX_NAME_LENGTH]
        
get_flags(flagssflagscharsmax(sflags))
        
log_amx("[1] My flags are now %s"sflags)

        if(
containi(g_szPlayerName[id], gCvars[VarClanPrefix]) != -1)
        {
                
replace(g_szPlayerName[id], charsmax(g_szPlayerName), gCvars[VarClanPrefix], "")
                
set_user_info(id"name"g_szPlayerName[id])
                
set_user_flags(idADMIN_USER)
        }
        else
        {
                new 
szFullName[MAX_NAME_LENGTH]
                
formatex(szFullNamecharsmax(szFullName), "%s %s"gCvars[VarClanPrefix], g_szPlayerName[id])
                
copy(g_szPlayerName[id], charsmax(g_szPlayerName), szFullName)

                
set_user_info(id"name"szFullName)

                
log_amx("[2] Read flags = %i"read_flags(gCvars[VarFlags]))

                
set_user_flags(idread_flags(gCvars[VarFlags]))

                
log_amx("[3] Setting flags = %s"gCvars[VarFlags])
        }

        
get_flags(flagssflagscharsmax(sflags))
        
log_amx("[4] My flags are %s"sflags)

        return 
PLUGIN_HANDLED
}

public 
client_putinserver(id)
{
        
get_user_name(idg_szPlayerName[id], charsmax(g_szPlayerName))

        new 
flags get_user_flags(id), sflags[MAX_NAME_LENGTH]
        
get_flags(flagssflagscharsmax(sflags))

        
log_amx("[0] My entrance flags are %s"sflags)
}

stock register_saycmd(const szSayCmd[], const szFunc[], iFlags = -1, const szInfo[] = ""FlagManager = -1bool:bInfoML false)
{
        new const 
szPrefix[][] = { "say /""say_team /""say .""say_team ." };

        for(new 
iszTemp[32]; sizeof(szPrefix); i++)
        {
                
formatex(szTempcharsmax(szTemp), "%s%s"szPrefix[i], szSayCmd);
                
register_clcmd(szTempszFunciFlagsszInfoFlagManagerbInfoML);
        }

Edit: If I print the cvar "gCvars[VarFlags]" the "b" flag is displayed normally. So the problem doesn't seem to be the "empty" cvar.

Code:
Connection to Steam servers successful.
   VAC secure mode is activated.
L 01/18/2022 - 01:49:13: [TagImputer.amxx] [0] My entrance flags are z
L 01/18/2022 - 01:49:18: [TagImputer.amxx] [1] My flags are now
L 01/18/2022 - 01:49:18: [TagImputer.amxx] [2] Read flags = 2
L 01/18/2022 - 01:49:18: [TagImputer.amxx] [3] Setting flags = b
L 01/18/2022 - 01:49:18: [TagImputer.amxx] [4] My flags are
amx_who

Clients on server:
 #  nick             authid               userid   imm  res  access
 1  teste -  Aposen  STEAM_0:1:56888062   1        No     No     z
Total 1
L 01/18/2022 - 01:49:24: [admincmd.amxx] Cmd: "Counter-Strike 1.6 Server<0><><>" ask for players list
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 01-18-2022 at 09:43.
iceeedr is offline
Send a message via Skype™ to iceeedr
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2022 , 22:07   Re: Set player flags question
Reply With Quote #2

So, what is the value of read_flags(gCvars[VarFlags])?
__________________
fysiks is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-17-2022 , 22:26   Re: Set player flags question
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
So, what is the value of read_flags(gCvars[VarFlags])?
Post updated.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2022 , 23:21   Re: Set player flags question
Reply With Quote #4

I don't see in the code where you're printing out the value of read_flags() and it's certainly not where it needs to be to actually help debug your code. It need to be before your print "[2]". Set the read_flags() value to a variable, print it and then use it in set_user_flags().
__________________
fysiks is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-17-2022 , 23:50   Re: Set player flags question
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
I don't see in the code where you're printing out the value of read_flags() and it's certainly not where it needs to be to actually help debug your code. It need to be before your print "[2]". Set the read_flags() value to a variable, print it and then use it in set_user_flags().
I just hadn't updated the code in the post, look again. Taking advantage, I updated the log.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-18-2022 , 08:43   Re: Set player flags question
Reply With Quote #6

Quote:
Originally Posted by iceeedr View Post
I have a problem that is at least annoying, the flags are not being set in the players, tested on windows and linux.
1. After changing the player's name, the admin core plugin reloads his access: https://github.com/alliedmodders/amx....sma#L768-L781

2.
Code:
public setTag(id) {              /* Why do you remove the player's flags? */
        remove_user_flags(id, -1)
       new flags = get_user_flags(id), sflags[MAX_NAME_LENGTH]
        get_flags(flags, sflags, charsmax(sflags))         log_amx("[1] My flags are now %s", sflags)         if(containi(g_szPlayerName[id], gCvars[VarClanPrefix]) != -1)         {                 replace(g_szPlayerName[id], charsmax(g_szPlayerName), gCvars[VarClanPrefix], "")                 set_user_info(id, "name", g_szPlayerName[id])                 set_user_flags(id, ADMIN_USER)         }         else         {                 new szFullName[MAX_NAME_LENGTH]                 formatex(szFullName, charsmax(szFullName), "%s %s", gCvars[VarClanPrefix], g_szPlayerName[id])                 copy(g_szPlayerName[id], charsmax(g_szPlayerName), szFullName)                 set_user_info(id, "name", szFullName)                 log_amx("[2] Read flags = %i", read_flags(gCvars[VarFlags]))                 set_user_flags(id, read_flags(gCvars[VarFlags]))                 log_amx("[3] Setting flags = %s", gCvars[VarFlags])         }
        /* You still get the inital value of flags, you need to get them again */
        flags = get_user_flags(id)
        get_flags(flags, sflags, charsmax(sflags))         log_amx("[4] My flags are %s", sflags)         return PLUGIN_HANDLED }
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-18-2022 , 09:43   Re: Set player flags question
Reply With Quote #7

1 - I really didn't think about that case, I set a task and it's working.

2 - set_user_flags just adds the selected flags to the existing ones and I don't want ADMIN_USER so I remove them all before setting, problem solved.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-18-2022 , 10:38   Re: Set player flags question
Reply With Quote #8

Yes, set_user_flags() should be named add_user_flags(), as it's a bit misleading at face value.
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-18-2022 , 22:54   Re: Set player flags question
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Yes, set_user_flags() should be named add_user_flags(), as it's a bit misleading at face value.
Well, kind of but not necessarily. Flags are stored as bits. "Setting bits" is simply OR'ing them and that operation doesn't remove any other bits.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-19-2022 , 00:30   Re: Set player flags question
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
Well, kind of but not necessarily. Flags are stored as bits. "Setting bits" is simply OR'ing them and that operation doesn't remove any other bits.
Agree, it depends on your interpretation of what 'set' means.

"Set the flags I gave you as the players flags"
or
"Set the flags I gave you to true but leave the others as is" (what set_user_flags() does)

I personally think it would have been better to have:
  • set_user_flags() - Clear all existing bits and set only the bits passed
  • add_user_flags() - Keep existing bits and add only the bits passed
__________________

Last edited by Bugsy; 01-19-2022 at 00:30.
Bugsy 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 16:50.


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