Переписать\обновить плагин наземных мин под amxmodx 1.8.2

Статус
В этой теме нельзя размещать новые ответы.

ifx

Сообщения
331
Реакции
153
Помог
4 раз(а)
Есть паблик плагин мин. В нем игрок покупает мины и ставит их на землю. Мины разные: взрывающиеся, замораживающие, ядовитые и тп.
Автора в плагине я не нашел, но судя по ссылкам, написан еще в 2015 году.

Кто-то может переписать код, убрав лишние модули\оптимзировав плагин, может даже с использованием reapi? Также необходимо добавить возможность покупки определенных мин для ВИП-игроков. Только обязательно под 1.8.2 amxmodx

Хочу поставить его на csdm сервер. Готов заплатить, в разумных пределах).

Спасибо

Код:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <xs>
#include <dm_chat>

native dm_get_user_money(id)
native dm_set_user_money(id, set)
native privilege_get(id)

native cs_set_player_maxspeed(id, Float:set, multi)
native Float:cs_get_player_maxspeed(id)

#define Mine_Model "models/test/mine.mdl"
#define Cube_Model "models/test/ice_cube.mdl"
#define Mine_Sprite_Explo "sprites/zerogxplode.spr"
#define Mine_Sprite_Explo2 "sprites/test/holybomb_exp.spr"
#define Mine_Sound_Explo "weapons/explode3.wav"
#define Mine_Sound_Place "weapons/mine_deploy.wav"

new g_iMines_Count[33]
new g_iFrost[33]
new g_burning_duration[33], g_crack_duration[33], g_poison[33]
new g_iLimit[33]
new g_Entity_Mine, g_Entity_Effect
new g_iSPR_Explo, g_iSPR_Explo2
new g_flameSpr,g_smokeSpr
new Float:g_fOldSpeed[33]

new g_iCvar[12]

const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

public plugin_init()
{
    register_menu("Mines Menu", KEYSMENU, "menu_mines")
  
    register_touch("Mine", "player", "touch_mine")
  
    register_think("Ice_Cube", "think_icecube")
  
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  
    RegisterHam(Ham_Killed, "player", "ham_killed_post", 1)
  
    g_iCvar[0]=register_cvar("m_damage", "25")
    g_iCvar[1]=register_cvar("m_damage_fire", "5")
  
    g_iCvar[2]=register_cvar("m_duration_frost", "3")
    g_iCvar[3]=register_cvar("m_duration_fire", "3")
    g_iCvar[4]=register_cvar("m_duration_poison", "3")
    g_iCvar[5]=register_cvar("m_duration_crack", "3")
  
    g_iCvar[6]=register_cvar("m_power_crack", "10")
  
    g_iCvar[7]=register_cvar("m_cost_1", "500")
    g_iCvar[8]=register_cvar("m_cost_2", "500")
    g_iCvar[9]=register_cvar("m_cost_3", "500")
    g_iCvar[10]=register_cvar("m_cost_4", "500")
    g_iCvar[11]=register_cvar("m_cost_5", "500")
}

public plugin_cfg()
{
    g_Entity_Mine = engfunc(EngFunc_AllocString, "func_breakable")
    g_Entity_Effect = engfunc(EngFunc_AllocString, "info_target")
  
    new file[128]; get_localinfo("amxx_configsdir",file,63)
    format(file, 127, "%s/test_cvars/mines.cfg", file)
    if(file_exists(file)) server_cmd("exec %s", file), server_exec()
}

public plugin_precache()
{
    precache_model(Mine_Model)
    precache_model(Cube_Model)
    precache_sound(Mine_Sound_Explo)
    precache_sound(Mine_Sound_Place)
    g_iSPR_Explo=precache_model(Mine_Sprite_Explo)
    g_iSPR_Explo2=precache_model(Mine_Sprite_Explo2)
    g_flameSpr=precache_model("sprites/xffloor.spr")
    g_smokeSpr=precache_model("sprites/black_smoke3.spr")
}

