AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] Menu (https://forums.alliedmods.net/showthread.php?t=152787)

natkemon 03-14-2011 04:14

[help] Menu
 
Hi

How do i make it so that when i type /class and then pick a class... it won't change class until the person dies? death?

fysiks 03-14-2011 13:15

Re: [help] Menu
 
You hold the selection until they die/spawn.

natkemon 03-14-2011 18:50

Re: [help] Menu
 
umm. how do I do that? can you please give me an example

fysiks 03-14-2011 20:07

Re: [help] Menu
 
Store the class in a global variable then use it to set the class on death (or when ever you want the new class to take affect; not sure if you can wait until spawn because I don't know how that part works).

natkemon 03-15-2011 03:14

Re: [help] Menu
 
sry i'm lost.. here is my code and its really messy.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <nvault>

#define PLUGIN "COD4"
#define VERSION "2.4"
#define AUTHOR "FreeStylez`"



new const RANK[55] = 
{
    
0,
    
300
    
1200
    
2700
    
4800
    
7500
    
10800,
    
14700,
    
19200,
    
24300,
    
30000,
    
36500,
    
43800,
    
51900,
    
60800,
    
70500,
    
81000,
    
92300
    
104400,
    
117300,
    
131000,
    
145500,
    
160800,
    
176900,
    
193800,
    
211500,
    
230000,
    
249300,
    
269400,
    
290300,
    
312400,
    
335700,
    
360200,
    
385900,
    
412800,
    
440900,
    
470200,
    
500700,
    
532400,
    
565300,
    
599400,
    
634700,
    
671200,
    
708900,
    
747800,
    
829200,
    
871700,
    
915400,
    
960300,
    
1006400,
    
1053700,
    
1102200,
    
1151900,
    
1202800
}
new const 
RANKNAMES[55][] =
{
    
"Private First Class",
    
"Private First Class I",
    
"Private First Class II"
    
"Lance Corporal"
    
"Lance Corporal I",
    
"Lance Corporal II"
    
"Corporal"
    
"Corporal I",
    
"Corporal II"
    
"Sargeant",
    
"Sargeant I"
    
"Sargeant II"
    
"Staff Sargeant"
    
"Staff Sargeant I"
    
"Straff Sargeant II",
    
"Gunnery Sargeant"
    
"Gunnery Sargeant I"
    
"Gunnery Sargeant II"
    
"Master Sargeant",
    
"Master Sargeant I",
    
"Master Sargeant II",
    
"Master Gunnery Sergeant"
    
"Master Gunnery Sergeant I"
    
"Master Gunnery Sergeant II",
    
"2nd Lieutenant",
    
"2nd Lieutenant I",
    
"2nd Lieutenant II"
    
"1st Lieutenant"
    
"1st Lieutenant I"
    
"1st Lieutenant II"
    
"Captain",
    
"Captain I"
    
"Captain II"
    
"Major"
    
"Major I"
    
"Major II",
    
"Lt. Colonel",
    
"Lt. Colonel I",
    
"Lt. Colonel II",
    
"Colonel",
    
"Colonel I"
    
"Colonel II"
    
"Brigadier General",
    
"Brigadier General I",
    
"Brigadier General II"
    
"Major General",
    
"Major General I"
    
"Major General II",
    
"Lieutenant General",
    
"Lieutenant General I",
    
"Lieutenant General II"
    
"General",
    
"General I"
    
"General II"
    
"Commander"
}

new 
gXP[33], gLevel[33];
new 
XP_KillXP_Hs;
new 
g_vault;
new 
g_status_sync;





 public 
plugin_init()
 {
        
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("cod4_version"VERSIONFCVAR_SERVER);
    
set_cvar_string("cod4version"VERSION);
    
    
register_event("DeathMsg""eDeath""a");
    
register_event("RoundTime""on_round""b")

 
    
XP_Kill register_cvar("cod_kill""100");
    
XP_Hs register_cvar("cod_hs","200");
    
g_vault nvault_open("CODRANK");
    
    
    
register_clcmd"say /class""ClassMenu" );
 }
 
 public 
plugin_precache()
{
    
precache_sound("cod4/levelup.wav");
    
precache_sound("cod4/start.wav");
    
}




 public 
eDeath() 
{
    new 
attacker read_data(1);
    new 
victim read_data(2);
    new 
headshot read_data(3);
    
    new 
gXPKill get_pcvar_num(XP_Kill);
    new 
gXPHs get_pcvar_num(XP_Hs);
 
    if( 
victim == attacker )
    return 
PLUGIN_HANDLED;
 
    if( !
headshot && victim != attacker )
    {
        
gXP[attacker] += gXPKill
        set_hudmessage
(2552550, -1.0, -0.57)
        
show_hudmessage(attacker"+%d"gXPKill)
    }
    else if( 
headshot && victim != attacker )
    {
        
gXP[attacker] += gXPHs
        set_hudmessage
(2552550, -1.0, -0.57)
        
show_hudmessage(attacker"+%d"gXPHs)
    }
    
    
 
 
    
CheckLevel(attacker)
    
SaveData(attacker)
    return 
PLUGIN_CONTINUE
}

public 
CheckLevel(id)
{
    if( 
gXP[id] >= RANK[gLevel[id]] )
    {
    
client_cmd(id"spk cod4/levelup.wav")
    Print(
id"Congratulations! You have been promoted to:^x01 %s^x03."RANKNAMES[gLevel[id]+1]);
    
gLevel[id]++;
    }
    
}


public 
on_round(id)
{
    
    
client_cmd(id"spk cod4/start.wav")
    
LoadData(id)
    
CheckLevel(id)
    
ClassMenu(id)
    
ShowHud(id)
}

public 
ShowHud(id)
{
    if(
is_user_connected(id) && id>&& !is_user_bot(id))
    {

        new 
message[56]
        new 
next_level gLevel[id]+1
        
if(next_level>49)
            
next_level 49
        format
(message55,"[COD:MW2] Title: %s | XP: %d/%d "RANKNAMES[gLevel[id]], gXP[id], RANK[gLevel[id]])
        
        
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusText"), {000}, id);
        
write_byte(0);
        
write_string(message);
        
message_end();
    
        }
    
set_task(0.3"ShowHud"id)    
}


public 
client_connect(id)
{
    
    
LoadData(id);

}

public 
client_disconnect(id)
{
    
SaveData(id);
    
gXP[id] = 0;
    
gLevel[id] = 0;
}



public 
SaveData(id)
{
    new 
key[32], data[101];
    
get_user_authid(idkey31);
    
format(data100"%d %d"gXP[id], gLevel[id]);
    
nvault_set(g_vaultkeydata);
}

public 
LoadData(id)
{
    new 
key[32], data[101];
    
get_user_authid(idkey31);
    
nvault_get(g_vaultkeydata100);

    new 
szXP[32], szLevel[32];
    
parse(dataszXP31szLevel31);
 
    
gXP[id] = str_to_num(szXP);
    
gLevel[id] = str_to_num(szLevel);
}

public 
plugin_end()
{
    
nvault_close(g_vault);
}



 
 public 
ClassMenu(id)
 {
    new 
menu menu_create("\yChoose a class:""menu_handler")

    
menu_additem(menu"\w Grenadier [Assault]""1"0);
    
menu_additem(menu"\w First Recon [Sub Machine]""2"0);
    
menu_additem(menu"\w Overwatch [Light Machine Gun]""3"0);
    
menu_additem(menu"\w Scout Sniper""4"0);
    
menu_additem(menu"\w Riot Squad ""5"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
    
 


    

 }
 
 public 
menu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1//grenadier
        
{
    
give_item(id"weapon_knife");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_aug");
    
give_item(id"ammo_556nato");
    
give_item(id"ammo_556nato");
    
give_item(id"ammo_556nato");
    
give_item(id"weapon_glock18");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
client_print(idprint_chat"You are now a Grenadier");
        
        }
        case 
2// First Recon
        
{
    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
give_item(id"weapon_ump45");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"weapon_glock18");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");

    
client_print(idprint_chat"You are now an Assault");
        }
        case 
3//Overwatch
    
{
    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
give_item(id"weapon_hegrenade");
    
give_item(id"weapon_glock18");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"weapon_m3");
    
give_item(id"ammo_buckshot");
    
give_item(id"ammo_buckshot");
    
give_item(id"ammo_buckshot");
    
give_item(id"ammo_buckshot");
    
give_item(id"ammo_buckshot");

    
client_print(idprint_chat"You are now a Overwatch");
    }
        case 
