Проблема в гранатомёте m79

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
59
Реакции
6
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Ошибка
L 04/02/2018 - 18:53:46: [FAKEMETA] Invalid entity
L 04/02/2018 - 18:53:46: [AMXX] Displaying debug trace (plugin "weapon_m79.amxx")
L 04/02/2018 - 18:53:46: [AMXX] Run time error 10: native error (native "pev")
L 04/02/2018 - 18:53:46: [AMXX] [0] weapon_m79.sma::pfn_touch (line 563)
L 04/02/2018 - 18:53:49: [FAKEMETA] Invalid entity
L 04/02/2018 - 18:53:49: [AMXX] Displaying debug trace (plugin "weapon_m79.amxx")
L 04/02/2018 - 18:53:49: [AMXX] Run time error 10: native error (native "pev")
L 04/02/2018 - 18:53:49: [AMXX] [0] weapon_m79.sma::pfn_touch (line 563)
L 04/02/2018 - 18:54:00: [FAKEMETA] Invalid entity
L 04/02/2018 - 18:54:00: [AMXX] Displaying debug trace (plugin "weapon_m79.amxx")
L 04/02/2018 - 18:54:00: [AMXX] Run time error 10: native error (native "pev")
L 04/02/2018 - 18:54:00: [AMXX] [0] weapon_m79.sma::pfn_touch (line 563)
L 04/02/2018 - 18:54:07: [FAKEMETA] Invalid entity
L 04/02/2018 - 18:54:07: [AMXX] Displaying debug trace (plugin "weapon_m79.amxx")
L 04/02/2018 - 18:54:07: [AMXX] Run time error 10: native error (native "pev")
L 04/02/2018 - 18:54:07: [AMXX] [0] weapon_m79.sma::pfn_touch (line 563)
L 04/02/2018 - 18:54:28: [FAKEMETA] Invalid entity
L 04/02/2018 - 18:54:28: [AMXX] Displaying debug trace (plugin "weapon_m79.amxx")
L 04/02/2018 - 18:54:28: [AMXX] Run time error 10: native error (native "pev")
L 04/02/2018 - 18:54:28: [AMXX] [0] weapon_m79.sma::pfn_touch (line 563)
ОС
Linux
Билд
ReHLDS version: 3.4.0.639-dev
ReGamedll
version: 5.7.0.295-dev
Список метамодулей
meta list
Currently loaded plugins:
description stat pend file vers src load unlod
[ 1] Reunion RUN - reunion_mm_i386. v0.1.0.9 ini Start Never
[ 2] VoiceTranscoder RUN - VoiceTranscoder. v2017RC3 ini ANY
[ 3] AMX Mod X RUN - amxmodx_mm_i386. v1.8.2 ini Start ANY
[ 4] ReSemiclip RUN - resemiclip_mm_i3 v2.3.9 ini ANY
[ 5] WHBlocker RUN - whblocker_mm_i38 v1.5.695 ini ANY
[ 6] Rechecker RUN - rechecker_mm_i38 v2.5 ini ANY
[ 7] MySQL RUN - mysql_amxx_i386. v1.8.2 pl3 ANY
[ 8] SQLite RUN - sqlite_amxx_i386 v1.8.2 pl3 ANY
[ 9] Fun RUN - fun_amxx_i386.so v1.8.2 pl3 ANY
[10] Engine RUN - engine_amxx_i386 v1.8.2 pl3 ANY
[11] FakeMeta RUN - fakemeta_amxx_i3 v1.8.2 pl3 ANY
[12] CStrike RUN - cstrike_amxx_i38 v1.8.2 pl3 ANY
[13] CSX RUN - csx_amxx_i386.so v1.8.2 pl3 ANY
[14] ReCSDM RUN - csdm_amxx_i386.s v3.6 pl3 ANY
[15] Ham Sandwich RUN - hamsandwich_amxx v1.8.2 pl3 ANY
[16] ReAPI RUN - reapi_amxx_i386. v5.5.0.1 pl3 ANY Never
[17] ReAimDetector RUN - reaimdetector_am v0.2.2 pl3 ANY Never
17 plugins, 17 running
Список плагинов
amxx plugins
Currently loaded plugins:
name version author file status
[ 1] FreshBans 1.3.7b kanagava fresh_bans.amxx running
[ 2] fb_forwards 0.1.5 Kanagava & Realu fb_forwards.amx running
[ 3] Admin Loader 3.1 neygomon admin_loader.am running
[ 4] Players MySQL Stats 1.2 neugomon players_mysql_s running
[ 5] Admin Commands 1.8.2 AMXX Dev Team admincmd.amxx running
[ 6] Menus Front-End 1.5 neugomon menufront_enda. running
[ 7] Commands Menu 1.8.2 AMXX Dev Team cmdmenu.amxx running
[ 8] Players Menu 1.7 neugomon players_menu.am running
[ 9] Maps Menu 1.4.1 neugomon mapsmenu.amxx running
[ 10] Plugin Menu 1.8.2 AMXX Dev Team pluginmenu.amxx running
[ 11] Info. Messages 1.8.2 AMXX Dev Team imessage.amxx running
[ 12] TimeLeft 1.8.2 AMXX Dev Team timeleft.amxx running
[ 13] Pause Plugins 1.8.2 AMXX Dev Team pausecfg.amxx running
[ 14] Stats Configuration 1.8.2 AMXX Dev Team statscfg.amxx running
[ 15] ReAimDetector API 0.2.1 ReHLDS Team reaimdetector.a running
[ 16] CSDM Shop menu 1.2 Aki_Lucky csdm_shop11.amx running
[ 17] Top Awards 0.11h Safety1st top_awards.amxx running
[ 18] Map Manager 2.5.61 Mistrick mapmanager.amxx running
[ 19] Bonus_admin_vip 1.3 Shuher bonus_vip_admin running
[ 20] Mode 2x2 2.5re s1lent mode.amxx running
[ 21] Advert Messages 1.22 neygomon adverts.amxx running
[ 22] [182] AC Spectator ESP 17.08.09 SKAJIbnEJIb & Ko ac_esp.amxx running
[ 23] Anti Reklama 1.1 MarcaD anti_reklama.am running
[ 24] Fake Ping 1.1 MeRcyLeZZ/gyxoBk FakePing.amxx running
[ 25] Double Jump 1.0 TBONTB double_jump.amx running
[ 26] Refill Clip On Hs Kill 0.0.2 Vaqtincha weapon_on_ammo. running
[ 27] Team menu 1.1 NobodyInTeam teammenu.amxx running
[ 28] Menu System 0.1.2 serfreeman1337 menuSystem.amxx running
[ 29] DemoRecoder 1.1 neygomon amx_demorec.amx running
[ 30] [ReAPI] AdminFreeLook 1.0 ReHLDS Team adminfreelook.a running
[ 31] Parachute 1.3 Shuher amx_parachute.a running
[ 32] Block grande info 1.0 neygomon BlockGrenadeInf running
[ 33] Block grande info 1.0 neygomon BlockGrenadeInf running
[ 34] Teleport Smoke Grenade 0.1 VEN teleport_smokeg running
[ 35] Ping Control 1.31 neygomon Ping_Control.am running
[ 36] [182] Chat RBS 17.12.18 SKAJIbnEJIb chat_rbs.amxx running
[ 37] Lite VoteBan 1.4 neygomon lite_voteban.am running
[ 38] Lite Vampire + Fade 1.3 neygomon Vampire.amxx running
[ 39] Game Names 1.0 Shuher gamename_change running
[ 40] FM ResetScore 0.1 neygomon Resetscore.amxx running
[ 41] Ultimate Chats Control 4.1 neygomon GagMenu.amxx running
[ 42] Jetpack 1.0 KleeneX jetpack.amxx running
[ 43] WPN Minigun 1.65 CLLlAgOB minigun.amxx running
[ 44] M79 Grenade Launcher 1.2 NiHiLaNTh + Fabu weapon_m79.amxx running
[ 45] [ReAPI] Custom Models 1.6.1 neugomon custom_models.a running
[ 46] FrostNades 2.14 Avalanche frostnades.amxx running
[ 47] Super Bunny Hopper 1.2 Cheesy Peteza bhop.amxx running
[ 48] Battlefield 2: Rank Mo 1.5.3 pRED* bf2rank.amxx running
[ 49] VIP 0.3 wasntme/Caldeum vip.amxx running
[ 50] unknown unknown unknown csdm_shop.amxx running
[ 51] unknown unknown unknown test_ak47g.amxx running
[ 52] unknown unknown unknown test_aklg.amxx running
[ 53] unknown unknown unknown test_aklong.amx running
[ 54] unknown unknown unknown test_awpg.amxx running
[ 55] BazookaAdvanced 1.3 Major Victory test_bazooka.am debug
[ 56] unknown unknown unknown test_hk416.amxx running
[ 57] unknown unknown unknown test_k1ase.amxx running
[ 58] unknown unknown unknown test_m4a1g.amxx running
[ 59] unknown unknown unknown test_m134.amxx running
[ 60] unknown unknown unknown test_mg36xmas.a running
[ 61] unknown unknown unknown test_vsk94.amxx running
[ 62] unknown unknown unknown test_watergun.a running
[ 63] unknown unknown unknown test_xm8.amxx running
[ 64] ReCSDM Main 3.6 ReCSDM Team csdm_main.amxx running
[ 65] ReCSDM Equip 3.6 ReCSDM Team csdm_equip.amxx running
[ 66] ReCSDM Spawns 3.6 ReCSDM Team csdm_spawn_pres running
[ 67] ReCSDM Misc 3.6 ReCSDM Team csdm_misc.amxx running
[ 68] ReCSDM Stripper 3.6 KWo csdm_stripper.a running
[ 69] ReCSDM Protection 3.6 BAILOPAN csdm_protection running
69 plugins, 69 running
Исходный код
В низу
Приветствую всех, люди знающие помогите решить ошибку, плагин походу просит натив которого нету, буду очень благодарен