public plugin_natives()
{
    register_native("open_mines_menu", "native_mines_menu", 1)
}

public native_mines_menu(id)
{
    mines_menu_open(id)
}

mines_menu_open(id)
{
    static menu[512], len
    len = 0
          
    len += formatex(menu[len], charsmax(menu) - len, "\r[\yDM\r]\w Наземные мины^n")
    len += formatex(menu[len], charsmax(menu) - len, "\r[\yDM\r]\w Лимит мин: \y%d^n", g_iLimit[id])
    len += formatex(menu[len], charsmax(menu) - len, "\r[\yDM\r]\w Мин установлено: \y%d\d/\y%d^n^n", g_iMines_Count[id], g_iLimit[id])
  
    len += formatex(menu[len], charsmax(menu) - len, (g_iMines_Count[id]<g_iLimit[id]&&dm_get_user_money(id)>=get_pcvar_num(g_iCvar[7]))?"\r[\y1\r]\w Простая \r(%d$)^n":"\r[\y1\r]\d Простая \r(%d$)^n", get_pcvar_num(g_iCvar[7]))
    len += formatex(menu[len], charsmax(menu) - len, (g_iMines_Count[id]<g_iLimit[id]&&dm_get_user_money(id)>=get_pcvar_num(g_iCvar[8]))?"\r[\y2\r]\w Замораживающая \r(%d$)^n":"\r[\y2\r]\d Замораживающая \r(%d$)^n", get_pcvar_num(g_iCvar[8]))
    len += formatex(menu[len], charsmax(menu) - len, (g_iMines_Count[id]<g_iLimit[id]&&dm_get_user_money(id)>=get_pcvar_num(g_iCvar[9]))?"\r[\y3\r]\w Огненная \r(%d$)^n^n":"\r[\y3\r]\d Огненная \r(%d$)^n^n", get_pcvar_num(g_iCvar[9]))
  
    len += formatex(menu[len], charsmax(menu) - len, (privilege_get(id)&&g_iMines_Count[id]<g_iLimit[id]&&dm_get_user_money(id)>=get_pcvar_num(g_iCvar[10]))?"\r[\y4\r]\w Ядовитая \r(%d$)    \y[ADM]^n":"\r[\y4\r]\d Ядовитая \r(%d$)    \y[ADM]^n", get_pcvar_num(g_iCvar[10]))
    len += formatex(menu[len], charsmax(menu) - len, (privilege_get(id)&&g_iMines_Count[id]<g_iLimit[id]&&dm_get_user_money(id)>=get_pcvar_num(g_iCvar[11]))?"\r[\y5\r]\w Галюцинногенная \r(%d$)    \y[ADM]^n":"\r[\y5\r]\d Галюцинногенная  \r(%d$)    \y[ADM]^n", get_pcvar_num(g_iCvar[11]))

    len += formatex(menu[len], charsmax(menu) - len, "^n\r[\y0\r]\w Выход")
  
    show_menu(id, KEYSMENU, menu, -1, "Mines Menu")
}

public menu_mines(id, key)
{
    if(!is_user_alive(id))return
  
    if(g_iMines_Count[id]>=g_iLimit[id]){
        colored_print(id, "!tУстановлено максимум мин!")
        return
    }
  
    if(dm_get_user_money(id)<get_pcvar_num(g_iCvar[7+key])){
        colored_print(id, "!tНедостаточно денег !g(!yнужно %d$!g)", get_pcvar_num(g_iCvar[7+key]))
        return
    }
  
    switch(key)
    {
        case 0:
        {
            mine_spawn(id, 0)
            mines_menu_open(id)
        }
      
        case 1:
        {
            mine_spawn(id, 1)
            mines_menu_open(id)
        }
      
        case 2:
        {
            mine_spawn(id, 2)
            mines_menu_open(id)
        }
      
        case 3:
        {
            if(privilege_get(id)){
                mine_spawn(id, 3)
                mines_menu_open(id)
            }else{
                mines_menu_open(id)
                colored_print(id, "!tДоступно только для !gАдминов!")
                return
            }
        }
      
        case 4:
        {
            if(privilege_get(id)){
                mine_spawn(id, 4)
                mines_menu_open(id)
            }else{
                mines_menu_open(id)
                colored_print(id, "!tДоступно только для !gАдминов!")
                return
            }
        }
    }
    dm_set_user_money(id, dm_get_user_money(id)-get_pcvar_num(g_iCvar[7+key]))
}

