AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help for CT or T Custom Menu (https://forums.alliedmods.net/showthread.php?t=327095)

feren02 09-01-2020 05:26

Help for CT or T Custom Menu
 
Hello guys! Hope you are coping during these times.

Kindly help me on this script (.sma):

***THE IDEA*** - When Counter Terrorist type /skin, a menu pops up with certain options, on the other hand, when Terrorist Team types /skin on say, a menu pops up as well with certain options.

I have the .sma already, problem is, I can't find a way to define the certain options of the menu pop-up when typing on say: /skin for CT OR T teams. Here are the codes as reference:

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>


#define PLUGIN "Admin Model Menu"
#define VERSION "1.0"
#define AUTHOR "Dimision"
#define ADMIN_LEVEL_Q        ADMIN_LEVEL_C

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /skin", "admin")
}

public plugin_precache()
{
        precache_model("models/player/Asasin/Asasin.mdl")
        precache_model("models/player/Death/Death.mdl")
        precache_model("models/player/Dobby/Dobby.mdl")
        precache_model("models/player/Sonic/Sonic.mdl")
        precache_model("models/player/Skeleton/Skeleton.mdl")
        precache_model("models/player/Joker/Joker.mdl")
        precache_model("models/player/Iron/Iron.mdl")
}
               
public admin(id)
{
        if (get_user_flags(id) & ADMIN_LEVEL_H)
                {
                        model_menu(id)
                }
                else
        {
              ChatColor(id, "!g>> !nContact Admin for VIP Subscription!n!")
        }
       
}
public model_menu(id)
{
    new menu = menu_create("\r[\wVIP Skins\r]\r", "menu_wybierz")
   
    menu_additem(menu, "\wAsasin", "1", 0)
    menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    menu_additem(menu, "\wSonic", "4", 0)
    menu_additem(menu, "\wSkeleton", "5", 0)
    menu_additem(menu, "\wJoker", "6", 0)
    menu_additem(menu, "\wIron", "7", 0)

   
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
   
    menu_display(id, menu, 0)
}

public menu_wybierz(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new acces, callback
    menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)
   
    new key = str_to_num(data)
   
    switch(key)
    {
      case 1 : cs_set_user_model(id, "Asasin")
      case 2 : cs_set_user_model(id, "Death")
      case 3 : cs_set_user_model(id, "Dobby")
      case 4 : cs_set_user_model(id, "Sonic")
      case 5 : cs_set_user_model(id, "Skeleton")
      case 6 : cs_set_user_model(id, "Joker")
      case 7 : cs_set_user_model(id, "Iron")
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED

stock ChatColor(const id, const input[], any:...) {
        new count = 1, players[32];
        static msg[191];
        vformat(msg, 190, input, 3);
       
        replace_all(msg, 190, "!g", "^4"); // verde
        replace_all(msg, 190, "!n", "^1"); // galben/alb/negru
        replace_all(msg, 190, "!t", "^3"); // rosu/albastru/gri
        replace_all(msg, 190, "!t2", "^0"); // rosu2/albastru2/gri2
       
        if (id) players[0] = id; else get_players(players, count, "ch");
        {
                for (new i = 0; i < count; i++)
                        {
                        if (is_user_connected(players[i]))
                                {
                                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                                write_byte(players[i]);
                                write_string(msg);
                                message_end();
                        }
                }
        }
}

I want this to be the MENU OPTIONS for COUNTER TERRORIST:
Code:

    menu_additem(menu, "\wAsasin", "1", 0)
    //menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    menu_additem(menu, "\wSonic", "4", 0)
    //menu_additem(menu, "\wSkeleton", "5", 0)
    //menu_additem(menu, "\wJoker", "6", 0)
    menu_additem(menu, "\wIron", "7", 0)

WHILE this are the MENU OPTIONS FOR TERRORIST:
Code:

    //menu_additem(menu, "\wAsasin", "1", 0)
    menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    //menu_additem(menu, "\wSonic", "4", 0)
    menu_additem(menu, "\wSkeleton", "5", 0)
    menu_additem(menu, "\wJoker", "6", 0)
    //menu_additem(menu, "\wIron", "7", 0)

Please help me retain my Syntax since I will use this in the future, What I need really is those Two options appear to CT or Terro when they type /skin on say.


LOOKING FORWARD! Thank you! :)