Код:
#pragma semicolon 1

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

// Plugin info
new const PLUGIN[] = "M79 Grenade Launcher";
new const VERSION[] = "1.2";
new const AUTHOR[] = "NiHiLaNTh + Fabulous";

// Weapon/Grenade models
new const P_MODEL[] = "models/p_m79.mdl";
new const V_MODEL[] = "models/v_m79.mdl";
new const W_MODEL[] = "models/w_m79.mdl";
new const GRENADE_MODEL[] = "models/grenade.mdl";

// Fire sound
new const GRENADE_SHOOT[] = "weapons/m79/m79_fire1.wav";

// Sprites
new const GRENADE_TRAIL[] = "sprites/laserbeam.spr";
new const GRENADE_EXPLOSION[] = "sprites/zerogxplode.spr";
new const GRENADE_SMOKE[] = "sprites/black_smoke3.spr";

// Cached sprite indexes
new sTrail, sExplo, sSmoke;

// Bodyparts and blood
new mdl_gib_flesh, mdl_gib_head, mdl_gib_lung, mdl_gib_spine, blood_drop, blood_spray;

// Pcvar
new pOn, aCost, bCost, pFF;

// Player variables
new g_hasM79[33]; // whether player has M79
new g_FireM79[33]; // player is shooting
new g_canShoot[33]; // player can shoot
new Float:g_last_shot_time[33]; // last shot time
new grenade_count[33]; // current grenade count
new g_restarted; // whether game was restarted