public mine_spawn(id, type)
{
    new Float:flOrigin[3]
    pev(id, pev_origin, flOrigin)
  
    if(pev(id, pev_flags) & FL_DUCKING) flOrigin[2]-=16.0
    else flOrigin[2]-=32.0
  
    new i_Ent = engfunc(EngFunc_CreateNamedEntity, g_Entity_Mine)
  
    if(!i_Ent) return
  
    set_pev(i_Ent, pev_classname, "Mine")
    engfunc(EngFunc_SetModel, i_Ent, Mine_Model)
    engfunc(EngFunc_SetOrigin, i_Ent, flOrigin)
  
    set_pev(i_Ent, pev_solid, SOLID_TRIGGER)
    set_pev(i_Ent, pev_movetype, MOVETYPE_TOSS)
  
    engfunc(EngFunc_SetSize, i_Ent, Float:{ -4.0, -4.0, 0.0 }, Float:{ 4.0, 4.0, 3.0 })
  
    set_pev(i_Ent, pev_takedamage, DAMAGE_NO)
  
    set_pev(i_Ent, pev_iuser1, fm_cs_get_user_team(id))
  
    set_pev(i_Ent, pev_iuser2, id)
  
    set_pev(i_Ent, pev_iuser3, type)
  
    if(type==1)  fm_set_rendering(i_Ent, kRenderFxNone, 255,255,255, kRenderTransTexture, 127)
  
    emit_sound(i_Ent, CHAN_WEAPON, Mine_Sound_Place, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  
    g_iMines_Count[id]++
}

public touch_mine(ent, id)
{
    if(!is_user_alive(id))return
    if(fm_cs_get_user_team(id)==pev(ent, pev_iuser1))return
  
    g_iMines_Count[pev(ent, pev_iuser2)]--
  
    switch(pev(ent, pev_iuser3))
    {
        case 0: CreateExplosion(ent, id)
        case 1: CreateExplosion_Frost(ent, id)
        case 2: CreateExplosion_Fire(ent, id)
        case 3: CreateExplosion_Poison(ent, id)
        case 4: CreateExplosion_Crack(ent, id)
    }
          
    engfunc(EngFunc_RemoveEntity, ent)
}

CreateExplosion(ent, victim)
{
    new Float:vOrigin[3]
    pev(ent,pev_origin,vOrigin)

    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord,vOrigin[0])
    engfunc(EngFunc_WriteCoord,vOrigin[1])
    engfunc(EngFunc_WriteCoord,vOrigin[2])
    write_short(g_iSPR_Explo)
    write_byte(30)
    write_byte(15)
    write_byte(0)
    message_end()
  
    ExecuteHamB(Ham_TakeDamage, victim, ent, pev(ent, pev_iuser2), get_pcvar_float(g_iCvar[0]), DMG_BULLET)
}

