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

Check if other mode is running


Post New Thread Reply   
 
Thread Tools Display Modes
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-12-2015 , 04:18   Re: Check if other mode is running
Reply With Quote #11

Can I have an example on cvar, cause I've never done one before.
Obada is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2015 , 08:52   Re: Check if other mode is running
Reply With Quote #12

Quote:
Originally Posted by Obada View Post
Can I have an example on cvar, cause I've never done one before.
Look at existing plugins that use cvars for how to use cvars. For each of your plugins, register a cvar like "mod1_running" then, set the value of that cvar to 1 when the mod is started and set the value of the cvar to 0 when it stops. You can check the value of the mod1 cvar in mod2 and vice versa.
__________________
fysiks is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-12-2015 , 23:15   Re: Check if other mode is running
Reply With Quote #13

So admins can change cvar by amx_cvar or?

I'm confused, like you mean I should remove the command that starts the mode, and replace it with a cvar?
Obada is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2015 , 23:19   Re: Check if other mode is running
Reply With Quote #14

Quote:
Originally Posted by Obada View Post
So admins can change cvar by amx_cvar or?
If an admin has the cvar flag then yes.

Quote:
Originally Posted by Obada View Post
I'm confused, like you mean I should remove the command that starts the mode, and replace it with a cvar?
I never said that. The cvar would be used merely for an indicator. If you have problems with admins changing the cvars, remove their cvar access or remove them as admins.

If you don't want to use cvars, use xvars. If you don't want to use xvars, use natives. If you don't want to use natives, then you can't do what you want. I.e. Just pick one and do it.
__________________
fysiks is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-13-2015 , 00:27   Re: Check if other mode is running
Reply With Quote #15

Ok thanks alot man.

I'll try using cvars.

PS. is Pcvars same as cvars? Thanks :p


EDIT: Here is what I tried.

Plugin1:
PHP Code:
new g_ghost_active[12
PHP Code:
public plugin_init()     
{     
g_ghost_active register_cvar("ghostmode_active""0"FCVAR_SPONLY
PHP Code:
public gwm(idlevelcid//the mode's function
{     
set_pcvar_num(ghostmode_activate1)

if(!
cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED
    
    
if(g_bGhostRunning)
    {
        
client_print(idprint_chat"*** Mode is already running")
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"*** You must be alive to activate the mode")
        return 
PLUGIN_HANDLED
    
}
    
    if (
get_pcvar_string(g_sologunner_active111);
    {
        
client_print(idprint_chat"*** Solo Gunner Mode is running at the moment.")
        return 
PLUGIN_HANDLED
    


Plugin2:

PHP Code:
new g_sologunner_active[12
PHP Code:
g_sologunner_active register_cvar("sologunner_active""0"FCVAR_SPONLY
PHP Code:
public gwm(idlevelcid//modes function
{     
    
set_pcvar_num(ghostmode_activate1)
    
    if(!
cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED
    
    
if(g_bGhostRunning)
    {
        
client_print(idprint_chat"*** Mode is already running")
        return 
PLUGIN_HANDLED
    
}
    
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"*** You must be alive to activate the mode.")
        return 
PLUGIN_HANDLED
    
}
    
    if (
get_pcvar_string(ghostmode_activate111));
    {
        
client_print(idprint_chat"*** Ghost Mode is running at the moment.")
        return 
PLUGIN_HANDLED
    



I'm really new to this, so please tell me if it's right or wrong, I just read the tutorial that explains about cvars, so this is the first time I'm dealing with cvars. Thanks

Last edited by Obada; 02-13-2015 at 02:43.
Obada is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-13-2015 , 18:26   Re: Check if other mode is running
Reply With Quote #16

The cvar variable must be integer not array!
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-14-2015 , 00:55   Re: Check if other mode is running
Reply With Quote #17

I'm confused, can you give me an example on how to do it?
Obada is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 02-14-2015 , 01:42   Re: Check if other mode is running
Reply With Quote #18

Just remove the size definition (aka the "[12]") behind the cvar.
__________________
Currently offline for study.
RateX is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-14-2015 , 03:38   Re: Check if other mode is running
Reply With Quote #19

PHP Code:
public gwm(idlevelcid)
{     
    
set_pcvar_num(ghostmode_activate1// <-- Line 207
    
    
if(!cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED 
Code:
//// ghostmode1.sma
// C:\steamcmd\cs_server\cstrike\addons\amxmodx\scripting\ghostmode1.sma(207) :
error 017: undefined symbol "ghostmode_activate"
// C:\steamcmd\cs_server\cstrike\addons\amxmodx\scripting\ghostmode1.sma(207) :
warning 215: expression has no effect
// C:\steamcmd\cs_server\cstrike\addons\amxmodx\scripting\ghostmode1.sma(207) :
error 001: expected token: ";", but found ")"
How am I supposed to change a cvar inside a function?

Last edited by Obada; 02-14-2015 at 03:39.
Obada is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-14-2015 , 03:45   Re: Check if other mode is running
Reply With Quote #20

If you define the cvar pointer globally, you can set/get the cvar from anywhere in the plugin. Global variables are only accessible to the plugin in which they are defined.

If you are trying to access a cvar that is registered in a different plugin, you have to get the cvar pointer for it first using get_cvar_pointer() in the plugin_cfg() forward.
__________________

Last edited by fysiks; 02-14-2015 at 03:47.
fysiks 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 20:08.


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