// Message ID's
new g_msgScreenShake, g_msgStatusText;

// Customization(CHANGE HERE)
#define GRENADE_DAMAGE         100
#define GRENADE_RADIUS      300

// Tasks
#define TASK_HUDAMMO        1337
#define ID_HUDAMMO (taskid - TASK_HUDAMMO)

// Plugin precache
public plugin_precache()
{
    // Models
    precache_model(P_MODEL);
    precache_model(V_MODEL);
    precache_model(W_MODEL);
    precache_model(GRENADE_MODEL);
    
    // Sounds
    precache_sound(GRENADE_SHOOT);
    precache_sound("weapons/357_cock1.wav");
    
    // Sprites
    sTrail = precache_model(GRENADE_TRAIL);
    sExplo = precache_model(GRENADE_EXPLOSION);
    sSmoke = precache_model(GRENADE_SMOKE);
    
    // Bodyparts and blood
    blood_drop = precache_model("sprites/blood.spr");
    blood_spray = precache_model("sprites/bloodspray.spr");
    mdl_gib_flesh = precache_model("models/Fleshgibs.mdl");
    mdl_gib_head = precache_model("models/GIB_Skull.mdl");
    mdl_gib_lung = precache_model("models/GIB_Lung.mdl");
    mdl_gib_spine = precache_model("models/GIB_B_Bone.mdl");
}