CreateExplosion_Frost(ent, victim)
{
    new Float:eOrigin[3]
    pev(ent,pev_origin,eOrigin)

    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, eOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord,eOrigin[0])
    engfunc(EngFunc_WriteCoord,eOrigin[1])
    engfunc(EngFunc_WriteCoord,eOrigin[2])
    write_short(g_iSPR_Explo2)
    write_byte(30)
    write_byte(15)
    write_byte(0)
    message_end()
  
    emit_sound(ent, CHAN_WEAPON, Mine_Sound_Explo, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  
    if(g_iFrost[victim])return
    new i_Ent = engfunc(EngFunc_CreateNamedEntity, g_Entity_Effect)
  
    if(!i_Ent) return
  
    set_pev(i_Ent, pev_classname, "Ice_Cube")
    engfunc(EngFunc_SetModel, i_Ent, Cube_Model)
    new Float:vOrigin[3]
    pev(victim,pev_origin,vOrigin)
    if(pev(victim, pev_flags) & FL_DUCKING) vOrigin[2]-=16.0
    else vOrigin[2]-=32.0
    engfunc(EngFunc_SetOrigin, i_Ent, vOrigin)
  
    set_pev(i_Ent, pev_solid, SOLID_TRIGGER)
    set_pev(i_Ent, pev_movetype, MOVETYPE_TOSS)
  
    engfunc(EngFunc_SetSize, i_Ent, Float:{ -0.0, -0.0, 0.0 }, Float:{ 0.0, 0.0, 0.0 })
  
    set_rendering(i_Ent, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255)
  
    set_pev(i_Ent, pev_takedamage, DAMAGE_NO)
  
    set_pev(i_Ent, pev_iuser1, victim)
  
    set_pev(i_Ent, pev_nextthink, get_gametime()+get_pcvar_float(g_iCvar[2]))
  
    set_pev(victim, pev_velocity, Float:{0.0,0.0,0.0})
  
    pev(victim, pev_maxspeed, g_fOldSpeed[victim])
    set_pev(victim, pev_maxspeed, 1.0)
  
    g_iFrost[victim]=i_Ent
}

CreateExplosion_Fire(ent, victim)
{
    new Float:vOrigin[3]
    pev(ent,pev_origin,vOrigin)

    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord,vOrigin[0])
    engfunc(EngFunc_WriteCoord,vOrigin[1])
    engfunc(EngFunc_WriteCoord,vOrigin[2])
    write_short(g_iSPR_Explo)
    write_byte(30)
    write_byte(15)
    write_byte(0)
    message_end()
  
    g_burning_duration[victim] += 5*get_pcvar_num(g_iCvar[3])
  
    if (!task_exists(victim+897))
        set_task(0.2, "burning_flame", victim+897, _, _, "b")
}

CreateExplosion_Poison(ent, victim)
{
    emit_sound(ent, CHAN_WEAPON, Mine_Sound_Explo, VOL_NORM, ATTN_NORM, 0, PITCH_NORM) 
  
    set_pev(victim, pev_velocity, Float:{0.0,0.0,0.0})
  
    pev(victim, pev_maxspeed, g_fOldSpeed[victim])
    set_pev(victim, pev_maxspeed, 100.0)
    g_poison[victim]=1
  
    if (!task_exists(victim+892))
        set_task(get_pcvar_float(g_iCvar[4]), "Task_Poison", victim+892)
    set_rendering(victim, kRenderFxGlowShell, 20, 200, 20, kRenderNormal, 25)
}

CreateExplosion_Crack(ent, victim)
{ 
    emit_sound(ent, CHAN_WEAPON, Mine_Sound_Explo, VOL_NORM, ATTN_NORM, 0, PITCH_NORM) 
  
    g_crack_duration[victim]+=5*get_pcvar_num(g_iCvar[5])
  
    if (!task_exists(victim+898))
        set_task(0.2, "crack_high", victim+898, _, _, "b")
      
    set_pev(victim, pev_velocity, Float:{0.0,0.0,0.0})
}

public Task_Poison(taskid)
{
    new id=taskid-892
  
    set_rendering(id)
    set_pev(id, pev_maxspeed, g_fOldSpeed[id])
    g_poison[id]=0
    remove_task(taskid);
    return;
}