CrazY. 09-01-2020 15:22

Re: Help for CT or T Custom Menu
 
You can check which team the player is using cs_get_user_team native.

Code:

if (cs_get_user_team(id) == CS_TEAM_T)
{
        // add TERRORIST menu options here
}
else
{
        // add CT menu options here
}

I suggest that you create two menus instead, one to Terrorits and other to CTs and add the same condition, as the one above, in the command where the menu is opened.

Supremache 09-01-2020 18:47

Re: Help for CT or T Custom Menu
 
1 Attachment(s)
Quote:

Originally Posted by feren02 (Post 2716224)
Hello guys! Hope you are coping during these times.

Kindly help me on this script (.sma):

***THE IDEA*** - When Counter Terrorist type /skin, a menu pops up with certain options, on the other hand, when Terrorist Team types /skin on say, a menu pops up as well with certain options.

I have the .sma already, problem is, I can't find a way to define the certain options of the menu pop-up when typing on say: /skin for CT OR T teams. Here are the codes as reference:

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>


#define PLUGIN "Admin Model Menu"
#define VERSION "1.0"
#define AUTHOR "Dimision"
#define ADMIN_LEVEL_Q        ADMIN_LEVEL_C

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /skin", "admin")
}

public plugin_precache()
{
        precache_model("models/player/Asasin/Asasin.mdl")
        precache_model("models/player/Death/Death.mdl")
        precache_model("models/player/Dobby/Dobby.mdl")
        precache_model("models/player/Sonic/Sonic.mdl")
        precache_model("models/player/Skeleton/Skeleton.mdl")
        precache_model("models/player/Joker/Joker.mdl")
        precache_model("models/player/Iron/Iron.mdl")
}
               
public admin(id)
{
        if (get_user_flags(id) & ADMIN_LEVEL_H)
                {
                        model_menu(id)
                }
                else
        {
              ChatColor(id, "!g>> !nContact Admin for VIP Subscription!n!")
        }
       
}
public model_menu(id)
{
    new menu = menu_create("\r[\wVIP Skins\r]\r", "menu_wybierz")
   
    menu_additem(menu, "\wAsasin", "1", 0)
    menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    menu_additem(menu, "\wSonic", "4", 0)
    menu_additem(menu, "\wSkeleton", "5", 0)
    menu_additem(menu, "\wJoker", "6", 0)
    menu_additem(menu, "\wIron", "7", 0)

   
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
   
    menu_display(id, menu, 0)
}

public menu_wybierz(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new acces, callback
    menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)
   
    new key = str_to_num(data)
   
    switch(key)
    {
      case 1 : cs_set_user_model(id, "Asasin")
      case 2 : cs_set_user_model(id, "Death")
      case 3 : cs_set_user_model(id, "Dobby")
      case 4 : cs_set_user_model(id, "Sonic")
      case 5 : cs_set_user_model(id, "Skeleton")
      case 6 : cs_set_user_model(id, "Joker")
      case 7 : cs_set_user_model(id, "Iron")
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED

stock ChatColor(const id, const input[], any:...) {
        new count = 1, players[32];
        static msg[191];
        vformat(msg, 190, input, 3);
       
        replace_all(msg, 190, "!g", "^4"); // verde
        replace_all(msg, 190, "!n", "^1"); // galben/alb/negru
        replace_all(msg, 190, "!t", "^3"); // rosu/albastru/gri
        replace_all(msg, 190, "!t2", "^0"); // rosu2/albastru2/gri2
       
        if (id) players[0] = id; else get_players(players, count, "ch");
        {
                for (new i = 0; i < count; i++)
                        {
                        if (is_user_connected(players[i]))
                                {
                                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                                write_byte(players[i]);
                                write_string(msg);
                                message_end();
                        }
                }
        }
}

I want this to be the MENU OPTIONS for COUNTER TERRORIST:
Code:

    menu_additem(menu, "\wAsasin", "1", 0)
    //menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    menu_additem(menu, "\wSonic", "4", 0)
    //menu_additem(menu, "\wSkeleton", "5", 0)
    //menu_additem(menu, "\wJoker", "6", 0)
    menu_additem(menu, "\wIron", "7", 0)

WHILE this are the MENU OPTIONS FOR TERRORIST:
Code:

    //menu_additem(menu, "\wAsasin", "1", 0)
    menu_additem(menu, "\wDeath", "2", 0)
    //menu_additem(menu, "\wDobby", "3", 0)
    //menu_additem(menu, "\wSonic", "4", 0)
    menu_additem(menu, "\wSkeleton", "5", 0)
    menu_additem(menu, "\wJoker", "6", 0)
    //menu_additem(menu, "\wIron", "7", 0)

Please help me retain my Syntax since I will use this in the future, What I need really is those Two options appear to CT or Terro when they type /skin on say.


LOOKING FORWARD! Thank you! :)

