Raised This Month: $ Target: $400
 0% 

Registering Same Commands


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 06-03-2014 , 20:02   Registering Same Commands
Reply With Quote #1

Is there any problem with registering the same client commands in different plugins ?

For example, when a user typed the X command, two or more plugins must be called.

Let's say, I have a plugin like this

PHP Code:
new bool:is_logged[32];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("login","cmdLogin")
    
register_clcmd("func_x","cmdX")
}
public 
cmdLogin(id) {
    new 
arg[32];
    
read_argv(1,arg,31)
    
    if(
equal(arg,"123")) {
        
console_print(id,"Logged in.")
        
is_logged[id] = true;
        return 
PLUGIN_HANDLED
    
}
    
console_print(id,"Wrong password")
    return 
PLUGIN_HANDLED
}
public 
cmdX(id) {
    if(!
is_logged[id]) {
        
console_print(id,"You are not authorized to use this function.")
        return 
PLUGIN_HANDLED
    
}
    
    
//...


and this

PHP Code:

new bool:is_logged[32];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("login","cmdLogin")
    
register_clcmd("func_y","cmdY")
}
public 
cmdLogin(id) {
    new 
arg[32];
    
read_argv(1,arg,31)
    
    if(
equal(arg,"123")) {
        
console_print(id,"Logged in.")
        
is_logged[id] = true;
        return 
PLUGIN_HANDLED
    
}
    
console_print(id,"Wrong password")
    return 
PLUGIN_HANDLED
}
public 
cmdY(id) {
    if(!
is_logged[id]) {
        
console_print(id,"You are not authorized to use this function.")
        return 
PLUGIN_HANDLED
    
}
    
    
//...

akcaliberg is offline
 


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:48.


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