Raised This Month: $ Target: $400
 0% 

Cvar by Strings (Or Flags)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-19-2010 , 05:52   Cvar by Strings (Or Flags)
Reply With Quote #1

I Want to make a cvar ussing...

Example.

PHP Code:
new szString[4]
new 
Cvar

//Init
  
Cvar register_cvar("mycvar","abc")

//Function

get_pcvar_string(Cvar,szString,3)

if 
cvar 'a' = do this
if cvar 'a+b' = do this and that
if cvar 'b' = do that
if cvar 'abc' = do this,that and those 
...So...How???


if you don't understand what i mean,please tell me.

Other thing
How i can detect if a string is a number,if is not,block them?

And...

How i can set a random model when i use cs_set_user_team(id,CS_TEAM_CT,----)?

Last edited by #8 SickneSS; 05-19-2010 at 07:21.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 05-19-2010 , 08:05   Re: Cvar by Strings (Or Flags)
Reply With Quote #2

Maybe this will help ?

PHP Code:
if(get_user_team(id) == CS_TEAM_CT)
{
          
cs_set_user_model(idCT_MODELrandom(0sizeof CT_MODEL)])

DoviuX is offline
Send a message via Skype™ to DoviuX
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-19-2010 , 08:15   Re: Cvar by Strings (Or Flags)
Reply With Quote #3

Yes,i think,i need to make a enum with the CTS models?,because in the cstrike.inc
the models are all in one enum
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 05-19-2010 , 09:10   Re: Cvar by Strings (Or Flags)
Reply With Quote #4

Maybe something like this help.

PHP Code:
new const CT_MODELS[][]
{
    
"models/ct/firstmodel.mdl",
    
"models/ct/secondmodel.mdl",
    
"models/ct/thirdmodel.mdl"
}

public 
plugin_precache()
{
    new 
iNum
    
for (iNum 0iNum sizeof CT_MODELSiNum++)
        
engfunc(EngFunc_PrecacheModelCT_MODELS[iNum])
}

public 
whatever(id)
{
    if(
get_user_team(id) == CS_TEAM_CT)
    {
        
cs_set_user_model(idCT_MODELSrandom(0sizeof CT_MODELS)])
    }

DoviuX is offline
Send a message via Skype™ to DoviuX
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-19-2010 , 09:57   Re: Cvar by Strings (Or Flags)
Reply With Quote #5

I don't think so
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-19-2010 , 10:05   Re: Cvar by Strings (Or Flags)
Reply With Quote #6

Why do you want to have a + in the flags? Why not just use a list of flags like used for admin flags. You can then use read_flags and bit flags for each option.
__________________
Bugsy is offline
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 05-19-2010 , 10:14   Re: Cvar by Strings (Or Flags)
Reply With Quote #7

PHP Code:
#include <amxmodx>

#define ACCESS_WHATEVER_1 (1<<0) // a
#define ACCESS_WHATEVER_2 (1<<1) // b
#define ACCESS_WHATEVER_3 (1<<2) // c
// and so on..

new g_cFlags;

public 
plugin_init()
{
      
register_plugin("Flags?""0.0""#8 SickneSS");
      
      
g_cFlags register_cvar("plugin_flags""abc");
}

public 
your_public(/* args */)
{
      static 
szFlags[32];
      
      
get_pcvar_string(g_cFlagsszFlagscharsmax(szFlags));
      
      if(
read_flags(szFlags) & ACCESS_WHATEVER_1)
      {
            
// got the flag 'a'
      
}
      
      if(
read_flags(szFlags) & ACCESS_WHATEVER_2)
      {
            
// got the flag 'b'
      
}

      if(
read_flags(szFlags) & ACCESS_WHATEVER_3)
      {
            
// got the flag 'c'
      
}
      
      
// and so on again..

__________________

Last edited by unnyquee; 05-19-2010 at 10:18.
unnyquee is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-19-2010 , 10:49   Re: Cvar by Strings (Or Flags)
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
Why do you want to have a + in the flags? Why not just use a list of flags like used for admin flags. You can then use read_flags and bit flags for each option.
I Don't Know How,if this dont's works...

Quote:
Originally Posted by unnyquee View Post
PHP Code:
#include <amxmodx>

#define ACCESS_WHATEVER_1 (1<<0) // a
#define ACCESS_WHATEVER_2 (1<<1) // b
#define ACCESS_WHATEVER_3 (1<<2) // c
// and so on..

new g_cFlags;

public 
plugin_init()
{
      
register_plugin("Flags?""0.0""#8 SickneSS");
      
      
g_cFlags register_cvar("plugin_flags""abc");
}

public 
your_public(/* args */)
{
      static 
szFlags[32];
      
      
get_pcvar_string(g_cFlagsszFlagscharsmax(szFlags));
      
      if(
read_flags(szFlags) & ACCESS_WHATEVER_1)
      {
            
// got the flag 'a'
      
}
      
      if(
read_flags(szFlags) & ACCESS_WHATEVER_2)
      {
            
// got the flag 'b'
      
}

      if(
read_flags(szFlags) & ACCESS_WHATEVER_3)
      {
            
// got the flag 'c'
      
}
      
      
// and so on again..

I will read the admin.sma

btw Thanks!
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
lazarev
Veteran Member
Join Date: Sep 2008
Old 05-19-2010 , 11:21   Re: Cvar by Strings (Or Flags)
Reply With Quote #9

PHP Code:
    static connectenabler[6];
    
get_pcvar_string(kz_ljs_connectenablerconnectenabler5);
    
format(connectenabler5"_%s"connectenabler);

    if( 
contain(connectenabler"a") > )
        
gHasColorChat[id] = true;
    else
        
gHasColorChat[id] = false
lazarev is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-19-2010 , 11:59   Re: Cvar by Strings (Or Flags)
Reply With Quote #10

Using bit flags would be cheaper.
PHP Code:
enum _:Flags (<<=1)
{
     
FlagA 1,  //'a'
     
FlagB,  //'b'
     
FlagC,  //'c'
     
FlagD,  //'d '
     
FlagE   //'e'
}

new 
iFlags read_flagsszFlags );

if ( 
iFlags FlagA )
{
        
//player has flag a

__________________
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 21:46.


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