Я хочу, чтобы точка(Crosshairs) RPG светила в соответствии с цветом команды.
Красный для красной команды.
Синий цвет для синей команды.
![](images/warning.png)
shel писал(а): > И как тебе норм код читается ?
Я привык писать в одну строчку уже, да, норм
Модераторы: Subb98, liFe iS GoOD
Lev писал(а):По-моему цвет лазерного пятна зашит в спрайте, т.к. в коде цвет не задается. Надо сделать спрайты разного цвета. Далее надо перехватить спавн лазерного пятна и заменить в нем модель.
К сожалению, почему-то, разработчики ХЛ сделали установку класса ентити не в Spawn, а после. Поэтому, немного упячный способ:
1. Зарегать хуки
- Код: Выделить всё
RegisterHam(Ham_Spawn, "laser_spot", "laser_spot_spawn", 1);
g_weapon_rpg_postframe_hook = RegisterHam(Ham_Item_PostFrame, "weapon_rpg", "weapon_rpg_postframe");
2. В laser_spot_spawn запоминаем ентитю. Включаем хук g_weapon_rpg_postframe_hook.
3. В weapon_rpg_postframe получаем игрока этого рокетлаунчера и для запомненой ентити меняем модель на нужную. Отключаем хук g_weapon_rpg_postframe_hook.
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "RPG Trail Color"
#define VERSION "1.1"
#define AUTHOR "LetiLetiLepestok"
#define XO_WEAPON 4
#define m_pPlayer 28
#define LASER_SPOT_RED "sprites/laserspot_red.spr"
#define LASER_SPOT_BLUE "sprites/laserspot_blue.spr"
new g_Colors[5][3] =
{
{0, 0, 0},
{80, 80, 255}, // color for team 1
{255, 80, 80}, // color for team 2
{200, 200, 80}, // color for team 3
{80, 200, 80} // color for team 4
}
new g_iLaserSpot = FM_NULLENT;
new HamHook:g_iHamHook_RPG_PostFrame;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_message(SVC_TEMPENTITY, "MessageTempEntity");
RegisterHam(Ham_Spawn, "laser_spot", "HamHook_LaserSpotSpawn_Post", true);
DisableHamForward(g_iHamHook_RPG_PostFrame = RegisterHam(Ham_Item_PostFrame, "weapon_rpg", "HamHook_RPG_PostFrame", false));
}
public plugin_precache()
{
precache_model(LASER_SPOT_RED);
precache_model(LASER_SPOT_BLUE);
}
public HamHook_LaserSpotSpawn_Post(iLaserSpot)
{
g_iLaserSpot = iLaserSpot;
EnableHamForward(g_iHamHook_RPG_PostFrame);
}
public HamHook_RPG_PostFrame(iItem)
{
static iPlayer;
// iPlayer = pev(iItem, pev_owner);
iPlayer = get_pdata_cbase(iItem, m_pPlayer, XO_WEAPON);
if(!is_user_connected(iPlayer))
return HAM_IGNORED;
switch(get_user_team(iPlayer))
{
case 1: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_RED);
case 2: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_BLUE);
}
DisableHamForward(g_iHamHook_RPG_PostFrame);
return HAM_IGNORED;
}
public MessageTempEntity()
{
if(get_msg_arg_int(1) != TE_BEAMFOLLOW)
return PLUGIN_CONTINUE
new classname[32]
new ent = get_msg_arg_int(2)
pev(ent, pev_classname, classname, 31)
if(!equal(classname, "rpg_rocket"))
return PLUGIN_CONTINUE
new team = get_user_team(pev(ent, pev_owner))
if(team <= 0 || team > 4)
{
team = 0
g_Colors[0][0] = random_num(0, 255)
g_Colors[0][1] = random_num(0, 255)
g_Colors[0][2] = random_num(0, 255)
}
set_msg_arg_int(6, ARG_BYTE, g_Colors[team][0])
set_msg_arg_int(7, ARG_BYTE, g_Colors[team][1])
set_msg_arg_int(8, ARG_BYTE, g_Colors[team][2])
set_msg_arg_int(9, ARG_BYTE, 255)
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "RPG Trail Color"
#define VERSION "1.1"
#define AUTHOR "LetiLetiLepestok"
#define XO_WEAPON 4
#define m_pPlayer 28
#define LASER_SPOT_RED "sprites/laserspot_blue.spr"
#define LASER_SPOT_BLUE "sprites/laserspot_red.spr"
new g_Colors[5][3] =
{
{0, 0, 0},
{80, 80, 255}, // color for team 1
{255, 80, 80}, // color for team 2
{200, 200, 80}, // color for team 3
{80, 200, 80} // color for team 4
}
new g_iLaserSpot = FM_NULLENT;
new HamHook:g_iHamHook_RPG_PostFrame;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_message(SVC_TEMPENTITY, "MessageTempEntity");
RegisterHam(Ham_Spawn, "laser_spot", "HamHook_LaserSpotSpawn_Post", true);
DisableHamForward(g_iHamHook_RPG_PostFrame = RegisterHam(Ham_Item_PostFrame, "weapon_rpg", "HamHook_RPG_PostFrame", false));
}
public plugin_precache()
{
precache_model(LASER_SPOT_RED);
precache_model(LASER_SPOT_BLUE);
}
public HamHook_LaserSpotSpawn_Post(iLaserSpot)
{
g_iLaserSpot = iLaserSpot;
EnableHamForward(g_iHamHook_RPG_PostFrame);
}
public HamHook_RPG_PostFrame(iItem)
{
if(pev_valid(g_iLaserSpot))
{
static iPlayer;
// iPlayer = pev(iItem, pev_owner);
iPlayer = get_pdata_cbase(iItem, m_pPlayer, XO_WEAPON);
if(!is_user_connected(iPlayer))
return HAM_IGNORED;
switch(get_user_team(iPlayer))
{
case 1: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_BLUE);
case 2: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_RED);
}
}
DisableHamForward(g_iHamHook_RPG_PostFrame);
return HAM_IGNORED;
}
public MessageTempEntity()
{
if(get_msg_arg_int(1) != TE_BEAMFOLLOW)
return PLUGIN_CONTINUE
new classname[32]
new ent = get_msg_arg_int(2)
pev(ent, pev_classname, classname, 31)
if(!equal(classname, "rpg_rocket"))
return PLUGIN_CONTINUE
new team = get_user_team(pev(ent, pev_owner))
if(team <= 0 || team > 4)
{
team = 0
g_Colors[0][0] = random_num(0, 255)
g_Colors[0][1] = random_num(0, 255)
g_Colors[0][2] = random_num(0, 255)
}
set_msg_arg_int(6, ARG_BYTE, g_Colors[team][0])
set_msg_arg_int(7, ARG_BYTE, g_Colors[team][1])
set_msg_arg_int(8, ARG_BYTE, g_Colors[team][2])
set_msg_arg_int(9, ARG_BYTE, 255)
return PLUGIN_CONTINUE
}
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <hl>
#define PLUGIN "RPG Trail Color"
#define VERSION "1.1"
#define AUTHOR "LetiLetiLepestok"
#define XO_WEAPON 4
#define m_pPlayer 28
#define LASER_SPOT_RED "sprites/laserspot_blue.spr"
#define LASER_SPOT_BLUE "sprites/laserspot_red.spr"
new g_Colors[5][3] =
{
{0, 0, 0},
{80, 80, 255}, // color for team 1
{255, 80, 80}, // color for team 2
{200, 200, 80}, // color for team 3
{80, 200, 80} // color for team 4
}
new g_iLaserSpot = FM_NULLENT;
new HamHook:g_iHamHook_RPG_PostFrame;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_message(SVC_TEMPENTITY, "MessageTempEntity");
RegisterHam(Ham_Spawn, "laser_spot", "HamHook_LaserSpotSpawn_Post", true);
DisableHamForward(g_iHamHook_RPG_PostFrame = RegisterHam(Ham_Item_PostFrame, "weapon_rpg", "HamHook_RPG_PostFrame", false));
}
public plugin_precache()
{
precache_model(LASER_SPOT_RED);
precache_model(LASER_SPOT_BLUE);
}
public HamHook_LaserSpotSpawn_Post(iLaserSpot)
{
g_iLaserSpot = iLaserSpot;
EnableHamForward(g_iHamHook_RPG_PostFrame);
}
public HamHook_RPG_PostFrame(iItem)
{
if(pev_valid(g_iLaserSpot))
{
static iPlayer;
// iPlayer = pev(iItem, pev_owner);
iPlayer = get_pdata_cbase(iItem, m_pPlayer, XO_WEAPON);
if(!is_user_connected(iPlayer))
return HAM_IGNORED;
switch(hl_get_user_team(iPlayer))
{
case TEAM_RED: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_RED);
case TEAM_BLUE: engfunc(EngFunc_SetModel, g_iLaserSpot, LASER_SPOT_BLUE);
}
}
DisableHamForward(g_iHamHook_RPG_PostFrame);
return HAM_IGNORED;
}
public MessageTempEntity()
{
if(get_msg_arg_int(1) != TE_BEAMFOLLOW)
return PLUGIN_CONTINUE
new classname[32]
new ent = get_msg_arg_int(2)
pev(ent, pev_classname, classname, 31)
if(!equal(classname, "rpg_rocket"))
return PLUGIN_CONTINUE
//new team = get_user_team(pev(ent, pev_owner))
new team = hl_get_user_team(pev(ent, pev_owner))
if(team <= 0 || team > 4)
{
team = 0
g_Colors[0][0] = random_num(0, 255)
g_Colors[0][1] = random_num(0, 255)
g_Colors[0][2] = random_num(0, 255)
}
set_msg_arg_int(6, ARG_BYTE, g_Colors[team][0])
set_msg_arg_int(7, ARG_BYTE, g_Colors[team][1])
set_msg_arg_int(8, ARG_BYTE, g_Colors[team][2])
set_msg_arg_int(9, ARG_BYTE, 255)
return PLUGIN_CONTINUE
}
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 16