Re: plz help
learn coding & define ur kills
PHP Code:
#include <amxmodx> #include <fakemeta_util> #include <cstrike> #include <fun> #define PLUGIN_NAME "Team Selection" #define PLUGIN_VERSION "1.0" #define PLUGIN_AUTHOR "Zapdos1"
// default names new const TeamT[] = "Soviets" // Terrorists new const TeamCT[] = "Allied" // Counter-Terrorists
// default round end sounds new const SoundT[] = "music/downed_intro.mp3" new const SoundCT[] = "music/motor_intro.mp3" new camouflagetime // Some useful code (thx to arkshine) enum { CS_TEAM_UNASSIGNED = 0, CS_TEAM_T, CS_TEAM_CT, CS_TEAM_SPECTATOR }
#define OFFSET_TEAM 114 #define cs_get_user_team(%1) get_pdata_int( %1, OFFSET_TEAM )
#define OFFSET_DEATHS 444 #define cs_get_user_deaths(%1) get_pdata_int( %1, OFFSET_DEATHS ) #define cs_set_user_deaths(%1,%2) set_pdata_int( %1, OFFSET_DEATHS, %2 )
// Some variables new mChooseTeam new showMsg = 0 new camouflagecost new pcTeamT, pcTeamCT, pcSoundT, pcSoundCT, pcUseSounds
public plugin_init() { register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_message(get_user_msgid("ShowMenu"), "message_show_menu"); register_event("ResetHUD", "set_hud", "be");
// change round end message / sounds register_message(get_user_msgid("SendAudio"), "message_sendaudio"); register_message(get_user_msgid("TextMsg"), "message_textmsg");
pcTeamT = register_cvar("ctn_team_t", TeamT); pcTeamCT = register_cvar("ctn_team_ct", TeamCT); pcUseSounds = register_cvar("ctn_use_sounds", "1"); pcSoundT = register_cvar("ctn_sound_t", SoundT); pcSoundCT = register_cvar("ctn_sound_ct", SoundCT); camouflagecost = register_cvar("amx_camouflagecost","1") register_clcmd("chooseteam", "cmdBlock"); camouflagetime = register_cvar("amx_camouflage_time", "20.0")
createMenu();
return PLUGIN_CONTINUE; }
public plugin_precache() { new sound_t[128]; get_pcvar_string(pcSoundT, sound_t, 127);
if (containi(sound_t, ".mp3") != -1) { formatex(sound_t, 127, "sound/%s", sound_t); precache_generic(sound_t); } else precache_sound(sound_t);
new sound_ct[128]; get_pcvar_string(pcSoundCT, sound_ct, 127);
if (containi(sound_ct, ".mp3") != -1) { formatex(sound_t, 127, "sound/%s", sound_ct); precache_generic(sound_ct); } else precache_sound(sound_ct); }
public client_connect(id) { set_user_info(id, "_vgui_menus", "0");
return PLUGIN_CONTINUE; }
public set_hud(id) { showMsg = 0;
set_task(0.2, "fixHUD", id); set_task(0.3, "fadeOut", id);
return PLUGIN_CONTINUE; }
public fixHUD(id) { // some fixes if the HUD is destroyed if (!user_has_weapon(id, CSW_KNIFE)) { fm_set_user_suit(id); fm_give_item(id, "weapon_knife");
switch (cs_get_user_team(id)) { case CS_TEAM_CT: { Submenu(id) } case CS_TEAM_T: { SubMenu1(id) } } } } public SubMenu1(id) { //Note that we will be using a different menu handler new menu = menu_create("\rChoose your soviet", "submenu_handler")
menu_additem(menu, "\wYuri", "1", 0); menu_additem(menu, "\wTesla Trooper", "2", 0); menu_additem(menu, "\wConscript", "3", 0); menu_additem(menu, "\wCrazy Ivan", "4", 0);
menu_display(id, menu, 0); } public submenu_handler(id, menu, item) { if( item == MENU_EXIT ) { menu_destroy(menu);
//If they are still connected if( is_user_connected(id) ) //Lets send them back to the top menu SubMenu1(id)
return PLUGIN_HANDLED; }
new data[6], iName[64]; new access, callback; menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
switch(key) { case 1: { give_item(id, "weapon_usp") client_print(id, print_chat, "You are the Yuri Commander"); } case 2: { give_item (id, "weapon_knife") client_print(id, print_chat, "You are now a Tesla Trooper"); } case 3: { give_item (id, "weapon_ak47") client_print(id, print_chat, "You are now a Conscript"); } case 4: { give_item (id, "weapon_c4") client_print(id, print_chat, "You are now the Crazy Ivan"); } }
menu_destroy(menu); return PLUGIN_HANDLED; } public Submenu(id) { new menu = menu_create("\rChoose your allied", "submenu_handlere")
menu_additem(menu, "\wTanya", "1", 0); menu_additem(menu, "\wGI", "2", 0); menu_additem(menu, "\wSpy", "3", 0); menu_additem(menu, "\wChrono Legionaire", "4", 0); menu_display(id, menu, 0); } public submenu_handlere(id, menu, item) { if( item == MENU_EXIT ) { menu_destroy(menu);
//If they are still connected if( is_user_connected(id) ) //Lets send them back to the top menu SubMenu1(id)
return PLUGIN_HANDLED; }
new data[6], iName[64]; new access, callback; menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
switch(key) { case 1: { give_item (id, "weapon_deagle") client_print(id, print_chat, "You are Tanya"); } case 2: { give_item (id, "weapon_m249") client_print(id, print_chat, "You are now a GI"); } case 3: { give_camouflage(id) give_item (id, "weapon_ak47") client_print(id, print_chat, "You are now a Spy"); } case 4: { give_item (id, "weapon_mac10") client_print(id, print_chat, "You are now a Chrono Legionaire "); } }
menu_destroy(menu); return PLUGIN_HANDLED; } public give_camouflage(id) { new cost = get_pcvar_num(camouflagecost) if(kills >= cost && is_user_alive(id)) { set_user_frags(id, kills - cost) camouflage[id] = true Timer = get_pcvar_num(camouflagetime) set_task(0.1, "timer_camouflage", id) ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "GIVECAMOUFLAGE") if(cs_get_user_team(id) == CS_TEAM_T) { cs_set_user_model(id, MODEL_TT[random(MODELS_TT)]) } else if(cs_get_user_team(id) == CS_TEAM_CT) { cs_set_user_model(id, MODEL_CT[random(MODELS_CT)]) } } else if(!(is_user_alive(id))) { ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "DEAD") } else if(randomn[id] == true) { if (is_user_alive(id)) { camouflage[id] = true Timer = get_pcvar_num(camouflagetime) set_task(0.1, "timer_camouflage", id) ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "GIVECAMOUFLAGE") if(cs_get_user_team(id) == CS_TEAM_T) { cs_set_user_model(id, MODEL_TT[random(MODELS_CT)]) } else if(cs_get_user_team(id) == CS_TEAM_CT) { cs_set_user_model(id, MODEL_CT[random(MODELS_TT)]) } } } else { ColorChat(id, RED, "^x01[AMXX] ^x03%L", id, "NOBUY") } return PLUGIN_CONTINUE } public timer_camouflage(id) { --Timer set_task(1.0, "timer_camouflage", id) set_hudmessage(255, 255, 255, 0.01, 0.3, 0, 6.0, 12.0) show_hudmessage(id, "Camouflage: [%i]",Timer) if(!(is_user_alive(id))) { remove_task(id) set_task(0.1, "remove_camouflage", id) } if(Timer < 1) { remove_task(id) set_hudmessage(255, 255, 255, 0.01, 0.3, 0, 6.0, 3.0) show_hudmessage(id, "Camouflage: [Over]") set_task(0.1, "remove_camouflage", id) } } // end of a round public round_end_msg(params[]) { if (showMsg == 1) { client_print(0, print_center, "%s win!", params); set_task(0.2, "round_end_msg", 0, params, 128); } }
public message_textmsg(msg_id, msg_dest, msg_entity) { static message[20]; get_msg_arg_string(2, message, sizeof message - 1);
if (equali(message, "#Soviets_Win")) { new params[128]; formatex(params, 127, "%s", TeamT);
showMsg = 1; set_task(0.2, "round_end_msg", 0, params, 128);
return PLUGIN_HANDLED; }
if (equali(message, "#Allieds_Win")) { new params[128]; formatex(params, 127, "%s", TeamCT);
showMsg = 1; set_task(0.2, "round_end_msg", 0, params, 128);
return PLUGIN_HANDLED; }
return PLUGIN_CONTINUE; }
// sounds public fadeOut() { client_cmd(0, "cd fadeout"); return PLUGIN_CONTINUE; }
public message_sendaudio(msg_id, msg_dest, msg_entity) { static message[20]; get_msg_arg_string(2, message, sizeof message - 1);
if (equali(message, "%!MRAD_terwin")) { if (get_pcvar_num(pcUseSounds) == 1) { new sound_t[128]; get_pcvar_string(pcSoundT, sound_t, 127);
if (containi(sound_t, ".mp3") != -1) client_cmd(0, "mp3 play sound/%s", sound_t); else client_cmd(0, "spk %s", sound_t); } return PLUGIN_HANDLED; }
if (equali(message, "%!MRAD_ctwin")) { if (get_pcvar_num(pcUseSounds) == 1) { new sound_ct[128]; get_pcvar_string(pcSoundCT, sound_ct, 127);
if (containi(sound_ct, ".mp3") != -1) client_cmd(0, "mp3 play sound/%s", sound_ct); else client_cmd(0, "spk %s", sound_ct); } return PLUGIN_HANDLED; } return PLUGIN_CONTINUE; }
public cmdBlock(id) { menu_display(id, mChooseTeam, 0); return PLUGIN_HANDLED; }
// custom menu public createMenu() { mChooseTeam = menu_create("Choose Team", "mh_ChooseTeam");
new t_name[128], ct_name[128]; get_pcvar_string(pcTeamT, t_name, 127); get_pcvar_string(pcTeamCT, ct_name, 127);
menu_additem(mChooseTeam, t_name, "ma_ChooseTeam", ADMIN_ALL); menu_additem(mChooseTeam, ct_name, "ma_ChooseTeam", ADMIN_ALL); menu_additem(mChooseTeam, "Spectator", "ma_ChooseTeam", ADMIN_ALL);
return PLUGIN_CONTINUE; }
public message_show_menu(msgid, dest, id) { if (get_user_team(id) || task_exists(id)) return PLUGIN_CONTINUE;
static team_select[] = "#Team_Select"; static menu_text_code[sizeof team_select];
get_msg_arg_string(4, menu_text_code, sizeof menu_text_code - 1);
if (!equal(menu_text_code, team_select)) return PLUGIN_CONTINUE;
set_task(0.1, "force_team_join", id);
return PLUGIN_HANDLED; }
public force_team_join(id) { engclient_cmd(id, "jointeam", "6"); menu_display(id, mChooseTeam, 0);
return PLUGIN_CONTINUE; }
public mh_ChooseTeam(id, menu, item) { switch (item) { case -3: return PLUGIN_HANDLED;
case 0: if (cs_get_user_team(id) == CS_TEAM_T) return PLUGIN_HANDLED; case 1: if (cs_get_user_team(id) == CS_TEAM_CT) return PLUGIN_HANDLED;
case 2: if (cs_get_user_team(id) == CS_TEAM_SPECTATOR) return PLUGIN_HANDLED; }
if (cs_get_user_team(id) != CS_TEAM_SPECTATOR) { user_silentkill(id); cs_set_user_deaths(id, cs_get_user_deaths(id) - 1); }
cs_set_user_team(id, item + 1, random_num(1, 5));
// restart round if there is only one player (excl. bot) new Players[32], playerCount; get_players(Players, playerCount, "c");
if (playerCount == 1) server_cmd("sv_restart 1");
return PLUGIN_HANDLED; }
|