4//Scout Snipist
    
{
    
give_item(id"weapon_knife");
    
give_item(id"weapon_hegrenade");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_scout");
    
give_item(id"ammo_762nato");
    
give_item(id"weapon_deagle");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
    
client_print(idprint_chat"You are now a Scout Snipist");
    }
        case 
5//Riot Control
    
{
    
give_item(id"weapon_knife");
    
give_item(id"weapon_hegrenade");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_knife");
    
give_item(id"weapon_shield");
    
give_item(id"weapon_deagle");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"ammo_50ae");
    
give_item(id"weapon_glock18");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"ammo_9mm");
    
give_item(id"weapon_usp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
give_item(id"ammo_45acp");
    
    
client_print(idprint_chat"You are now a Riot Controller");
    }
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 }
 
 
 
 
 
 Print(
iPlayer, const sMsg[], any:...)
{
    static 
iiPlayer iPlayer get_Player();
    if ( !
) return;
 
    new 
sMessage[256];
    new 
len formatex(sMessagesizeof(sMessage) - 1"^x04[COD:MW2]^x03 ");
    
vformat(sMessage[len], sizeof(sMessage) - lensMsg3);
    
sMessage[192] = '^0';
  
    static 
msgid_SayText;
    if ( !
msgid_SayText msgid_SayText get_user_msgid("SayText");
 
    new const 
team_Names[][] =
 {
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
 
};
  
    new 
sTeam get_user_team(i);
 
    
team_Info(iiPlayerteam_Names[0]);
  
    
message_begin(iPlayer MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_SayText_iPlayer);
    
write_byte(i);
    
write_string(sMessage);
    
message_end();
  
    
team_Info(iiPlayerteam_Names[sTeam]);
}
team_Info(receiversendersTeam[])
{
    static 
msgid_TeamInfo;
    if ( !
msgid_TeamInfo msgid_TeamInfo get_user_msgid("TeamInfo");
 
    
message_begin(sender MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_TeamInfo_sender);
    
write_byte(receiver);
    
write_string(sTeam);
    
message_end();
}
get_Player()
{
    for ( new 
iPlayer 1iPlayer <= get_maxplayers(); iPlayer++ )
    {
    return 
iPlayer;
 }
 
    return 
0;
}
 
 
//////////FROM BF2 RANK MOD//////////

public on_ShowStatus(id//called when id looks at someone
{
    new 
name[32], pid read_data(2);
    new 
pidrank gLevel[pid];

    
get_user_name(pidname31);
    new 
color1 0color2 0;

    if (
get_user_team(pid) == 1)
        
color1 255;
    else
        
color2 255        
    
    set_hudmessage
(color1100color2, -1.00.3500.0120.0);    
    
ShowSyncHudMsg(idg_status_sync"%s^nLevel: %d"namegLevel[pidrank]+1);
}

public 
on_HideStatus(id)
{
    
ClearSyncHud(idg_status_sync);



DA 03-15-2011 08:56

Re: [help] Menu
 
Try to add this line to the eDeath() function:

PHP Code:

ClassMenu(victim); 



All times are GMT -4. The time now is 14:39.

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