Проверенный
Участник
Пользователь
d3m37r4
111111
- Сообщения
- 1,449
- Реакции
- 1,175
- Помог
- 10 раз(а)
Спавн армори энтити
Код:
// ArmouryItemPack, see cssdk_const.inc
spawnArmouryEntity(const ArmouryItemPack:armouryItem, const armouryCount, const Float:origin[3], bool:blockPickup = false) {
new ent = rg_create_entity("armoury_entity");
if(is_nullent(ent)) {
return NULLENT;
}
set_member(ent, m_Armoury_iItem, ArmouryItemPack:armouryItem);
set_member(ent, m_Armoury_iCount, armouryCount);
set_entvar(ent, var_solid, blockPickup ? SOLID_NOT : SOLID_TRIGGER);
engfunc(EngFunc_SetOrigin, ent, origin);
dllfunc(DLLFunc_Spawn ,ent );
return ent;
}
Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>
const Float:SpawnDist = 200.0 // in units
public plugin_init() {
register_concmd("say wpn", "cmdSpawnArmoury");
}
public cmdSpawnArmoury(id) {
new Float:originStart[3];
get_entvar(id, var_origin, originStart);
new Float:originEnd[3]
getCoordPointInDirView(id, SpawnDist, originEnd);
// ArmouryItemPack, see cssdk_const.inc
if(spawnArmouryEntity(ARMOURY_AK47, 1, originEnd) == NULLENT) {
log_amx("Invalid entity index");
}
}
spawnArmouryEntity(const ArmouryItemPack:armouryItem, const armouryCount, const Float:origin[3], bool:blockPickup = false) {
new ent = rg_create_entity("armoury_entity");
if(is_nullent(ent)) {
return NULLENT;
}
set_member(ent, m_Armoury_iItem, ArmouryItemPack:armouryItem);
set_member(ent, m_Armoury_iCount, armouryCount);
set_entvar(ent, var_solid, blockPickup ? SOLID_NOT : SOLID_TRIGGER);
engfunc(EngFunc_SetOrigin, ent, origin);
dllfunc(DLLFunc_Spawn ,ent );
return ent;
}
stock getCoordPointInDirView(const index, const Float:dist, Float:output[3]) {
new Float:start_origins[3];
pev(index, pev_origin, start_origins);
new Float:angles[3];
pev(index, pev_v_angle, angles);
new Float:end_origins[3];
end_origins[0] = start_origins[0] + dist * floatcos(angles[1], degrees) * floatabs(floatcos(angles[0], degrees));
end_origins[1] = start_origins[1] + dist * floatsin(angles[1], degrees) * floatabs(floatcos(angles[0], degrees));
end_origins[2] = start_origins[2];
engfunc(EngFunc_TraceLine, start_origins, end_origins, DONT_IGNORE_MONSTERS, index, 0);
get_tr2(0, TR_vecEndPos, end_origins);
output[0] = end_origins[0];
output[1] = end_origins[1];
output[2] = end_origins[2];
}