// Plugin init
public plugin_init()
{
    // Register plugin
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_cvar("zp_m79_version", VERSION, FCVAR_SERVER);
    
    // Client command
    register_clcmd("say /m79", "CmdBuyIt");
    
    //Client command
    //register_clcmd("say /m79_ammo", "CmdBuyAmmo");
    
    // Events
    register_event("CurWeapon", "Event_CurrentWeapon", "be", "1=1");
    register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
    register_event("TextMsg", "Event_GameRestart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in");
    
    // Forwards
    register_forward(FM_SetModel, "fw_SetModel");
    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled");
    register_forward(FM_Touch, "fw_Touch");
    register_forward(FM_CmdStart, "fw_CmdStart");
    register_forward(FM_PlayerPostThink, "fw_PlayerPostThink");
    register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1);
    
    // Messages
    g_msgScreenShake = get_user_msgid("ScreenShake");
    g_msgStatusText = get_user_msgid("StatusText");
    
    // CVARs
    pOn = register_cvar("amx_m79", "1");
    aCost = register_cvar("amx_m79_cost", "160");
    bCost = register_cvar("amx_m79_ammo_cost", "5000");
    pFF = get_cvar_pointer("mp_friendlyfire");
}

// Client connected
public client_connect(id)
{
    // Reset all
    g_hasM79[id] = false;
    g_canShoot[id] = false;
    g_last_shot_time[id] = 0.0;
    grenade_count[id] = 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public cmdDrop(id) {
    if(g_hasM79[id]) {
        new clip,ammo;
        new weapon = get_user_weapon(id,clip,ammo);
        if(weapon == CSW_XM1014) {
            drop_M79(id);
//            entity_set_string(id,EV_SZ_viewmodel,"models/v_knife.mdl")
//            entity_set_string(id,EV_SZ_weaponmodel,"models/p_knife.mdl")
            return PLUGIN_HANDLED;
        }
    }
    return PLUGIN_CONTINUE;
}

public drop_M79(id) {
    if(g_hasM79[id]) {
        new Float:Aim[3],Float:origin[3];
        VelocityByAim(id, 64, Aim);
        entity_get_vector(id,EV_VEC_origin,origin);
        
        origin[0] += Aim[0];
        origin[1] += Aim[1];
        
        new m79 = create_entity("info_target");
        entity_set_string(m79,EV_SZ_classname,"m79_grenade");
        entity_set_model(m79,"models/w_m79.mdl");
        
        entity_set_size(m79,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0});
        entity_set_int(m79,EV_INT_solid,1);
        
        entity_set_int(m79,EV_INT_movetype,6);
        
        entity_set_vector(m79,EV_VEC_origin,origin);
        g_hasM79[id] = 0;
    }   
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Buy attempt
public CmdBuyIt(id)
{
    // Plugin not enabled
    if (get_pcvar_num(pOn) == 0)
        return PLUGIN_CONTINUE;
    
    // Ignore dead
    if (!is_user_alive(id))
        return PLUGIN_CONTINUE;
        
    // Already own
    if (g_hasM79[id] || user_has_weapon(id, CSW_XM1014))
    {
        client_print(id, print_center, "You already own this weapon");
        return PLUGIN_CONTINUE;
    }
    
    // VIP
    if (cs_get_user_vip(id))
    {
        client_print(id, print_center, "You are VIP.You can't buy this weapon");
        return PLUGIN_CONTINUE;
    }
    
    // Not enough money
    if (cs_get_user_money(id) < get_pcvar_num(aCost))
    {
        client_print(id, print_center, "You don't have enough money");
        return PLUGIN_CONTINUE;
    }
    
    // Otherwise all is OK
    give_item(id, "weapon_xm1014");
    cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(aCost));
    engclient_cmd(id,"weapon_knife");
    g_hasM79[id] = true;
    grenade_count[id] = 10;
    set_task(1.1, "hud_init", id+TASK_HUDAMMO, _, _, "b");
    
    return PLUGIN_CONTINUE;
}