public crack_high(taskid)
{
    new id=taskid-898
  
    if (g_crack_duration[id] < 1)
    {
        remove_task(taskid);
        return;
    }
  
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id)
    write_short((1<<12) * random_num(3, 10)) // amplitude           
    write_short((1<<12) * 2) // duration
    write_short((1<<12) * random_num(3, 10)) // frequency
    message_end()
  
    new Float:cloc[3]
    cloc[0] = cloc[1] = cloc[2] = random_float(-get_pcvar_float(g_iCvar[6]), get_pcvar_float(g_iCvar[6]))
  
    set_pev(id, pev_punchangle, cloc)
  
    g_crack_duration[id]--
}

public burning_flame(taskid)
{
    new id=taskid-897
    static origin[3], flags
    get_user_origin(id, origin)
    flags = pev(id, pev_flags)
  
    if ((flags & FL_INWATER) || g_burning_duration[id] < 1)
    {
        message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
        write_byte(TE_SMOKE) // TE id
        write_coord(origin[0]) // x
        write_coord(origin[1]) // y
        write_coord(origin[2]-50) // z
        write_short(g_smokeSpr) // sprite
        write_byte(random_num(15, 20)) // scale
        write_byte(random_num(10, 20)) // framerate
        message_end()

        remove_task(taskid);
        return;
    }
  
    if (flags & FL_ONGROUND)
    {
        static Float:velocity[3]
        pev(id, pev_velocity, velocity)
        xs_vec_mul_scalar(velocity, 0.5, velocity)
        set_pev(id, pev_velocity, velocity)
    }
  
    static Float:health
    pev(id, pev_health, health)
  
    if (health - get_pcvar_float(g_iCvar[1]) > 0.0)
        set_pev(id, pev_health, health-get_pcvar_float(g_iCvar[1]))

    message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    write_byte(TE_SPRITE) // TE id
    write_coord(origin[0]+random_num(-5, 5)) // x
    write_coord(origin[1]+random_num(-5, 5)) // y
    write_coord(origin[2]+random_num(-10, -5)) // z
    write_short(g_flameSpr) // sprite
    write_byte(random_num(10, 15)) // scale
    write_byte(220) // brightness
    message_end()
  
    g_burning_duration[id]--
}

public think_icecube(ent)
{
    new id=pev(ent, pev_iuser1)
  
    g_iFrost[id]=0
  
    set_pev(id, pev_maxspeed, g_fOldSpeed[id])
  
    engfunc(EngFunc_RemoveEntity, ent)
}

public fw_PlayerPreThink(id) {
    if(!is_user_alive(id)) return
  
    if(g_iFrost[id])
    {
        entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_DUCK)
        entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button) & ~IN_ATTACK)
        set_pev(id, pev_velocity, Float:{0.0,0.0,0.0})
        set_pev(id, pev_maxspeed, 1.0)
        return
    }
    if(g_poison[id]){
        set_pev(id, pev_maxspeed, 100.0)
    }
}

public ham_killed_post(id)
{
    new i_Ent=g_iFrost[id]
    if(i_Ent) set_pev(i_Ent, pev_nextthink, get_gametime())
  
    g_poison[id]=0
}

public client_putinserver(id) g_iLimit[id]=privilege_get(id)?10:8

public client_disconnect(id) if(g_iMines_Count[id]) Cycle_delete_mines(id)

stock Cycle_delete_mines(i_Owner)
{
    new iEnt = 33
    while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "Mine")))
    {
        if(pev(iEnt, pev_iuser2) != i_Owner) continue

        engfunc(EngFunc_RemoveEntity, iEnt)
    }
    g_iMines_Count[i_Owner]=0
}

stock fm_cs_get_user_team(id)
{
    if (pev_valid(id) != 2) return 0
  
    return get_pdata_int(id, 114, 5)
}

stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
    static Float:color[3]
    color[0] = float(r)
    color[1] = float(g)
    color[2] = float(b)
  
    set_pev(entity, pev_renderfx, fx)
    set_pev(entity, pev_rendercolor, color)
    set_pev(entity, pev_rendermode, render)
    set_pev(entity, pev_renderamt, float(amount))
}
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу