Raised This Month: $ Target: $400
 0% 

Get different info form one cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoGoGo
Senior Member
Join Date: Apr 2008
Old 03-09-2009 , 09:16   Get different info form one cvar
Reply With Quote #1

Hi

How to get different info from one cvar (in cfg file). I mean how to transform:
Code:
some_cvar "lol"
some_cvar "lol2"
some_cvar "lol3"
some_cvar "lol4"
(this code is written in config/some_cvar.cfg)
to
Code:
cvar [0] = lol
cvar [1] = lol2
cvar [2] = lol3
cvar [3] = lol4
(And plugin transform it to this form)
Sorry 4 bad description but I had no idea how to tell this.
__________________
Aaaaaa!

Last edited by GoGoGo; 03-09-2009 at 09:25.
GoGoGo is offline
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 03-09-2009 , 09:26   Re: Get different info form one cvar
Reply With Quote #2

Example:
PHP Code:
...

#define MAX_CVARS 4
#define MAX_LENGTH 32

...

new const 
g_szCvarsMAX_CVARS ][ MAX_LENGTH ]

...

new 
szCvar1MAX_LENGTH ]
new 
szCvar2MAX_LENGTH ]
get_cvar_string"some_cvar"szCvar1sizeof szCvar1 ) - )
get_cvar_string"some_cvar"szCvar2sizeof szCvar2 ) - )

g_szCvars] = szCvar1
g_szCvars
] = szCvar2 

Last edited by TheRadiance; 03-09-2009 at 09:31.
TheRadiance is offline
Send a message via ICQ to TheRadiance
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-09-2009 , 10:22   Re: Get different info form one cvar
Reply With Quote #3

Are you trying to convert individual cvar pointer variables to an array of cvar pointers?

PHP Code:
new g_Cvar[5];

enum
{
    
ITEM1,
    
ITEM2,
    
ITEM3,
    
ITEM4,
    
ITEM5
}

public 
plugin_init()
{
    
g_Cvar[ITEM1] = register_cvar"item1" "val1" );
    
g_Cvar[ITEM2] = register_cvar"item2" "val2" );
    
g_Cvar[ITEM3] = register_cvar"item3" "val3" );
    
g_Cvar[ITEM4] = register_cvar"item4" "val4" );
    
g_Cvar[ITEM5] = register_cvar"item5" "val5" );
}

new 
szVal[5];
get_pcvar_string g_Cvar[ITEM1] , szVal ); 
__________________
Bugsy is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-09-2009 , 10:59   Re: Get different info form one cvar
Reply With Quote #4

i think he wants todo like for example amx_imessage, you can do multiple thing with that

and btw its not cvar, its like an console command :]
__________________
xPaw is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 03-09-2009 , 12:35   Re: Get different info form one cvar
Reply With Quote #5

Yes, I don't want to use 5 items, I want to use one command.

First method is not working for me, but these two definitions (max cvar and lenght) are good
__________________
Aaaaaa!

Last edited by GoGoGo; 03-09-2009 at 12:39.
GoGoGo is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-09-2009 , 12:44   Re: Get different info form one cvar
Reply With Quote #6

See register_srvcmd("amx_addserver", "addserver")

http://forums.alliedmods.net/showpos...66&postcount=6
__________________

Last edited by AntiBots; 03-09-2009 at 12:46.
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
GoGoGo
Senior Member
Join Date: Apr 2008
Old 03-09-2009 , 13:05   Re: Get different info form one cvar
Reply With Quote #7

Ok one more thing

I can check args, but how to go to next line

some_cvar "lol"
some_cvar "lol2"


First line is checked by read arg 1, but how to check lol2?
__________________
Aaaaaa!
GoGoGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-09-2009 , 13:15   Re: Get different info form one cvar
Reply With Quote #8

Quote:
Originally Posted by GoGoGo View Post
Ok one more thing

I can check args, but how to go to next line

some_cvar "lol"
some_cvar "lol2"


First line is checked by read arg 1, but how to check lol2?

It will be read by read_argv(1), it doesn't change. Everythime that "some_cvar" is executed you will be starting over essentially (if you are registering it as a server command).
__________________
fysiks is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 03-09-2009 , 13:20   Re: Get different info form one cvar
Reply With Quote #9

So what code should I add to make it work?
__________________
Aaaaaa!
GoGoGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-09-2009 , 13:30   Re: Get different info form one cvar
Reply With Quote #10

PHP Code:
#include <amxmodx>
new Array:my_array_of_strings
public plugin_init() 
{
 
register_srvcmd("some_cvar""add_value_to_array")
}
public 
add_value_to_array()
{
 new 
my_string[32]
 
read_argv(1my_string31)
 
ArrayPushString(my_array_of_stringsmy_string)
 return 
PLUGIN_HANDLED

Then use "my_array_of_strings[#]" anywhere in the plugin. But remember to check the size of the array so you don't go "out of bounds"
__________________

Last edited by fysiks; 03-09-2009 at 13:32.
fysiks is offline
Reply


Thread Tools
Display Modes

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 09:02.


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