I remade it but i didn't tested it

feren02 09-02-2020 00:00

Re: Help for CT or T Custom Menu
 
Quote:

Originally Posted by CrazY. (Post 2716288)
You can check which team the player is using cs_get_user_team native.

Code:

if (cs_get_user_team(id) == CS_TEAM_T)
{
        // add TERRORIST menu options here
}
else
{
        // add CT menu options here
}

I suggest that you create two menus instead, one to Terrorits and other to CTs and add the same condition, as the one above, in the command where the menu is opened.

Thank you for this but where would I insert it? Do I need to add other lines or codes? My apologies, not that much in scripting..

Thanks in advance!

feren02 09-02-2020 00:02

Re: Help for CT or T Custom Menu
 
Quote:

Originally Posted by Supremache (Post 2716311)
I remade it but i didn't tested it

Hello thank you for your time really. I tested it but when I type /skin on say (y), nothing appears. (Tried on both teams) Thank you looking forward for your response.

Supremache 09-02-2020 07:10

Re: Help for CT or T Custom Menu
 
Quote:

Originally Posted by feren02 (Post 2716336)
Hello thank you for your time really. I tested it but when I type /skin on say (y), nothing appears. (Tried on both teams) Thank you looking forward for your response.

I will check it
Edit: I have tested it and there's no problem, it's working perfectly cmd "say /skin"

https://i.ibb.co/vxbS1mH/2s.png
https://i.ibb.co/ZKHJ9F5/1s.png

CrazY. 09-02-2020 09:12

Re: Help for CT or T Custom Menu
 
You can do something like this:

Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
        register_plugin("Plugin", "Version", "Author")
        register_clcmd("say /menu", "CommandMenu")
}

public CommandMenu(id)
{
        switch (cs_get_user_team(id))
        {
                case CS_TEAM_T: ShowMenuT(id)
                case CS_TEAM_CT: ShowMenuCT(id)
        }
}


/* Terrorist Menu */
ShowMenuT(id)
{
        new menu = menu_create("[T] Skins Menu", "HandleMenuT")
        menu_additem(menu, "Skin #1") // this will be 0
        menu_additem(menu, "Skin #2") // this will be 1
        menu_additem(menu, "Skin #3") // this will be 2
        menu_display(id, menu)
}

public HandleMenuT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_T || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        switch (item)
        {
                case 0:
                {
                        // Player selected 'Skin #1'
                }
                case 1:
                {
                        // Player selected 'Skin #2'
                }
                case 2:
                {
                        // Player selected 'Skin #3'
                }
        }

        menu_destroy(menu)
        return PLUGIN_HANDLED
}


/* Counter-Terrorist Menu */
ShowMenuCT(id)
{
        new menu = menu_create("[CT] Skins Menu", "HandleMenuCT")
        menu_additem(menu, "Skin #1") // this will be 0
        menu_additem(menu, "Skin #2") // this will be 1
        menu_additem(menu, "Skin #3") // this will be 2
        menu_display(id, menu)
}

public HandleMenuCT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_CT || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        switch (item)
        {
                case 0:
                {
                        // Player selected 'Skin #1'
                }
                case 1:
                {
                        // Player selected 'Skin #2'
                }
                case 2:
                {
                        // Player selected 'Skin #3'
                }
        }

        menu_destroy(menu)
        return PLUGIN_HANDLED
}


If the menu is going to have more than 1 page, you should do this instead:
Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
        register_plugin("Plugin", "Version", "Author")
        register_clcmd("say /menu", "CommandMenu")
}

public CommandMenu(id)
{
        switch (cs_get_user_team(id))
        {
                case CS_TEAM_T: ShowMenuT(id)
                case CS_TEAM_CT: ShowMenuCT(id)
        }
}

/* Terrorist Menu */
ShowMenuT(id)
{
        new menu = menu_create("[T] Skins Menu", "HandleMenuT")
        menu_additem(menu, "Skin #1", "1") // we'll treat the third param as the model index, 1 in this case
        menu_additem(menu, "Skin #2", "2") // this will be 2
        menu_additem(menu, "Skin #3", "3") // this will be 3
        menu_display(id, menu)
}

public HandleMenuT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_T || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        new access, callback, info[3]
        menu_item_getinfo(menu, item, access, info, charsmax(info), _, _, callback)
        menu_destroy(menu)
        new model_id = str_to_num(info)

        switch (model_id)
        {
                case 1:
                {
                        // Player selected 'Skin #1'
                }
                case 2:
                {
                        // Player selected 'Skin #2'
                }
                case 3:
                {
                        // Player selected 'Skin #3'
                }
        }

        return PLUGIN_HANDLED
}


/* Counter-Terrorist Menu */
ShowMenuCT(id)
{
        new menu = menu_create("[CT] Skins Menu", "HandleMenuCT")
        menu_additem(menu, "Skin #1", "1") // we'll treat the third param as the model index, 1 in this case
        menu_additem(menu, "Skin #2", "2") // this will be 2
        menu_additem(menu, "Skin #3", "3") // this will be 3
        menu_display(id, menu)
}

public HandleMenuCT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_CT || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        new access, callback, info[3]
        menu_item_getinfo(menu, item, access, info, charsmax(info), _, _, callback)
        menu_destroy(menu)
        new model_id = str_to_num(info)

        switch (model_id)
        {
                case 1:
                {
                        // Player selected 'Skin #1'
                }
                case 2:
                {
                        // Player selected 'Skin #2'
                }
                case 3:
                {
                        // Player selected 'Skin #3'
                }
        }

        return PLUGIN_HANDLED
}

There is more information about newmenus in this thread
https://forums.alliedmods.net/showpo...40&postcount=1

Hope I've helped, happy coding!

Supremache 09-02-2020 09:18

Re: Help for CT or T Custom Menu
 
Quote:

Originally Posted by CrazY. (Post 2716385)
You can do something like this:

Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
        register_plugin("Plugin", "Version", "Author")
        register_clcmd("say /menu", "CommandMenu")
}

public CommandMenu(id)
{
        switch (cs_get_user_team(id))
        {
                case CS_TEAM_T: ShowMenuT(id)
                case CS_TEAM_CT: ShowMenuCT(id)
        }
}


/* Terrorist Menu */
ShowMenuT(id)
{
        new menu = menu_create("[T] Skins Menu", "HandleMenuT")
        menu_additem(menu, "Skin #1") // this will be 0
        menu_additem(menu, "Skin #2") // this will be 1
        menu_additem(menu, "Skin #3") // this will be 2
        menu_display(id, menu)
}

public HandleMenuT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_T || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        switch (item)
        {
                case 0:
                {
                        // Player selected 'Skin #1'
                }
                case 1:
                {
                        // Player selected 'Skin #2'
                }
                case 2:
                {
                        // Player selected 'Skin #3'
                }
        }

        menu_destroy(menu)
        return PLUGIN_HANDLED
}


/* Counter-Terrorist Menu */
ShowMenuCT(id)
{
        new menu = menu_create("[CT] Skins Menu", "HandleMenuCT")
        menu_additem(menu, "Skin #1") // this will be 0
        menu_additem(menu, "Skin #2") // this will be 1
        menu_additem(menu, "Skin #3") // this will be 2
        menu_display(id, menu)
}

public HandleMenuCT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_CT || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        switch (item)
        {
                case 0:
                {
                        // Player selected 'Skin #1'
                }
                case 1:
                {
                        // Player selected 'Skin #2'
                }
                case 2:
                {
                        // Player selected 'Skin #3'
                }
        }

        menu_destroy(menu)
        return PLUGIN_HANDLED
}