//Buy ammo attempt
public CmdBuyAmmo(id)
{
    // Plugin not enabled
    if (get_pcvar_num(pOn) == 0)
        return PLUGIN_CONTINUE;
    
    // Ignore dead
    if (!is_user_alive(id))
        return PLUGIN_CONTINUE;
        
    // Already own
    if (!g_hasM79[id])
    {
        client_print(id, print_center, "You don't have appropriate weapon");
        return PLUGIN_CONTINUE;
    }
    
    // Not enough money
    if (cs_get_user_money(id) < get_pcvar_num(bCost))
    {
        client_print(id, print_center, "You don't have enough money");
        return PLUGIN_CONTINUE;
    }
    
    // Otherwise all is OK
    grenade_count[id] += 10;
    cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(bCost));
    
    return PLUGIN_CONTINUE;

}

// Current weapon player is holding
public Event_CurrentWeapon(id)
{
    // Read weapon ID
    new weaponID = read_data(2);
    
    if (weaponID == CSW_XM1014)
    {
        if (g_hasM79[id])
        {
            // View model
            entity_set_string(id, EV_SZ_viewmodel, V_MODEL);
            
            // Player model
            entity_set_string(id, EV_SZ_weaponmodel, P_MODEL);
        }
    }
}

// New round started
public Event_NewRound(id)
{
    if (g_restarted)
    {
        // Strip from M79 if game have been restarted
        for (new i = 1; i <= get_maxplayers(); i++)
        {
            g_hasM79[i] = false;
            remove_task(i+TASK_HUDAMMO);
        }
        g_restarted = false;
    }
}

// Restart
public Event_GameRestart()
{
    g_restarted = true;
}
        
// Set model       
public fw_SetModel(ent, const model[])
{
    // Invalid entity
    if (!pev_valid(ent))
        return FMRES_IGNORED;
    
    // Not needed model
    if(!equali(model, "models/w_xm1014.mdl"))
        return FMRES_IGNORED;
    
    // Get owner and classname
    new owner = pev(ent, pev_owner);
    new classname[33]; pev(ent, pev_classname, classname, charsmax(classname));
    
    // Entity classname is a weaponbox
    if(equal(classname, "weaponbox"))
    {
        // The weapon owner has a M79
        if(g_hasM79[owner])
        {
            // Strip from m79
            g_hasM79[owner] = false;
            
            // Set world model
            engfunc(EngFunc_SetModel, ent, W_MODEL);
            
            // Touch fix
            set_task(0.1, "touch_fix", owner);
            
            // Remove HUD
            remove_task(owner+TASK_HUDAMMO);
            
            return FMRES_SUPERCEDE;
        }
    }
    
    return FMRES_IGNORED;

}

// Player killed
public fw_PlayerKilled(victim, attacker, shouldgib)
{
    if (g_hasM79[victim])       
    {
        // Reset all
        g_hasM79[victim] = false;
        g_canShoot[victim] = false;
        g_FireM79[victim] = false;
        grenade_count[victim] = 0;
        
        // Remove HUD
        remove_task(victim+TASK_HUDAMMO);
    }
}

public fw_Touch(ent, toucher)
{
    // Invalid ent/toucher
    if(!pev_valid(ent) || !pev_valid(toucher))
        return FMRES_IGNORED;
    
    // Get model, toucherclass, entityclass
    new model[33], toucherclass[33], entityclass[33];
    pev(ent, pev_model, model, charsmax(model));
    pev(ent, pev_classname, entityclass, charsmax(entityclass));
    pev(toucher, pev_classname, toucherclass, charsmax(toucherclass));
    
    // TOucher isn't player and entity isn't weapon
    if (!equali(toucherclass, "player") || !equali(entityclass, "weaponbox"))
        return FMRES_IGNORED;
    
    // Our world model
    if(equali(model, W_MODEL))
    {
        // If allowed to touch
        if(allowed_toucher(toucher))
        {
            // Pick up weapon
            g_hasM79[toucher] = true;
            g_canShoot[toucher] = true;
            g_FireM79[toucher] = false;
        }
    }
    
    return FMRES_IGNORED;
}

