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

Check if other mode is running


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-11-2015 , 10:58   Check if other mode is running
Reply With Quote #1

Hey there,

I have a question.

I have two plugins, they are modes for fun. I want if one of them is activated, the admins should not be able to activate the other one.

PHP Code:
public gwm(idlevelcid)
{     
    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
    

So here in the function, it already check if the mode itself is running, it won't allow it to be activated another time.

But how can I catch if the other mode is running?

Here is the other mode.
PHP Code:
public AdminActivate(idlevelcid)
{
    if(!
cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED
    
    
if(g_bRunning)
    {
        
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
    


Thanks everyone.


PS. They are two separate plugins.

Last edited by Obada; 02-11-2015 at 11:02.
Obada is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 02-11-2015 , 11:27   Re: Check if other mode is running
Reply With Quote #2

I'm sure you can use xvars for this.
__________________

Accepting all kinds of requests via private message.
matsi is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-11-2015 , 11:29   Re: Check if other mode is running
Reply With Quote #3

I'm sorry.

Could you explain more, I'm really new to this.

EDIT: I found this link

Can I have an example.

Last edited by Obada; 02-11-2015 at 11:31.
Obada is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 02-11-2015 , 11:30   Re: Check if other mode is running
Reply With Quote #4

Check with native?
__________________
Currently offline for study.

Last edited by RateX; 02-12-2015 at 10:44.
RateX is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-11-2015 , 11:34   Re: Check if other mode is running
Reply With Quote #5

I don't know.

I heard somewhere where I can
Code:
#include <pluginname.amxx>
I know it may seem stupid, but I really think that I've read this somewhere, but I can't remember where.
Obada is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-11-2015 , 12:56   Re: Check if other mode is running
Reply With Quote #6

Create a native, and check with if like
PHP Code:
if(mod_already_running()) 
{
    return
}
else
{
    
//do your stuffs

The native can be:
PHP Code:
new boolPluginState
public plugin_natives()
{
    
register_native("mod_already_loaded""_mod_already_loaded")
}

public 
_mod_already_loaded(const PluginIndex, const PluginParams)
{
    return 
PluginState

The only think you have to do is to set the bool to true when the needed part of code is triggered and to false when it's stopped.

You can do with xvars too(as matsi said), query a global variable value in the plugin and check it's value.
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2015 , 20:02   Re: Check if other mode is running
Reply With Quote #7

Quote:
Originally Posted by Obada View Post
I don't know.

I heard somewhere where I can
Code:
#include <pluginname.amxx>
I know it may seem stupid, but I really think that I've read this somewhere, but I can't remember where.
It seems stupid because it is. It makes no sense and won't work.
__________________
fysiks is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 02-11-2015 , 20:53   Re: Check if other mode is running
Reply With Quote #8

make a cvar, it's so much easier than natives
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 02-11-2015 , 21:52   Re: Check if other mode is running
Reply With Quote #9

If I want to make a native, should I have a .inc file?

If no I will try using the native.
Obada is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2015 , 22:42   Re: Check if other mode is running
Reply With Quote #10

I would use cvars or xvars if you are writing both of the plugins and aren't going to distribute them.
__________________
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 05:39.


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