Плагин для выбора режима игры: Кнопки, Свободный, Невидимка... (DeathRun)
Когда Террорист выбирает свободный бег с ножами, но нож дается только Террористу, Контры бегают с USP'ами Помогите плз!!
Вод код .sma: #include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>
new g_is_bought_invis, g_is_bought_free, g_rounds, g_lastround, Float:g_timenobuy, g_MsgSync, g_maxplayers
public plugin_precache()
{
register_plugin("[DeathRun] Mods", "1.0", "[=FaIL=]")
RegisterHam(Ham_Spawn, "player", "runda", 1);
}
public plugin_init()
{
register_clcmd("say /invis", "buy_invis")
register_clcmd("say_team /invis", "buy_invis")
register_clcmd("say /free", "buy_free")
register_clcmd("say_team /free", "buy_free")
register_clcmd("say /button", "buy_button")
register_clcmd("say_team /button", "buy_button")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
RegisterHam(Ham_Use, "func_button", "fw_UseButton")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
g_MsgSync = CreateHudSyncObj()
g_maxplayers = get_maxplayers()
}
public runda(id){
set_task(0.1, "menu", id)
}
public menu(id)
{
if (cs_get_user_team(id) == CS_TEAM_T)
{
new menu = menu_create("\Выбор Раунда","wybor_menu")
menu_additem(menu,"\Кнопки","1",0)
menu_additem(menu,"\Невидимый раунд","2",0)
menu_additem(menu,"\Свободный бег с Ножами","3",0)
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
menu_display(id,menu,0)
}
}
public wybor_menu(id,menu,item)
{
if(item==MENU_EXIT)
{
menu_destroy(menu)
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 : {
client_cmd(id, "say /button")
}
case 2 : {
client_cmd(id, "say /invis")
}
case 3 : {
client_cmd(id, "say /free")
}
}
return PLUGIN_HANDLED
}
public fw_PlayerSpawn_Post(id)
{
if(g_is_bought_free)
{
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
}
}
public fw_TouchWeapon(weapon, id)
{
static model[32]; pev(weapon, pev_model, model, charsmax(model))
if(!is_user_connected(id) || (!g_is_bought_invis && !g_is_bought_free) || (!g_is_bought_free && get_user_team(id) == 2 && (equal(model, "models/w_usp.mdl"))))
return HAM_IGNORED;
return HAM_SUPERCEDE;
}
public event_round_start()
{
g_rounds++
g_is_bought_invis = false
g_is_bought_free = false
g_timenobuy = get_gametime() + 20.0
}
public buy_invis(id)
{
if(!is_user_alive(id))
{
client_print(id, print_chat, "")
return
}
if(get_user_team(id) != 1)
{
client_print(id, print_chat, "Только террористы могут начать Невидимый раунд!")
return
}
if(g_is_bought_free)
{
client_print(id, print_chat, "Невидимки не будет. Ты уже выбрал Свободный бег!")
return
}
if(g_is_bought_invis)
return
if(get_gametime() >= g_timenobuy)
{
client_print(id, print_chat, "Поздно, 20 секунд уже прошло...")
return
}
if(g_lastround > g_rounds)
{
static g_rounds_remaining; g_rounds_remaining = g_lastround - g_rounds
client_print(id, print_chat, "INVIS - будет доступен через %d %s", g_rounds_remaining, g_rounds_remaining == 1 ? "раунд" : "раунда")
return
}
g_is_bought_invis = true
set_pev(id, pev_health, 150.0)
fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
client_print(id, print_chat, "Вы выбрали Невидимый раунд!")
set_hudmessage(20, 255, 20, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "Терорист Выбрал Невидимый Раунд")
g_lastround = g_rounds + 2
}
public buy_free(id)
{
if(!is_user_alive(id))
{
client_print(id, print_chat, "Только живые могут это взять")
return
}
if(get_user_team(id) != 1)
{
client_print(id, print_chat, "")
return
}
if(g_is_bought_free)
return
if(g_is_bought_invis)
{
client_print(id, print_chat, "Свободного бега не будет. Ты выбрал Невидимый раунд!")
return
}
if(get_gametime() >= g_timenobuy)
{
client_print(id, print_chat, "Поздно, 25 секунд уже прошло...")
return
}
if(g_lastround > g_rounds)
{
static g_rounds_remaining; g_rounds_remaining = g_lastround - g_rounds
client_print(id, print_chat, "Free - будет доступен через %d %s", g_rounds_remaining, g_rounds_remaining == 1 ? "раунд" : "раунда")
return
}
g_is_bought_free = true
set_hudmessage(20, 255, 20, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "Терорист выбрал Свободный бег с Ножами")
static i
for (i = 1; i < g_maxplayers; i++)
{
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
}
}
public buy_button(id)
{
if(!is_user_alive(id))
{
client_print(id, print_chat, "Только живые могут это взять")
return
}
if(get_user_team(id) != 1)
{
client_print(id, print_chat, "")
return
}
set_hudmessage(20, 255, 20, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "Терорист выбрал Кнопки ")
}
public fw_UseButton(ent, caller, activator, use_type)
{
if(get_user_team(activator) == 1 && is_user_alive(activator))
{
if(g_is_bought_invis)
client_print(activator, print_center, "Нельзя нажимать кнопки! Ты выбрал невидимку")
else if(g_is_bought_free)
client_print(activator, print_center, "Нельзя нажимать кнопки, сейчас Свободный раунд!")
else
return HAM_IGNORED
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
// From fakemeta_util
stock fm_set_rendering(entity, fx, r, g, b, render, amount)
{
new Float:RenderColor[3]
RenderColor[0] = float(r)
RenderColor[1] = float(g)
RenderColor[2] = float(b)
set_pev(entity, pev_renderfx, fx)
set_pev(entity, pev_rendercolor, RenderColor)
set_pev(entity, pev_rendermode, render)
set_pev(entity, pev_renderamt, float(amount))
}
// Give an item to a player (from fakemeta_util)
stock fm_give_item(id, const item[])
{
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent)) return;
static Float:originF[3]
pev(id, pev_origin, originF)
set_pev(ent, pev_origin, originF)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, ent)
static save
save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, id)
if (pev(ent, pev_solid) != save)
return;
engfunc(EngFunc_RemoveEntity, ent)
}
// Strip user weapons (from fakemeta_util)
stock fm_strip_user_weapons(id)
{
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
if (!pev_valid(ent)) return;
dllfunc(DLLFunc_Spawn, ent)
dllfunc(DLLFunc_Use, ent, id)
engfunc(EngFunc_RemoveEntity, ent)
}
Добавлено (2011-05-13, 19:49)
---------------------------------------------
UP!!!