// Command start
public fw_CmdStart(id, uc_handle, seed)
{
    // Ignore dead
    if (!is_user_alive(id))
        return FMRES_IGNORED;
        
    // Don't have our weapon   
    if (!g_hasM79[id])
        return FMRES_IGNORED;
        
    // Get ammo, clip, weapon   
    new ammo, clip, weapon = get_user_weapon(id, clip, ammo);
    
    // Not replaced weapon
    if (weapon != 5)
        return FMRES_IGNORED;
        
    // Get buttons   
    new buttons = get_uc(uc_handle, UC_Buttons);
    
    // Attack1 button pressed
    if(buttons & IN_ATTACK)
    {
        g_FireM79[id] = true;
    
        // Remove attack button from their button mask
        buttons &= ~IN_ATTACK;
        set_uc(uc_handle, UC_Buttons, buttons);
    }
    else
        g_FireM79[id] = false;
        
    return FMRES_HANDLED;
}

// Player think after
public fw_PlayerPostThink(id)
{
    // ignore dead
    if (!is_user_alive(id))
        return FMRES_IGNORED;
        
    // Don't have our weapon   
    if (!g_hasM79[id])
        return FMRES_IGNORED;
        
    // Get ammo, clip, and weapon   
    new ammo, clip, weapon = get_user_weapon(id, clip, ammo);
    
    // Not our replaced weapon
    if (weapon != 5)
        return FMRES_IGNORED;
        
    // If player is firing   
    if (g_FireM79[id])
    {
        // Grenades are more or equal to 1
        if (grenade_count[id] >= 1)
        {
            // Player can shoot
            if (get_gametime() - g_last_shot_time[id] > 1.0)
            {
                // Fire!!!
                FireGrenade(id);
                
                // Decrease nade count
                grenade_count[id]--;
                
                // Without this HUD is not updating correctly
                set_task(0.1, "hud_init", id+TASK_HUDAMMO);
                
                // Remember last shot time
                g_last_shot_time[id] = get_gametime();
            }
        }
        else
        {
            // Don't have nades
            client_print(id, print_center, "Out of grenades!");
        }
    }
    
    return FMRES_IGNORED;
}

// Update client data
public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
    // Dead
    if (!is_user_alive(id))
        return FMRES_IGNORED;
        
    // Don't have our weapon   
    if (!g_hasM79[id])
        return FMRES_IGNORED;
    
    // Get ammo, clip, weapon
    new ammo, clip, weapon = get_user_weapon(id, clip, ammo);
    
    // Not replaced weapon
    if (weapon != 5)
        return FMRES_IGNORED;
        
    // Block default sounds   
    set_cd(cd_handle, CD_ID, 0);
    return FMRES_HANDLED;
}

