Участник
Пользователь
- Сообщения
- 103
- Реакции
- 9
Нужно вставить проверку по флагам. Хочу чтобы командой "give_dragon" (строчка 108) могли пользоваться только вип игроки.
Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// [ Небольшой гайд ]
/* Изначально, спрайт который идет от игрока к модели хука - трясется ( амплитуда ). Если вы хотите это убрать, надо сделать следующее:
Ищем функцию Create_HookEntity, находим там CREATE_BEAMENTS, дефолтно прописано вот так:
CREATE_BEAMENTS(iPlayer, iEntity, g_iszBeamFollowLine, 0, 0, 120, 25, 1, 244, 244, 255, 120, 10);
Изменяем на:
CREATE_BEAMENTS(iPlayer, iEntity, g_iszBeamFollowLine, 0, 0, 120, 25, 0, 244, 244, 255, 120, 10);
*/
// Константа с моделями
new const g_szHookModels[][] =
{
"models/dragonclaw_hook/v_skeleton_hook.mdl",
"models/dragonclaw_hook/p_skeleton_hook.mdl",
"models/dragonclaw_hook/w_skeleton_hook.mdl"
}
// Константа со звуками
new const g_szHookSounds[][] =
{
"weapons/dragonclaw_hook/dragonclaw_draw.wav",
"weapons/dragonclaw_hook/dragonclaw_hitwall.wav",
"weapons/dragonclaw_hook/dragonclaw_slash1.wav",
"weapons/dragonclaw_hook/dragonclaw_hit1.wav",
"weapons/dragonclaw_hook/hook_throw.wav",
"weapons/dragonclaw_hook/hook_impact.wav",
"weapons/dragonclaw_hook/hook_retract_stop.wav"
}
#define WEAPONLIST_NAME "weapon_dchook" // Название txt виапонлиста
#define WEAPONLIST_SPRITE "sprites/dragonclaw_hook/640hud79.spr" // Спрайт для виапонлиста
// Биты
#define SetBit(%0,%1) ((%0) |= (1 << (%1)))
#define ClearBit(%0,%1) ((%0) &= ~(1 << (%1)))
#define IsSetBit(%0,%1) ((%0) & (1 << (%1)))
#define IsNotSetBit(%0,%1) (~(%0) & (1 << (%1)))
//#define ZP_SUPPORT // Поддержка зп мода. Закомментируйте, если не нужно
//#define ZP_EXTRA_ITEM // Возможность купить дк хук. Закомментируйте, если не нужно
//#define ZP_HOOKED_NEM_OR_SURV // Возможность притягивать немезиду/сурвивора ( выжившего ). Закомментируйте, если не нужно
#if defined ZP_SUPPORT
#tryinclude <zombieplague>
#endif
#if defined ZP_EXTRA_ITEM
#define WEAPON_NAME "DragonClaw Hook" // Название айтема
#define WEAPON_COST 25 // Цена айтема
#endif
#define CLASSNAME_DRAGONCLAW "dragonclaw_entity" // Класснейм энтити
#define TIME_RELOAD_HOOK 10.0 // Сколько секунд длится перезарядка способности ( С момента, когда хук до чего-либо докасается )
#define TIME_HOOK_PLAYER 10.0 // Сколько секунд игрок может притягивать игрока
#define HOOK_FLY_SPEED 1500.0 // Скорость хука в полете
#define HOOK_SPEED 700.0 // Скорость притягивания цели
#define KNIFE_DAMAGE 1.0 // Дамаг ножа ( Ваш обычный дамаг множится на дамаг указанный в макросе )
#define TASK_PLAYER_HOOKED 423652 // Task-Id
new g_iBitDragonClawHook, g_iHookEntity, Float: g_flTimeReload[33], g_pPlayerId[33];
new g_iszBeamPointLine, g_iszBeamFollowLine, g_pModelGlass;
#if defined ZP_SUPPORT && defined ZP_EXTRA_ITEM
new g_iItemId
#endif
public plugin_precache()
{
for(new i = 0; i < sizeof g_szHookModels; i++)
engfunc(EngFunc_PrecacheModel, g_szHookModels[i]);
for(new i = 0; i < sizeof g_szHookSounds; i++)
engfunc(EngFunc_PrecacheSound, g_szHookSounds[i]);
new iszWeaponListName[64]; formatex(iszWeaponListName, charsmax(iszWeaponListName), "sprites/%s.txt", WEAPONLIST_NAME)
engfunc(EngFunc_PrecacheGeneric, iszWeaponListName);
engfunc(EngFunc_PrecacheGeneric, WEAPONLIST_SPRITE);
g_iszBeamPointLine = engfunc(EngFunc_PrecacheModel, "sprites/zbeam4.spr");
g_iszBeamFollowLine = engfunc(EngFunc_PrecacheModel, "sprites/dragonclaw_hook/bone_chain.spr");
g_pModelGlass = engfunc(EngFunc_PrecacheModel, "models/rockgibs.mdl");
}
public plugin_init()
{
register_plugin("[AMXX] DragonClaw Hook", "0.0.2", "1331");
register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0");
register_forward(FM_EmitSound, "FMHook_EmitSound_Pre", 0);
RegisterHam(Ham_Item_Deploy, "weapon_knife", "HamHook_ItemDeploy_Post", 1);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "HamHook_PrimaryAttack_Post", 1);
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "HamHook_SecondaryAttack_Post", 1);
RegisterHam(Ham_Touch, "info_target", "HamHook_EntityTouch_Post", 1);
RegisterHam(Ham_TakeDamage, "player", "HamHook_TakeDamage_Pre", 0);
RegisterHam(Ham_Killed, "player", "HamHook_PlayerKilled_Pre", 0);
RegisterHam(Ham_Spawn, "player", "HamHook_PlayerSpawn_Post", 1);
register_clcmd("+dragon", "ClCmd_Drop");
register_clcmd("give_dragon", "Hook_WeaponGive");
register_clcmd(WEAPONLIST_NAME, "ClCmd_HookWeapon");
#if defined ZP_SUPPORT && defined ZP_EXTRA_ITEM
g_iItemId = zp_register_extra_item(WEAPON_NAME, WEAPON_COST, ZP_TEAM_HUMAN);
#endif
}
public plugin_natives()
{
register_native("remove_user_dragonclaw", "Native_RemoveUserDragonClaw", 1);
register_native("is_user_have_dragonclaw", "Native_IsUserHaveDragonClaw", 1);
register_native("give_user_dragonclaw", "Native_GivesUserDragonClaw", 1);
}
public ClCmd_HookWeapon(iPlayer)
{
engclient_cmd(iPlayer, "weapon_knife");
return PLUGIN_HANDLED;
}
#if defined ZP_SUPPORT && defined ZP_EXTRA_ITEM
public zp_extra_item_selected(iPlayer, iItemId)
{
if(iItemId != g_iItemId)
return PLUGIN_HANDLED;
if(IsSetBit(g_iBitDragonClawHook, iPlayer))
{
UTIL_SayText(iPlayer, "!y[!gDOOM-ZONE!y] !tУ вас уже имеется данный предмет");
return ZP_PLUGIN_HANDLED;
}
Hook_WeaponGive(iPlayer);
return PLUGIN_HANDLED;
}
#endif
public Native_RemoveUserDragonClaw(iPlayer)
{
reset_values(iPlayer);
return 1;
}
public Native_IsUserHaveDragonClaw(iPlayer) return IsSetBit(g_iBitDragonClawHook, iPlayer);
public Native_GivesUserDragonClaw(iPlayer)
{
Hook_WeaponGive(iPlayer);
return 1;
}
public Event_RoundStart()
{
new iEntity, iOwner;
while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", CLASSNAME_DRAGONCLAW)))
{
if(!pev_valid(iEntity))
return;
iOwner = pev(iEntity, pev_owner);
UTIL_KillEntity(g_iHookEntity, iOwner)
UTIL_KillBeamPoint(iOwner);
}
for(new pPlayer = 1; pPlayer <= get_maxplayers(); pPlayer++)
{
if(!is_user_connected(pPlayer))
continue;
if(task_exists(pPlayer+TASK_PLAYER_HOOKED))
{
remove_task(pPlayer+TASK_PLAYER_HOOKED);
UTIL_KillBeamPoint(pPlayer);
}
if(IsSetBit(g_iBitDragonClawHook, pPlayer)) g_flTimeReload[pPlayer] = 0.0;
}
}
public Hook_WeaponGive(iPlayer)
{
if(!is_user_alive(iPlayer) || IsSetBit(g_iBitDragonClawHook, iPlayer))
return;
#if defined ZP_SUPPORT
if(zp_get_user_zombie(iPlayer))
return;
#endif
new iEntity = get_pdata_cbase(iPlayer, 373, 5);
if(!pev_valid(iEntity))
return;
SetBit(g_iBitDragonClawHook, iPlayer);
g_flTimeReload[iPlayer] = 0.0;
if(get_user_weapon(iPlayer) == CSW_KNIFE)
ExecuteHamB(Ham_Item_Deploy, iEntity);
UTIL_SetWeaponList(iPlayer, WEAPONLIST_NAME, -1, -1, -1, -1, 2, 1, 29, 0);
}
public HamHook_PlayerKilled_Pre(iVictim, iKiller)
{
reset_values(iVictim);
if(task_exists(iVictim+TASK_PLAYER_HOOKED))
{
remove_task(iVictim+TASK_PLAYER_HOOKED);
UTIL_KillBeamPoint(iVictim);
}
}
public HamHook_ItemDeploy_Post(iEntity)
{
static iPlayer; iPlayer = get_pdata_cbase(iEntity, 41, 4);
static iszViewModel, iszWeaponModel;
if(IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return;
if(iszViewModel || (iszViewModel = engfunc(EngFunc_AllocString, g_szHookModels[0])))
set_pev_string(iPlayer, pev_viewmodel2, iszViewModel);
if(iszWeaponModel || (iszWeaponModel = engfunc(EngFunc_AllocString, g_szHookModels[1])))
set_pev_string(iPlayer, pev_weaponmodel2, iszWeaponModel);
set_pdata_float(iEntity, 46, 0.9, 4);
set_pdata_float(iEntity, 47, 0.9, 4);
set_pdata_float(iEntity, 48, 0.9, 4);
}
public HamHook_PrimaryAttack_Post(iEntity)
{
static iPlayer; iPlayer = get_pdata_cbase(iEntity, 41, 4);
if(IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return HAM_IGNORED;
set_pdata_float(iEntity, 46, 1.19, 4);
set_pdata_float(iEntity, 47, 1.19, 4);
set_pdata_float(iEntity, 48, 1.19, 4);
return HAM_SUPERCEDE;
}
public HamHook_SecondaryAttack_Post(iEntity)
{
static iPlayer; iPlayer = get_pdata_cbase(iEntity, 41, 4);
if(IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return HAM_IGNORED;
set_pdata_float(iEntity, 46, 1.36, 4);
set_pdata_float(iEntity, 47, 1.36, 4);
set_pdata_float(iEntity, 48, 1.36, 4);
return HAM_SUPERCEDE;
}
public HamHook_EntityTouch_Post(iEntity, pPlayer)
{
if(!pev_valid(g_iHookEntity))
return;
new szClassName[64], iOwner, Float: vecOrigin[3];
pev(g_iHookEntity, pev_origin, vecOrigin);
pev(g_iHookEntity, pev_classname, szClassName, charsmax(szClassName));
iOwner = pev(g_iHookEntity, pev_owner);
static Float: flGameTime; flGameTime = get_gametime();
UTIL_KillBeamPoint(g_iHookEntity);
if(equal(szClassName, CLASSNAME_DRAGONCLAW))
{
if(get_user_weapon(iOwner) == CSW_KNIFE)
{
static iWeapon; iWeapon = get_pdata_cbase(iOwner, 373, 5);
set_pdata_float(iWeapon, 46, 0.9, 4);
set_pdata_float(iWeapon, 47, 0.9, 4);
set_pdata_float(iWeapon, 48, 0.9, 4);
UTIL_WeaponAnimation(iOwner, 3);
}
g_flTimeReload[iOwner] = flGameTime + TIME_RELOAD_HOOK;
if(is_user_alive(pPlayer))
{
#if defined ZP_SUPPORT && defined ZP_HOOKED_NEM_OR_SURV
if(zp_get_user_nemesis(pPlayer) || zp_get_user_survivor(pPlayer))
{
client_print(iOwner, print_center, "Нельзя хукнуть %s", zp_get_user_survivor(pPlayer) ? "выжившего" : "немезиду");
UTIL_KillEntity(g_iHookEntity, iOwner);
return;
}
#endif
if(task_exists(pPlayer+TASK_PLAYER_HOOKED))
{
client_print(iOwner, print_center, "Этот игрок уже хукнут!");
UTIL_KillEntity(g_iHookEntity, iOwner);
return;
}
g_pPlayerId[pPlayer] = iOwner;
emit_sound(iOwner, CHAN_AUTO, g_szHookSounds[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
set_task(0.1, "DragonClaw_HookedPlayer", pPlayer+TASK_PLAYER_HOOKED, _, _, "b");
set_task(TIME_HOOK_PLAYER, "DragonClaw_HookedOff", pPlayer+TASK_PLAYER_HOOKED);
CREATE_BEAMENTS(iOwner, pPlayer, g_iszBeamPointLine, 0, 0, 120, 6, 0, 155, 155, 55, 90, 10);
client_print(iOwner, print_center, "Хук удался!");
}
else
{
emit_sound(iOwner, CHAN_AUTO, g_szHookSounds[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
client_print(iOwner, print_center, "Хук не удался!");
CREATE_BREAKMODEL(vecOrigin, _, _, 10, g_pModelGlass, 10, 25, 0);
}
emit_sound(iOwner, CHAN_AUTO, g_szHookSounds[4], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM);
set_pev(g_iHookEntity, pev_flags, FL_KILLME);
}
}
public HamHook_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:fDamage, iBitDamage)
{
if(!is_user_connected(iVictim) || !is_user_connected(iAttacker))
return;
if(IsNotSetBit(g_iBitDragonClawHook, iAttacker) || get_user_weapon(iAttacker) != CSW_KNIFE)
return;
#if defined ZP_SUPPORT
if(zp_get_user_zombie(iAttacker))
return;
#endif
fDamage = fDamage * KNIFE_DAMAGE;
SetHamParamFloat(4, fDamage);
}
// Fix Bug with default Knife Model
public HamHook_PlayerSpawn_Post(iPlayer)
{
if(!is_user_connected(iPlayer) || IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return;
if(get_user_weapon(iPlayer) != CSW_KNIFE)
return;
#if defined ZP_SUPPORT
if(zp_get_user_zombie(iPlayer))
return;
#endif
new iEntity = get_pdata_cbase(iPlayer, 373, 5);
if(!pev_valid(iEntity))
return;
ExecuteHamB(Ham_Item_Deploy, iEntity);
}
public ClCmd_Drop(iPlayer)
{
if(!is_user_alive(iPlayer) || IsNotSetBit(g_iBitDragonClawHook, iPlayer) || get_user_weapon(iPlayer) != CSW_KNIFE)
return;
if(fm_is_aiming_at_sky(iPlayer))
{
UTIL_SayText(iPlayer, "!y[!gDOOM-ZONE!y] !tНельзя запускать хук в небо!");
return;
}
static Float: flGameTime; flGameTime = get_gametime();
if(g_flTimeReload[iPlayer] > flGameTime)
{
UTIL_SayText(iPlayer, "!y[!gDOOM-ZONE!y] !tПодождите! Хук перезаряжается: !g%1.f", g_flTimeReload[iPlayer] - flGameTime);
return;
}
static iWeapon; iWeapon = get_pdata_cbase(iPlayer, 373, 5);
Create_HookEntity(iPlayer);
set_pdata_float(iWeapon, 46, 12.0, 4);
set_pdata_float(iWeapon, 47, 12.0, 4);
set_pdata_float(iWeapon, 48, 12.0, 4);
UTIL_WeaponAnimation(iPlayer, 2);
emit_sound(iPlayer, CHAN_AUTO, g_szHookSounds[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
public Create_HookEntity(iPlayer)
{
static iReference;
if(iReference || (iReference = engfunc(EngFunc_AllocString, "info_target")))
{
g_iHookEntity = engfunc(EngFunc_CreateNamedEntity, iReference);
new Float: vecOrigin[3], Float: vecVelocity[3], Float: vecAngle[3];
pev(iPlayer, pev_origin, vecOrigin);
pev(iPlayer, pev_v_angle, vecAngle);
set_pev(g_iHookEntity, pev_classname, CLASSNAME_DRAGONCLAW);
set_pev(g_iHookEntity, pev_movetype, MOVETYPE_FLY);
set_pev(g_iHookEntity, pev_solid, SOLID_BBOX);
set_pev(g_iHookEntity, pev_owner, iPlayer);
velocity_by_aim(iPlayer, floatround(HOOK_FLY_SPEED), vecVelocity); vecVelocity[2] += 25.0;
set_pev(g_iHookEntity, pev_velocity, vecVelocity);
set_pev(g_iHookEntity, pev_angles, vecAngle);
engfunc(EngFunc_SetModel, g_iHookEntity, g_szHookModels[2]);
engfunc(EngFunc_SetOrigin, g_iHookEntity, vecOrigin);
CREATE_BEAMENTS(iPlayer, g_iHookEntity, g_iszBeamFollowLine, 0, 0, 120, 25, 1, 244, 244, 255, 120, 10);
}
}
public FMHook_EmitSound_Pre(iPlayer, iChannel, szSample[], Float:fVolume, Float:fAttn, iFlag, iPitch)
{
if(!is_user_connected(iPlayer) || IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return FMRES_IGNORED;
if(szSample[8] == 'k' && szSample[9] == 'n' && szSample[10] == 'i' && szSample[11] == 'f' && szSample[12] == 'e')
{
switch(szSample[17])
{
case 'l': emit_sound(iPlayer, iChannel, g_szHookSounds[0], fVolume, fAttn, iFlag, iPitch); // knife_deploy1.wav
case 'w': emit_sound(iPlayer, iChannel, g_szHookSounds[1], fVolume, fAttn, iFlag, iPitch); // knife_hitwall1.wav
case 's': emit_sound(iPlayer, iChannel, g_szHookSounds[2], fVolume, fAttn, iFlag, iPitch); // knife_slash(1-2).wav
case 'b': emit_sound(iPlayer, iChannel, g_szHookSounds[3], fVolume, fAttn, iFlag, iPitch); // knife_stab.wav
default: emit_sound(iPlayer, iChannel, g_szHookSounds[3], fVolume, fAttn, iFlag, iPitch); // knife_hit(1-4).wav
}
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public DragonClaw_HookedPlayer(pPlayer)
{
pPlayer -= TASK_PLAYER_HOOKED;
if(!task_exists(pPlayer+TASK_PLAYER_HOOKED))
return;
#if defined ZP_SUPPORT
if(zp_get_user_zombie(g_pPlayerId[pPlayer]))
{
remove_task(pPlayer+TASK_PLAYER_HOOKED);
UTIL_KillBeamPoint(pPlayer);
}
#endif
new Float: vecOrigin[3], Float: vecVictimOrigin[3], Float: vecVelocity[3];
pev(g_pPlayerId[pPlayer], pev_origin, vecOrigin);
pev(pPlayer, pev_origin, vecVictimOrigin);
new Float: iDistance = get_distance_f(vecOrigin, vecVictimOrigin);
if(iDistance > 1.0)
{
new Float: flTime = iDistance / HOOK_SPEED;
vecVelocity[0] = (vecOrigin[0] - vecVictimOrigin[0]) / flTime;
vecVelocity[1] = (vecOrigin[1] - vecVictimOrigin[1]) / flTime;
vecVelocity[2] = (vecOrigin[2] - vecVictimOrigin[2]) / flTime;
}
else
{
vecVelocity[0] = 0.0;
vecVelocity[1] = 0.0;
vecVelocity[2] = 0.0;
}
set_pev(pPlayer, pev_velocity, vecVelocity);
}
public DragonClaw_HookedOff(pPlayer)
{
pPlayer -= TASK_PLAYER_HOOKED;
if(task_exists(pPlayer+TASK_PLAYER_HOOKED))
{
remove_task(pPlayer+TASK_PLAYER_HOOKED);
UTIL_KillBeamPoint(pPlayer);
}
}
// Other
public client_putinserver(iPlayer)
{
reset_values(iPlayer);
if(task_exists(iPlayer+TASK_PLAYER_HOOKED))
{
remove_task(iPlayer+TASK_PLAYER_HOOKED);
UTIL_KillBeamPoint(iPlayer);
}
}
#if defined ZP_SUPPORT
public zp_user_infected_pre(iPlayer, iInfector) reset_values(iPlayer);
public zp_user_humanized_pre(iPlayer) reset_values(iPlayer);
#endif
public reset_values(iPlayer)
{
if(IsNotSetBit(g_iBitDragonClawHook, iPlayer))
return;
new iEntity = get_pdata_cbase(iPlayer, 373, 5);
if(!pev_valid(iEntity))
return;
ClearBit(g_iBitDragonClawHook, iPlayer);
g_flTimeReload[iPlayer] = 0.0;
if(pev_valid(g_iHookEntity))
{
new iOwner; iOwner = pev(g_iHookEntity, pev_owner);
UTIL_KillEntity(g_iHookEntity, iOwner);
UTIL_KillBeamPoint(iOwner);
}
if(is_user_alive(iPlayer) && get_user_weapon(iPlayer) == CSW_KNIFE)
ExecuteHamB(Ham_Item_Deploy, iEntity);
UTIL_SetWeaponList(iPlayer, "weapon_knife", -1, -1, -1, -1, 2, 1, 29, 0);
}
// Stocks
stock UTIL_KillEntity(iEntity, pPlayer)
{
emit_sound(pPlayer, CHAN_AUTO, g_szHookSounds[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
emit_sound(pPlayer, CHAN_AUTO, g_szHookSounds[4], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM);
set_pev(iEntity, pev_flags, FL_KILLME);
}
stock CREATE_BREAKMODEL(Float:vecOrigin[3], Float:vecSize[3] = {16.0, 16.0, 16.0}, Float:vecVelocity[3] = {25.0, 25.0, 25.0}, iRandomVelocity, pModel, iCount, iLife, iFlags)
{
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
write_byte(TE_BREAKMODEL);
engfunc(EngFunc_WriteCoord, vecOrigin[0]);
engfunc(EngFunc_WriteCoord, vecOrigin[1]);
engfunc(EngFunc_WriteCoord, vecOrigin[2] + 24);
engfunc(EngFunc_WriteCoord, vecSize[0]);
engfunc(EngFunc_WriteCoord, vecSize[1]);
engfunc(EngFunc_WriteCoord, vecSize[2]);
engfunc(EngFunc_WriteCoord, vecVelocity[0]);
engfunc(EngFunc_WriteCoord, vecVelocity[1]);
engfunc(EngFunc_WriteCoord, vecVelocity[2]);
write_byte(iRandomVelocity);
write_short(pModel);
write_byte(iCount); // 0.1's
write_byte(iLife); // 0.1's
write_byte(iFlags); // BREAK_GLASS 0x01, BREAK_METAL 0x02, BREAK_FLESH 0x04, BREAK_WOOD 0x08
message_end();
}
stock UTIL_SetWeaponList(iPlayer, const szWeaponName[], iPrimaryAmmoID, iPrimaryAmmoMaxAmount, iSecondaryAmmoID, iSecondaryAmmoMaxAmount, iSlotID, iNumberInSlot, iWeaponID, iFlags)
{
message_begin(MSG_ONE, 78, _, iPlayer);
write_string(szWeaponName);
write_byte(iPrimaryAmmoID);
write_byte(iPrimaryAmmoMaxAmount);
write_byte(iSecondaryAmmoID);
write_byte(iSecondaryAmmoMaxAmount);
write_byte(iSlotID);
write_byte(iNumberInSlot);
write_byte(iWeaponID);
write_byte(iFlags);
message_end();
}
stock UTIL_SayText(pPlayer, const szMessage[], any:...)
{
new szBuffer[190];
if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
else copy(szBuffer, charsmax(szBuffer), szMessage);
while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
switch(pPlayer)
{
case 0:
{
for(new iPlayer = 1; iPlayer <= get_maxplayers(); iPlayer++)
{
if(!is_user_connected(iPlayer)) continue;
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, iPlayer);
write_byte(iPlayer);
write_string(szBuffer);
message_end();
}
}
default:
{
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, pPlayer);
write_byte(pPlayer);
write_string(szBuffer);
message_end();
}
}
}
stock bool: fm_is_aiming_at_sky(pPlayer)
{
new Float: vecOrigin[3];
fm_get_aiming_position(pPlayer, vecOrigin);
return engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_SKY;
}
stock UTIL_WeaponAnimation(pPlayer, iAnimation)
{
set_pev(pPlayer, pev_weaponanim, iAnimation);
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0.0, 0.0, 0.0}, pPlayer);
write_byte(iAnimation);
write_byte(0);
message_end();
}
stock CREATE_BEAMENTS(pPlayer, pVictim, pSprite, SFrame, EFrame, iLife, iWidth, iNoise, iRed, iGreen, iBlue, iBrightness, iSpeed)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMENTS) // TE_BEAMENTS
write_short(pPlayer)
write_short(pVictim)
write_short(pSprite) // sprite index
write_byte(SFrame) // start frame
write_byte(EFrame) // framerate
write_byte(iLife) // life
write_byte(iWidth) // width
write_byte(iNoise) // noise
write_byte(iRed) // r, g, b
write_byte(iGreen) // r, g, b
write_byte(iBlue) // r, g, b
write_byte(iBrightness) // brightness
write_byte(iSpeed) // speed
message_end()
}
stock UTIL_KillBeamPoint(pPlayer)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_KILLBEAM)
write_short(pPlayer)
message_end()
}
stock fm_get_aiming_position(pPlayer, Float:vecReturn[3])
{
new Float:vecOrigin[3], Float:vecViewOfs[3], Float:vecAngle[3], Float:vecForward[3];
pev(pPlayer, pev_origin, vecOrigin);
pev(pPlayer, pev_view_ofs, vecViewOfs);
xs_vec_add(vecOrigin, vecViewOfs, vecOrigin);
pev(pPlayer, pev_v_angle, vecAngle);
engfunc(EngFunc_MakeVectors, vecAngle);
global_get(glb_v_forward, vecForward);
xs_vec_mul_scalar(vecForward, 8192.0, vecForward);
xs_vec_add(vecOrigin, vecForward, vecForward);
engfunc(EngFunc_TraceLine, vecOrigin, vecForward, DONT_IGNORE_MONSTERS, pPlayer, 0);
get_tr2(0, TR_vecEndPos, vecReturn);
}
stock xs_vec_add(const Float:vec1[], const Float:vec2[], Float:out[])
{
out[0] = vec1[0] + vec2[0];
out[1] = vec1[1] + vec2[1];
out[2] = vec1[2] + vec2[2];
}
stock xs_vec_mul_scalar(const Float:vec[], Float:scalar, Float:out[])
{
out[0] = vec[0] * scalar;
out[1] = vec[1] * scalar;
out[2] = vec[2] * scalar;
}
Вложения
-
21.7 KB Просмотры: 4