Raised This Month: $ Target: $400
 0% 

clcmd not working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
entc
Junior Member
Join Date: May 2008
Old 07-29-2009 , 09:34   clcmd not working?
Reply With Quote #1

I have this code:
Code:
    register_clcmd("say /class", "ChangeClass");
    register_clcmd("say_team /class", "ChangeClass");
    register_clcmd("say /xp", "ShowHud");
    register_clcmd("say_team /xp", "ShowHud");
Code:
public ShowHud(id) {
    set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0);
    show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s", PlayerLevel[id], PlayerXP[id], CLASSES[PlayerClass[id]]);
}
Code:
public ChangeClass(id) {
    new menu = menu_create("Class Menu", "Class_Handle");
    menu_additem(menu, "uno", "1", 0);
    menu_additem(menu, "dos", "2", 0);
    menu_additem(menu, "tres", "3", 0);
    
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
    
    return PLUGIN_CONTINUE;
}

public Class_Handle(id, menu, item) {
    if(item == MENU_EXIT)
        menu_destroy(menu);
        
    new szCommand[6], szName[64];
    new access, callback;
    
    menu_item_getinfo(menu, item, access, szCommand, 5, szName, 63, callback);
    
    new i = str_to_num(szCommand);
    if(PlayerClass[id] != i) {
        PlayerClass[id] = i;
        client_print(id,print_chat,"[%s] You are now a %s", PREFIX, CLASSES[i]);
    } else
        client_print(id,print_chat,"[%s] You are allready a %s", PREFIX, CLASSES[i]);
        
    menu_destroy(menu);
    return PLUGIN_CONTINUE;
}
BUT, the clcmds wont work. When i type either /class or /xp nothing happens. I have checked the code a million times without finding anything wrong. You guys have any idea?
entc is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 07-29-2009 , 09:45   Re: clcmd not working?
Reply With Quote #2

The commands - are they correctly registered in plugin_init?
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
entc
Junior Member
Join Date: May 2008
Old 07-29-2009 , 10:51   Re: clcmd not working?
Reply With Quote #3

Yea, i think so:

PHP Code:
public plugin_init()
{
    
/*
    The rest of the registers
    */
    
register_clcmd("say /class""ChangeClass");
    
register_clcmd("say_team /class""ChangeClass");
    
register_clcmd("say /xp""ShowHud");
    
register_clcmd("say_team /xp""ShowHud");

Running plugin in debug mode:


L 07/29/2009 - 17:43:53: Invalid menu id 0(2)
L 07/29/2009 - 17:43:53: [AMXX] Displaying debug trace (plugin "flashattack.amxx")
L 07/29/2009 - 17:43:53: [AMXX] Run time error 10: native error (native "menu_item_getinfo")
L 07/29/2009 - 17:43:53: [AMXX] [0] flashattack.sma::Class_Handle (line 214)

Last edited by entc; 07-29-2009 at 11:45.
entc is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 07-29-2009 , 12:36   Re: clcmd not working?
Reply With Quote #4

Are you using the latest version of AMXX?
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath 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 18:24.


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