If the menu is going to have more than 1 page, you should do this instead:
Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
        register_plugin("Plugin", "Version", "Author")
        register_clcmd("say /menu", "CommandMenu")
}

public CommandMenu(id)
{
        switch (cs_get_user_team(id))
        {
                case CS_TEAM_T: ShowMenuT(id)
                case CS_TEAM_CT: ShowMenuCT(id)
        }
}

/* Terrorist Menu */
ShowMenuT(id)
{
        new menu = menu_create("[T] Skins Menu", "HandleMenuT")
        menu_additem(menu, "Skin #1", "1") // we'll treat the third param as the model index, 1 in this case
        menu_additem(menu, "Skin #2", "2") // this will be 2
        menu_additem(menu, "Skin #3", "3") // this will be 3
        menu_display(id, menu)
}

public HandleMenuT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_T || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        new access, callback, info[3]
        menu_item_getinfo(menu, item, access, info, charsmax(info), _, _, callback)
        menu_destroy(menu)
        new model_id = str_to_num(info)

        switch (model_id)
        {
                case 1:
                {
                        // Player selected 'Skin #1'
                }
                case 2:
                {
                        // Player selected 'Skin #2'
                }
                case 3:
                {
                        // Player selected 'Skin #3'
                }
        }

        return PLUGIN_HANDLED
}


/* Counter-Terrorist Menu */
ShowMenuCT(id)
{
        new menu = menu_create("[CT] Skins Menu", "HandleMenuCT")
        menu_additem(menu, "Skin #1", "1") // we'll treat the third param as the model index, 1 in this case
        menu_additem(menu, "Skin #2", "2") // this will be 2
        menu_additem(menu, "Skin #3", "3") // this will be 3
        menu_display(id, menu)
}

public HandleMenuCT(id, menu, item)
{
        if (cs_get_user_team(id) != CS_TEAM_CT || item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }

        new access, callback, info[3]
        menu_item_getinfo(menu, item, access, info, charsmax(info), _, _, callback)
        menu_destroy(menu)
        new model_id = str_to_num(info)

        switch (model_id)
        {
                case 1:
                {
                        // Player selected 'Skin #1'
                }
                case 2:
                {
                        // Player selected 'Skin #2'
                }
                case 3:
                {
                        // Player selected 'Skin #3'
                }
        }

        return PLUGIN_HANDLED
}

There is more information about newmenus in this thread
https://forums.alliedmods.net/showpo...40&postcount=1

Hope I've helped, happy coding!

I already did that on my plugin and i tested it and it working perfectly but he said my plugin didn't worked with him :shock:

P.S @feren02: I did one wrong on my plugin

Replace from:
PHP Code:

switch(cs_get_user_team(id))
    {
        case 
CS_TEAM_T:
            
CustomCTMenu(id);
        
        case 
CS_TEAM_CT:
            
CustomTMenu(id);
    } 

To:

PHP Code:

switch(cs_get_user_team(id))
    {
        case 
CS_TEAM_T:
            
CustomTMenu(id);
        
        case 
CS_TEAM_CT:
            
CustomCTMenu(id);
    } 


sb123 09-02-2020 12:00

Re: Help for CT or T Custom Menu
 
3 Attachment(s)
Try this custom team menu model plugin

feren02 09-14-2020 23:16

Re: Help for CT or T Custom Menu
 
Hello everyone thanks for all the inputs. It really helped me figure out how to do it and make it work on server side! KUDOS for my learnings via your expertise.

ONE LAST request if granted: When a player for example is in CT, and selected a skin for CT, the moment the player switches to Terrorist Team, the model still appears as is. This goes likewise when a player is on Terrorist Team selecting skin or model then switches to CT Team.

How can I make the skin go off or default when switching teams so they cannot look and appear like the model or skin available from the other teams?

***THE PROBLEM***: For example for CT Team there are three options only to switch models:
1. Assassin
2. Sonic
3. Iron Man

-- A player selects Sonic, when a player switches to Terrorist Team, Sonic still appears, creating confusion to all players because they know Sonic model is only for CT.


Looking forward for all your thoughts.


Regards, keep safe and healthy!


All times are GMT -4. The time now is 21:36.

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