// Fire gremade
public FireGrenade(id)
{
    // Set animation
    set_pev(id, pev_weaponanim, 3);
    
    // Get origin. angle and velocity
    new Float:fOrigin[3], Float:fAngle[3], Float:fVelocity[3];
    pev(id, pev_origin, fOrigin);
    pev(id, pev_v_angle, fAngle);
    
    // Create ent
    new grenade = create_entity("info_target");
    
    // Not grenade
    if (!grenade) return PLUGIN_HANDLED;
    
    // Classname
    entity_set_string(grenade, EV_SZ_classname, "m79_grenade");
    
    // Model
    entity_set_model(grenade, GRENADE_MODEL);
    
    // Origin
    entity_set_origin(grenade, fOrigin);
    
    // Angles
    entity_set_vector(grenade, EV_VEC_angles, fAngle);
    
    // Size
    new Float:MinBox[3] = {-1.0, -1.0, -1.0};
    new Float:MaxBox[3] = {1.0, 1.0, 1.0};
    entity_set_vector(grenade, EV_VEC_mins, MinBox);
    entity_set_vector(grenade, EV_VEC_maxs, MaxBox);
    
    // Interaction
    entity_set_int(grenade, EV_INT_solid, SOLID_SLIDEBOX);
    
    // Movetype
    entity_set_int(grenade, EV_INT_movetype, MOVETYPE_TOSS);
    
    // Owner
    entity_set_edict(grenade, EV_ENT_owner, id);
    
    // Effects
    entity_set_int(grenade, EV_INT_effects, EF_BRIGHTLIGHT);
    
    // Velocity
    VelocityByAim(id, 1500, fVelocity);
    entity_set_vector(grenade, EV_VEC_velocity, fVelocity);
    
    // Launch sound
    emit_sound(grenade, CHAN_WEAPON, GRENADE_SHOOT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    
    // Draw trail
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
    write_byte(TE_BEAMFOLLOW); // Temporary entity ID
    write_short(grenade); // Entity
    write_short(sTrail); // Sprite index
    write_byte(10); // Life
    write_byte(3); // Line width
    write_byte(255); // Red
    write_byte(255); // Green
    write_byte(255); // Blue
    write_byte(255); // Alpha
    message_end();
    
    return PLUGIN_CONTINUE;
}   

// We hit something!!!
public pfn_touch(ptr, ptd)
{
    // If ent is valid
    if (pev_valid(ptr))
    {   
        // Get classnames
        static classname[32], classnameptd[32];
        pev(ptr, pev_classname, classname, 31);
        pev(ptd, pev_classname, classnameptd, 31);
        
        // Our ent
        if(equal(classname, "m79_grenade"))
        {
            // Get it's origin
            new Float:originF[3];
            pev(ptr, pev_origin, originF);
            
            // Draw explosion
            message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
            write_byte(TE_EXPLOSION); // Temporary entity ID
            engfunc(EngFunc_WriteCoord, originF[0]); // engfunc because float
            engfunc(EngFunc_WriteCoord, originF[1]);
            engfunc(EngFunc_WriteCoord, originF[2]);
            write_short(sExplo); // Sprite index
            write_byte(50); // Scale
            write_byte(15); // Framerate
            write_byte(0); // Flags
            message_end();
            
            // Draw smoke
            message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
            write_byte(TE_SMOKE); // Temporary entity IF
            engfunc(EngFunc_WriteCoord, originF[0]); // Pos X
            engfunc(EngFunc_WriteCoord, originF[1]); // Pos Y
            engfunc(EngFunc_WriteCoord, originF[2]); // Pos Z
            write_short(sSmoke); // Sprite index
            write_byte(75); // Scale
            write_byte(15); // Framerate
            message_end();
            
            // Get owner
            new owner = pev(ptr, pev_owner);
            
            // Loop through all players
            for(new i = 0; i < get_maxplayers(); i++)
            {
                // Alive...
                if (is_user_alive(i) == 1)
                {
                    // Start screen shake
                    //message_begin(MSG_ONE, g_msgScreenShake, {0,0,0}, i);
                    //write_short(1<<14); // Amount
                    //write_short(1<<14); // Duration
                    //write_short(1<<14); // Frequency
                    //message_end();
                    
                    // A victim from other team/or FF is allowed
                    if ((cs_get_user_team(owner) != cs_get_user_team(i) || get_pcvar_num(pFF) == 1)||(owner == i))
                    {
                        // Get victims origin and distance
                        new Float:VictimOrigin[3], Float:distance;
                        pev(i, pev_origin, VictimOrigin);
                        
                        // Get distance between victim and epicenter
                        distance = get_distance_f(VictimOrigin, originF);
                        
                        if (distance <= GRENADE_RADIUS)
                        {
                            // Get victims health
                            new health = get_user_health(i);
                            
                            // Still alive
                            if (health - GRENADE_DAMAGE >= 1)
                            {
                                // Set health
                                set_user_health(i, health - GRENADE_DAMAGE);
                            }
                            else
                            {
                                // Silently kill victim
                                user_silentkill(i);
                            
                                // Make death message
                                make_deathmsg(owner, i, 0, "grenade");
                                
                                // Bloody parts
                                create_blood(VictimOrigin);
                                
                                // Set frags
                                set_user_frags(owner, get_user_frags(owner) + 1);
                                
                                // Set deaths
                                cs_set_user_deaths(i, cs_get_user_deaths(i) + 1);
                                
                                // FF kill
                                if (cs_get_user_team(owner) == cs_get_user_team(i))
                                {
                                    // Decrease money
                                    cs_set_user_money(owner, cs_get_user_money(owner) - 500, 1);
                                }
                                else
                                {
                                    // Set new money
                                    cs_set_user_money(owner, cs_get_user_money(owner) + 300, 1);
                                }
                            }
                        }
                    }
                }
                // Destroy ent
                set_pev(ptr, pev_flags, FL_KILLME);
            }
            // We hit breakable
            if (equali(classnameptd, "func_breakable"))
            {
                // Destroy it
                force_use(ptr,ptd);
            }
        }
    }   
}   
    
// HUD init   
public hud_init(taskid)
{
    new HudAmmo[65];
    
    format(HudAmmo, 64, "Grenades Remaining: %d", grenade_count[ID_HUDAMMO]);
    
    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, ID_HUDAMMO);
    write_byte(0);
    write_string(HudAmmo); // Text
    message_end();
    
    /*if (g_hasM79[id])
    {
        set_hudmessage(255, 255, 255, 0.03, 0.93, _, 0.2, 1.0);
        
        ShowSyncHudMsg(id, g_SyncHudAmmo, "Grenades Remaining: %d", grenade_count);
    }
    */
}

