AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   clcmd not working? (https://forums.alliedmods.net/showthread.php?t=98791)

entc 07-29-2009 09:34

clcmd not working?
 
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?

Xellath 07-29-2009 09:45

Re: clcmd not working?
 
The commands - are they correctly registered in plugin_init?

entc 07-29-2009 10:51

Re: clcmd not working?
 
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)

Xellath 07-29-2009 12:36

Re: clcmd not working?
 
Are you using the latest version of AMXX?


All times are GMT -4. The time now is 18:24.

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