View Single Post
JusTGo
Veteran Member
Join Date: Mar 2013
Old 02-23-2014 , 10:49   Re: Permanent Field of View change?
Reply With Quote #3

I dont know if this helps this code from zp5:
PHP Code:
/*================================================================================
    
    ----------------------------
    -*- [ZP] Zombie Features -*-
    ----------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <amx_settings_api>
#include <cs_ham_bots_api>
#include <zp50_core>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_ASSASSIN "zp50_class_assassin"
#include <zp50_class_assassin>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

new const bleeding_decals[] = { 99 107 108 184 185 186 187 188 189 }

new Array:
g_bleeding_decals

#define TASK_BLOOD 100
#define ID_BLOOD (taskid - TASK_BLOOD)

#define CS_DEFAULT_FOV 90

new g_IsModCZ
new g_MsgSetFOV

new cvar_zombie_fovcvar_zombie_silentcvar_zombie_bleeding

public plugin_init()
{
    
register_plugin("[ZP] Zombie Features"ZP_VERSION_STRING"ZP Dev Team")
    
    
g_MsgSetFOV get_user_msgid("SetFOV")
    
register_message(g_MsgSetFOV"message_setfov")
    
    
cvar_zombie_fov register_cvar("zp_zombie_fov""110")
    
cvar_zombie_silent register_cvar("zp_zombie_silent""1")
    
cvar_zombie_bleeding register_cvar("zp_zombie_bleeding""1")
    
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
RegisterHamBots(Ham_Killed"fw_PlayerKilled")
    
    
// Check if it's a CZ server
    
new mymod[6]
    
get_modname(mymodcharsmax(mymod))
    if (
equal(mymod"czero")) g_IsModCZ 1
}

public 
plugin_precache()
{
    
// Initialize arrays
    
g_bleeding_decals ArrayCreate(11)
    
    
// Load from external file
    
amx_load_setting_int_arr(ZP_SETTINGS_FILE"Zombie Decals""DECALS"g_bleeding_decals)
    
    
// If we couldn't load from file, use and save default ones
    
new index
    
if (ArraySize(g_bleeding_decals) == 0)
    {
        for (
index 0index sizeof bleeding_decalsindex++)
            
ArrayPushCell(g_bleeding_decalsbleeding_decals[index])
        
        
// Save to external file
        
amx_save_setting_int_arr(ZP_SETTINGS_FILE"Zombie Decals""DECALS"g_bleeding_decals)
    }
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(moduleLIBRARY_NEMESIS) || equal(moduleLIBRARY_ASSASSIN))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
        
    return 
PLUGIN_CONTINUE;
}

// Ham Player Killed Forward
public fw_PlayerKilled(victimattackershouldgib)
{
    
// Remove bleeding task
    
remove_task(victim+TASK_BLOOD)
}

public 
client_disconnect(id)
{
    
// Remove bleeding task
    
remove_task(id+TASK_BLOOD)
}

public 
message_setfov(msg_idmsg_destmsg_entity)
{
    if (!
is_user_alive(msg_entity) || !zp_core_is_zombie(msg_entity) || get_msg_arg_int(1) != CS_DEFAULT_FOV)
        return;
    
    
set_msg_arg_int(1get_msg_argtype(1), get_pcvar_num(cvar_zombie_fov))
}

public 
zp_fw_core_infect_post(idattacker)
{
    
// Set custom FOV?
    
if (get_pcvar_num(cvar_zombie_fov) != CS_DEFAULT_FOV && get_pcvar_num(cvar_zombie_fov) != 0)
    {
        
message_begin(MSG_ONEg_MsgSetFOV_id)
        
write_byte(get_pcvar_num(cvar_zombie_fov)) // angle
        
message_end()
    }
    
    
// Remove previous tasks
    
remove_task(id+TASK_BLOOD)
    
    
// Nemesis Class loaded?
    
if (!LibraryExists(LIBRARY_NEMESISLibType_Library) || !zp_class_nemesis_get(id))
    {
        
// Set silent footsteps?
        
if (get_pcvar_num(cvar_zombie_silent))
            
set_user_footsteps(id1)
        
        
// Zombie bleeding?
        
if (get_pcvar_num(cvar_zombie_bleeding))
            
set_task(0.7"zombie_bleeding"id+TASK_BLOOD__"b")
    }
    
// Assassin Class loaded?
    
else if (!LibraryExists(LIBRARY_ASSASSINLibType_Library) || !zp_class_assassin_get(id))
    {
        
// Set silent footsteps?
        
if (get_pcvar_num(cvar_zombie_silent))
            
set_user_footsteps(id1)
        
        
// Zombie bleeding?
        
if (get_pcvar_num(cvar_zombie_bleeding))
            
set_task(0.7"zombie_bleeding"id+TASK_BLOOD__"b")
    }
    else
    {
        
// Restore normal footsteps?
        
if (get_pcvar_num(cvar_zombie_silent))
            
set_user_footsteps(id0)
    }
}

public 
zp_fw_core_cure_post(idattacker)
{
    
// Restore FOV?
    
if (get_pcvar_num(cvar_zombie_fov) != CS_DEFAULT_FOV && get_pcvar_num(cvar_zombie_fov) != 0)
    {
        
message_begin(MSG_ONEg_MsgSetFOV_id)
        
write_byte(CS_DEFAULT_FOV// angle
        
message_end()
    }
    
    
// Restore normal footsteps?
    
if (get_pcvar_num(cvar_zombie_silent))
        
set_user_footsteps(id0)
    
    
// Remove bleeding task
    
remove_task(id+TASK_BLOOD)
}

// Make zombies leave footsteps and bloodstains on the floor
public zombie_bleeding(taskid)
{
    
// Only bleed when moving on ground
    
if (!(pev(ID_BLOODpev_flags) & FL_ONGROUND) || fm_get_speed(ID_BLOOD) < 80)
        return;
    
    
// Get user origin
    
static Float:originF[3]
    
pev(ID_BLOODpev_originoriginF)
    
    
// If ducking set a little lower
    
if (pev(ID_BLOODpev_bInDuck))
        
originF[2] -= 18.0
    
else
        
originF[2] -= 36.0
    
    
// Send the decal message
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_WORLDDECAL// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
write_byte(ArrayGetCell(g_bleeding_decalsrandom_num(0ArraySize(g_bleeding_decals) - 1)) + (g_IsModCZ 12)) // decal number (offsets +12 for CZ)
    
message_end()
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
    static 
Float:velocity[3]
    
pev(entitypev_velocityvelocity)
    
    return 
floatround(vector_length(velocity));

__________________
JusTGo is offline