// Touch fix
public touch_fix(id)
{
    if (g_hasM79[id])
        g_hasM79[id] = false;
}

// Allowed toucher
stock allowed_toucher(player)
{
    // Already has it
    if (g_hasM79[player])
        return false;
    
    return true;
}

// Blood and bodyparts
stock create_blood(const Float:origin[3])
{
    // Head
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_MODEL);
    engfunc(EngFunc_WriteCoord, origin[0]);
    engfunc(EngFunc_WriteCoord, origin[1]);
    engfunc(EngFunc_WriteCoord, origin[2]);
    write_coord(random_num(-100,100));
    write_coord(random_num(-100,100));
    write_coord(random_num(100,200));
    write_angle(random_num(0,360));
    write_short(mdl_gib_head); // Sprite index
    write_byte(0); // bounce
    write_byte(500); // life
    message_end();
    
    // Spine
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_MODEL);
    engfunc(EngFunc_WriteCoord, origin[0]);
    engfunc(EngFunc_WriteCoord, origin[1]);
    engfunc(EngFunc_WriteCoord, origin[2]);
    write_coord(random_num(-100,100));
    write_coord(random_num(-100,100));
    write_coord(random_num(100,200));
    write_angle(random_num(0,360));
    write_short(mdl_gib_spine);
    write_byte(0); // bounce
    write_byte(500); // life
    message_end();
    
    // Lung
    for(new i = 0; i < random_num(1,2); i++)
    {
        message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
        write_byte(TE_MODEL);
        engfunc(EngFunc_WriteCoord, origin[0]);
        engfunc(EngFunc_WriteCoord, origin[1]);
        engfunc(EngFunc_WriteCoord, origin[2]);
        write_coord(random_num(-100,100));
        write_coord(random_num(-100,100));
        write_coord(random_num(100,200));
        write_angle(random_num(0,360));
        write_short(mdl_gib_lung);
        write_byte(0); // bounce
        write_byte(500); // life
        message_end();
    }
    
    // Parts, 10 times
    for(new i = 0; i < 10; i++)
    {
        message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
        write_byte(TE_MODEL);
        engfunc(EngFunc_WriteCoord, origin[0]);
        engfunc(EngFunc_WriteCoord, origin[1]);
        engfunc(EngFunc_WriteCoord, origin[2]);
        write_coord(random_num(-100,100));
        write_coord(random_num(-100,100));
        write_coord(random_num(100,200));
        write_angle(random_num(0,360));
        write_short(mdl_gib_flesh);
        write_byte(0); // bounce
        write_byte(500); // life
        message_end();
    }
    
    // Blood
    for(new i = 0; i < 3; i++)
    {
        new x,y,z;
        x = random_num(-100,100);
        y = random_num(-100,100);
        z = random_num(0,100);
        for(new j = 0; j < 3; j++)
        {
            message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            write_byte(TE_BLOODSPRITE);
            engfunc(EngFunc_WriteCoord, origin[0]+(x*j));
            engfunc(EngFunc_WriteCoord, origin[1]+(y*j));
            engfunc(EngFunc_WriteCoord, origin[2]+(z*j));
            write_short(blood_spray);
            write_short(blood_drop);
            write_byte(229); // color index
            write_byte(15); // size
            message_end();
        }
    }
}
 
В этой теме было размещено решение! Перейти к решению.

Вложения

Сообщения
1,292
Реакции
2,288
Помог
57 раз(а)
558-ая строка
C++:
-if (pev_valid(ptr))
+if (pev_valid(ptr) && pev_valid(ptd))
 
Последнее редактирование модератором:
Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
P.S: плагин достаточно перегружен клиентскими сообщениями. Если будут overflow или подобного рода сообщения в консоли - не удивляйтесь.
 
Статус
В этой теме нельзя размещать новые ответы.

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

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