Версия: 0.0.1
Описание:
Плагин позволяет игроку играть от 3-его лица. Очень удобен для мода SoccerJam. Для включения режима от 3-его лица игроку нужно прописать в чате команду /cam.
Код:
- Код: Выделить всё
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#define VERSION "0.0.1"
#define MAX_PLAYERS 32
#define m_flWait 42
#define USE_TOGGLE 3
new g_iCam[MAX_PLAYERS+1]
new g_iMaxPlayers
public plugin_init()
{
register_plugin("Camera View", VERSION, "ConnorMcLeod")
register_clcmd("say /cam", "cam")
register_think("trigger_camera", "Camera_Think")
g_iMaxPlayers = get_maxplayers()
}
public cam( id )
{
if( !is_user_alive(id) )
{
return
}
new iEnt = g_iCam[id]
if( !is_valid_ent(iEnt) )
{
iEnt = create_entity("trigger_camera")
entity_set_int(iEnt, EV_INT_spawnflags, SF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION)
DispatchSpawn(iEnt)
set_pdata_float(iEnt, m_flWait, 999999.0, 4)
g_iCam[id] = iEnt
}
ExecuteHam( Ham_Use, iEnt, id, id, USE_TOGGLE, 1.0)
entity_set_int(id, EV_INT_flags, entity_get_int(id, EV_INT_flags) & ~FL_FROZEN)
cs_reset_user_maxspeed(id)
}
public client_disconnect(id)
{
new iEnt = g_iCam[id]
if( !is_valid_ent(iEnt) )
{
g_iCam[id] = 0
remove_entity(iEnt)
}
}
cs_reset_user_maxspeed(id)
{
new Float:flMaxSpeed;
switch ( get_user_weapon(id) )
{
case CSW_SG550, CSW_AWP, CSW_G3SG1 : flMaxSpeed = 210.0;
case CSW_M249 : flMaxSpeed = 220.0;
case CSW_AK47 : flMaxSpeed = 221.0;
case CSW_M3, CSW_M4A1 : flMaxSpeed = 230.0;
case CSW_SG552 : flMaxSpeed = 235.0;
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS : flMaxSpeed = 240.0;
case CSW_P90 : flMaxSpeed = 245.0;
case CSW_SCOUT : flMaxSpeed = 260.0;
default : flMaxSpeed = 250.0;
}
set_user_maxspeed(id, flMaxSpeed);
}
get_cam_owner(iEnt)
{
static id
for(id = 1; id<=g_iMaxPlayers; id++)
{
if( g_iCam[id] == iEnt )
{
return id
}
}
return 0
}
public Camera_Think(entid)
{
new id = get_cam_owner(entid);
if( !id )
{
return
}
static Float:origin[3], Float:angle[3], Float:vBack[3];
entity_get_vector( id, EV_VEC_origin, origin );
entity_get_vector( id, EV_VEC_v_angle, angle );
angle_vector( angle, ANGLEVECTOR_FORWARD, vBack );
origin[2] += 20.0;
origin[0] += (-vBack[0] * 150.0);
origin[1] += (-vBack[1] * 150.0);
origin[2] += (-vBack[2] * 150.0);
entity_set_origin( entid, origin );
entity_set_vector( entid, EV_VEC_angles, angle );
entity_set_float(entid, EV_FL_nextthink, get_gametime())
}
Утверждено. //Leonidddd