AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   join class bug (https://forums.alliedmods.net/showthread.php?t=312150)

devilsquare 11-18-2018 10:22

join class bug
 
I'm having problems with class selection.

I wanted to create a menu over the default class selection menu.

EXAMPLE:

PHP Code:


#include <amxmodx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN_NAME "[CS] Class Custom"
#define PLUGIN_VERSION "2.0.1.8"
#define PLUGIN_AUTHOR "Eclipse*"

const PDATA_SAFE 2
const OFFSET_CSMENUCODE 205

new const CT_ClassNames[][] = { "Seal Team 6""GSG-9""SAS""GIGN" }
new const 
CT_ClassSysNames[][] = { "urban""gsg9""sas""gign" }

new const 
T_ClassNames[][] = { "Phoenix Connexion""Elite Crew""Arctic Avengers""Guerilla Warfare" }
new const 
T_ClassSysNames[][] = { "terror""leet""arctic""guerilla" }

public 
plugin_init() {
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    
register_message(get_user_msgid("ShowMenu"), "FWD_ShowMenu")
    
register_message(get_user_msgid("VGUIMenu"), "FWD_VGUIMenu")
    
    
register_clcmd("jointeam""CLCMD_Team")
    
register_clcmd("chooseteam""CLCMD_Team")
    
register_clcmd("joinclass""CLCMD_Class")
}

public 
FWD_ShowMenu(MsgIDMsgDestid) {
    if (!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    new 
MenuTXT[64]; get_msg_arg_string(4MenuTXTcharsmax(MenuTXT));
    
    if (
contain(MenuTXT"Team_Select")) {
        
MENU_Team(id)
        return 
PLUGIN_HANDLED
    
}
    
    else if (
contain(MenuTXT"Terrorist_Select") || contain(MenuTXT"CT_Select")) {
        
MENU_Class(idCsTeams:cs_get_user_team(id))
        return 
PLUGIN_HANDLED
    
}
    
    
//g_iMsgId[id] = MsgID
    
    
return PLUGIN_CONTINUE
}

public 
FWD_VGUIMenu(MsgIDMsgDestid) {
    if (!
is_user_connected(id))
        return 
PLUGIN_CONTINUE;
    
    if (
get_msg_arg_int(1) == PDATA_SAFE) {
        
MENU_Team(id)
        return 
PLUGIN_HANDLED
    
}
    else {
        if (
get_msg_arg_int(1) == 26 || get_msg_arg_int(1) == 27) {
            
MENU_Class(idCsTeams:cs_get_user_team(id))
            return 
PLUGIN_HANDLED
        
}
    }
    
    return 
PLUGIN_CONTINUE
}

public 
CLCMD_Team(id) {
    
/*if (!Is_Valid_Connected(id))
        return PLUGIN_CONTINUE;*/
    
    //set_pdata_int(id, 125, get_pdata_int(id, 125, 5) & ~(1<<8), 5)
    
    
MENU_Team(id)
    
    return 
PLUGIN_HANDLED
}

public 
MENU_Team(id) {
    if (!
is_user_connected(id)) return PLUGIN_CONTINUE;
    
    new 
MenuTXT[1024]; formatex(MenuTXTcharsmax(MenuTXT), "\yMenu da Equipe:\d");
    new 
MenuIDMenuID menu_create(MenuTXT"SUBMENU_Team");
    
    
formatex(MenuTXTcharsmax(MenuTXT), "\wTerroristas")
    
menu_additem(MenuIDMenuTXT"1")
    
    
formatex(MenuTXTcharsmax(MenuTXT), "\wContra-Terroristas^n")
    
menu_additem(MenuIDMenuTXT"2")
    
    
formatex(MenuTXTcharsmax(MenuTXT), "\wEspectador^n")
    
menu_additem(MenuIDMenuTXT"3")
    
    
/*formatex(MenuTXT, charsmax(MenuTXT), "\wSelecionar Aleatoriamente^n")
    menu_additem(MenuID, MenuTXT, "4")*/
    
    
formatex(MenuTXTcharsmax(MenuTXT), "\wSair do Menu")
    
menu_setprop(MenuIDMPROP_EXITNAMEMenuTXT)
    
    if (
pev_valid(id) == PDATA_SAFE)
        
set_pdata_int(idOFFSET_CSMENUCODE0);
    
    
menu_display(idMenuID)
    return 
PLUGIN_HANDLED
}

public 
SUBMENU_Team(idMenuItem) {
    if (
Item == MENU_EXIT || !is_user_connected(id)) {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
AccessInfo[4], Name[32], CallBack
    menu_item_getinfo
(MenuItemAccessInfocharsmax(Info), Namecharsmax(Name), CallBack)
    
    new 
KeyKey str_to_num(Info);
    
    switch (
Key) {
        case 
1: {
            
engclient_cmd(id"jointeam"Info)
            
MENU_Class(idCsTeams:Key)
        }
        case 
2: {
            
engclient_cmd(id"jointeam"Info)
            
MENU_Class(idCsTeams:Key)
        }
        case 
3engclient_cmd(id"jointeam"Info);
        
//case 4: Fm_JoinTeam(id, random_num(1, Key-1));
    
}
    
    return 
PLUGIN_HANDLED
}

public 
CLCMD_Class(id) {
    
/*if (!Is_Valid_Connected(id))
        return PLUGIN_CONTINUE;*/
    
    
MENU_Class(idcs_get_user_team(id))
    
    return 
PLUGIN_HANDLED
}

public 
MENU_Class(idCsTeams:Team) {
    if (!
is_user_connected(id)) return PLUGIN_CONTINUE;
    
    new 
MenuTXT[1024]; formatex(MenuTXTcharsmax(MenuTXT), "\yMenu das Classes:\d");
    new 
MenuIDMenuID menu_create(MenuTXT"SUBMENU_Class");
    
    if (
CsTeams:Team == CS_TEAM_T) {
        for (new 
0sizeof(T_ClassNames); I++) {
            
formatex(MenuTXTcharsmax(MenuTXT), "\w%s"T_ClassNames[I])
            new 
Num[4]; num_to_str(I+1Numcharsmax(Num));
            
menu_additem(MenuIDMenuTXTNum)
        }
    }
    else if (
CsTeams:Team == CS_TEAM_CT) {
        for (new 
0sizeof(CT_ClassNames); I++) {
            
formatex(MenuTXTcharsmax(MenuTXT), "\w%s"CT_ClassNames[I])
            new 
Num[4]; num_to_str(I+1Numcharsmax(Num));
            
menu_additem(MenuIDMenuTXTNum)
        }
    }
    else {
        
menu_destroy(MenuID)
        return 
PLUGIN_HANDLED
    
}
    
    
/*formatex(MenuTXT, charsmax(MenuTXT), "\wVoltar Pagina")
    menu_setprop(MenuID, MPROP_BACKNAME, MenuTXT)
    formatex(MenuTXT, charsmax(MenuTXT), "\wProxima Pagina")
    menu_setprop(MenuID, MPROP_NEXTNAME, MenuTXT)*/
    
formatex(MenuTXTcharsmax(MenuTXT), "\wSair do Menu")
    
menu_setprop(MenuIDMPROP_EXITNAMEMenuTXT)
    
    if (
pev_valid(id) == PDATA_SAFE)
        
set_pdata_int(idOFFSET_CSMENUCODE0);
    
    
menu_display(idMenuID)
    return 
PLUGIN_HANDLED
}

public 
SUBMENU_Class(idMenuItem) {
    if (
Item == MENU_EXIT || !is_user_connected(id) || cs_get_user_team(id) < CS_TEAM_T || cs_get_user_team(id) > CS_TEAM_CT) {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
AccessInfo[4], Name[32], CallBack
    menu_item_getinfo
(MenuItemAccessInfocharsmax(Info), Namecharsmax(Name), CallBack)
    
    new 
KeyKey str_to_num(Info);
    
    
/*if (!Get_Bitvar(g_Alive, id)) {
        dllfunc(
        //ExecuteHamB(Ham_CS_RoundRespawn, id)
        
        //Set_Bitvar(g_Alive, id)
    }*/
    
    
engclient_cmd(id"joinclass"Info)
    
    if (
cs_get_user_team(id) == CS_TEAM_T) {
        switch (
Key) {
            case 
1cs_set_user_model(idT_ClassSysNames[Key-1]);
            case 
2cs_set_user_model(idT_ClassSysNames[Key-1]);
            case 
3cs_set_user_model(idT_ClassSysNames[Key-1]);
            case 
4cs_set_user_model(idT_ClassSysNames[Key-1]);
        }
    }
    else {
        switch (
Key) {
            case 
1cs_set_user_model(idCT_ClassSysNames[Key-1]);
            case 
2cs_set_user_model(idCT_ClassSysNames[Key-1]);
            case 
3cs_set_user_model(idCT_ClassSysNames[Key-1]);
            case 
4cs_set_user_model(idCT_ClassSysNames[Key-1]);
        }
    }
    
    return 
PLUGIN_HANDLED


OBS: I am using a code a little different from this example but the functions are the same.

Napoleon_be 11-20-2018 08:20

Re: join class bug
 
and what seems to be your bug?

devilsquare 11-21-2018 01:26

Re: join class bug
 
Quote:

Originally Posted by Napoleon_be (Post 2624873)
and what seems to be your bug?

this message comes up shortly after I select the class

"This command is not available to you at this point"

Napoleon_be 11-22-2018 08:33

Re: join class bug
 
Can you please put your code in a PHP window and also indent your code so it's easier to read?

devilsquare 11-22-2018 21:33

Re: join class bug
 
Quote:

Originally Posted by Napoleon_be (Post 2625174)
Can you please put your code in a PHP window and also indent your code so it's easier to read?

could any moderator do this favor?

because I can not find such an option
*

iceeedr 11-23-2018 07:25

Re: join class bug
 
You should enter the code between this [php] text [/ php]

devilsquare 11-23-2018 12:20

Re: join class bug
 
Quote:

Originally Posted by iceeedr (Post 2625345)
You should enter the code between this [php] text [/ php]

Thank you very much.

Napoleon_be 11-25-2018 10:11

Re: join class bug
 
Quote:

Originally Posted by devilsquare (Post 2624986)
this message comes up shortly after I select the class

"This command is not available to you at this point"

Does it happen when you join the server and join a class? when you change team? when exactly does it happen

devilsquare 11-26-2018 15:05

Re: join class bug
 
Quote:

Originally Posted by Napoleon_be (Post 2625630)
Does it happen when you join the server and join a class? when you change team? when exactly does it happen

join class :(

devilsquare 12-03-2018 03:36

Re: join class bug
 
the issue has been resolved, you can close the topic :D


All times are GMT -4. The time now is 07:35.

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