added funmaps

This commit is contained in:
zino
2023-11-23 11:22:53 +01:00
parent bf8a8e24fd
commit 05ff9d34e6
792 changed files with 49515 additions and 60 deletions

View File

@@ -0,0 +1,75 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#include <amxmodx>
#include <fun> //we want fun running for extra compatibility
#include <engine> //we want engine running for extra compatibility
#include <fakemeta>
#include <translator>
#define AMXMODX_NOAUTOLOAD
#include <cstrike>
#include <sqlx>
#define MOD_NORMAL 0
#define MOD_CSTRIKE 1
new g_ModType = MOD_NORMAL
new g_MaxPlayers
#include "core.sma"
#include "vexdum.sma"
#include "mysql.sma"
public plugin_init()
{
register_plugin("AMX Mod Compat Engine", "1.76.rc4", "AMXX Dev Team")
g_MaxPlayers = get_maxplayers()
VexdUM_Register()
}
public plugin_natives()
{
set_module_filter("Plugin_ModuleFilter")
set_native_filter("Plugin_NativeFilter")
new modname[32]
get_modname(modname, 31)
if (equali(modname, "cstrike") || equali(modname, "czero"))
{
g_ModType = MOD_CSTRIKE
}
Core_Natives()
VexdUM_Natives()
MySQL_Natives()
}
public Plugin_ModuleFilter(const module[])
{
if (equali(module, "sqlx") || equali(module, "cstrike"))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public Plugin_NativeFilter(const name[], index, trap)
{
if (!trap)
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_connect(id)
{
VexdUM_ClientConnect(id)
}

View File

@@ -0,0 +1,301 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
Core_Natives()
{
/* implicit compatibility */
register_native("VelocityByAim", "__VelocityByAim")
register_native("load_translations", "__load_translations")
register_native("is_user_authorized", "__is_user_authorized")
register_native("get_user_money", "__get_user_money")
register_native("set_user_money", "__set_user_money")
register_native("angle_to_vector", "__angle_to_vector")
register_native("fabs", "__fabs")
register_native("asin", "__asin")
register_native("sin", "__sin")
register_native("sinh", "__sinh")
register_native("acos", "__acos")
register_native("cos", "__cos")
register_native("cosh", "__cosh")
register_native("atan", "__atan")
register_native("atan2", "__atan2")
register_native("tan", "__tan")
register_native("tanh", "__tanh")
register_native("fsqroot", "__fsqroot")
register_native("fpower", "__fpower")
register_native("flog", "__flog")
register_native("get_cmdaccess", "__get_cmdaccess")
register_native("is_translated", "__is_translated")
register_native("get_plugincmdsnum", "__get_plugincmdsnum")
register_native("get_plugincmd", "__get_plugincmd")
register_native("get_plugincvarsnum", "__get_plugincvarsnum")
register_native("get_plugincvar", "__get_plugincvar")
register_native("is_module_running", "__is_module_running")
register_native("is_plugin_running", "__is_plugin_running")
}
public __VelocityByAim(plid, num)
{
new iIndex
new iVelocity
new Float:vRetValue[3]
iIndex = get_param(1)
iVelocity = get_param(2)
new ret = velocity_by_aim(iIndex, iVelocity, vRetValue)
set_array_f(3, vRetValue, 3)
return ret
}
public __load_translations(plid, num)
{
static file[255]
get_string(1, file, 254)
return load_translations(file)
}
public __is_user_authorized(plid, num)
{
return is_user_authorized(get_param(1))
}
public __get_user_money(plid, num)
{
return get_user_money(get_param(1))
}
public __set_user_money(plid, num)
{
return set_user_money(get_param(1), get_param(2), get_param(3))
}
public __angle_to_vector(plid, num)
{
new Float:angle[3]
new Float:vRetValue[3]
get_array_f(1, angle, 3)
new ret = angle_vector(angle, get_param(2), vRetValue)
set_array_f(3, vRetValue, 3)
return ret
}
public Float:__fabs(plid, num)
{
new Float:value = get_param_f(1)
return floatabs(value)
}
public Float:__asin(plid, num)
{
new Float:value = get_param_f(1)
return floatasin(value, radian)
}
public Float:__sin(plid, num)
{
new Float:value = get_param_f(1)
return floatsin(value, radian)
}
public Float:__sinh(plid, num)
{
new Float:value = get_param_f(1)
return floatsinh(value, radian)
}
public Float:__acos(plid, num)
{
new Float:value = get_param_f(1)
return floatacos(value, radian)
}
public Float:__cos(plid, num)
{
new Float:value = get_param_f(1)
return floatcos(value, radian)
}
public Float:__cosh(plid, num)
{
new Float:value = get_param_f(1)
return floatcosh(value, radian)
}
public Float:__atan(plid, num)
{
new Float:value = get_param_f(1)
return floatatan(value, radian)
}
public Float:__atan2(plid, num)
{
new Float:value1 = get_param_f(1)
new Float:value2 = get_param_f(2)
return floatatan2(value1, value2, radian)
}
public Float:__tan(plid, num)
{
new Float:value = get_param_f(1)
return floattan(value, radian)
}
public Float:__tanh(plid, num)
{
new Float:value = get_param_f(1)
return floattanh(value, radian)
}
public Float:__fsqroot(plid, num)
{
new Float:value = get_param_f(1)
return floatsqroot(value)
}
public Float:__fpower(plid, num)
{
new Float:value = get_param_f(1)
new Float:exponent = get_param_f(2)
return floatpower(value, exponent)
}
public Float:__flog(plid, num)
{
new Float:value = get_param_f(1)
new Float:base = get_param_f(2)
return floatlog(value, base)
}
//get_cmdaccess(cmd[], accessflags[], len)
public __get_cmdaccess(plid, num)
{
static command[32], accessflags[32]
new ret
get_string(1, command, 31)
if ((ret=get_cmdaccess(command, accessflags, 31)))
{
set_string(2, accessflags, get_param(3))
}
return ret
}
public __is_translated(plid, num)
{
static string[512]
get_string(1, string, 511)
return is_translated(string)
}
public __get_plugincmdsnum(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return get_plugincmdsnum(plugin, get_param(2))
}
public __get_plugincmd(plid, num)
{
static plugin[64]
static command[32]
static accessflags[32]
static info[512]
get_string(1, plugin, 63)
if (get_plugincmd(plugin,
get_param(2),
command,
31,
accessflags,
31,
info,
511,
get_param(9),
get_param(10)))
{
set_string(3, command, get_param(4))
set_string(5, accessflags, get_param(6))
set_string(7, info, get_param(8))
return 1
}
return 0
}
public __get_plugincvarsnum(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return get_plugincvarsnum(plugin, get_param(2))
}
//stock get_plugincvar(plugin[], index, cvar[], len1, value[], len2, flags=0)
public __get_plugincvar(plid, num)
{
static plugin[64]
static cvar[32]
static value[512]
get_string(1, plugin, 63)
if (get_plugincvar(plugin, get_param(2), cvar, 31, value, 511, get_param(7)))
{
set_string(3, cvar, get_param(4))
set_string(5, value, get_param(6))
return 1
}
return 0
}
public __is_module_running(plid, num)
{
static module[64]
get_string(1, module, 63)
return is_module_running(module)
}
public __is_plugin_running(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return is_plugin_running(plugin)
}

View File

@@ -0,0 +1,415 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#define MAX_CONNECTIONS 64
new Connections[MAX_CONNECTIONS+1] = {0}
new ConnectionTracker[MAX_CONNECTIONS+1] = {0}
new ConnectionErrors[MAX_CONNECTIONS+1][255]
new ConnectionQueries[MAX_CONNECTIONS+1] = {0}
new QueryPositions[MAX_CONNECTIONS+1]
MySQL_Natives()
{
register_native("mysql_connect", "__mysql_connect")
register_native("mysql_query", "__mysql_query")
register_native("mysql_error", "__mysql_error")
register_native("mysql_close", "__mysql_close")
register_native("mysql_nextrow", "__mysql_nextrow")
register_native("mysql_getfield", "__mysql_getfield")
register_native("mysql_getresult", "__mysql_getresult")
register_native("mysql_affected_rows", "__mysql_affected_rows")
register_native("mysql_num_fields", "__mysql_num_fields")
register_native("mysql_num_rows", "__mysql_num_rows")
register_native("mysql_field_name", "__mysql_field_name")
register_native("mysql_insert_id", "__mysql_insert_id")
}
MakeConnectionIndex(Handle:cn)
{
if (ConnectionTracker[0])
{
new idx = ConnectionTracker[ConnectionTracker[0]]
ConnectionTracker[0]--
Connections[idx] = _:cn
return idx
} else {
Connections[0]++
if (Connections[0] > MAX_CONNECTIONS)
{
return 0
}
Connections[Connections[0]] = _:cn
return Connections[0]
}
return 0
}
Handle:GetConnectionIndex(idx)
{
if (idx < 1 || idx > MAX_CONNECTIONS || !Connections[idx])
{
return Empty_Handle
}
return Handle:Connections[idx]
}
FreeConnectionIndex(idx)
{
Connections[idx] = 0
ConnectionTracker[0]++
ConnectionTracker[ConnectionTracker[0]] = idx
ConnectionErrors[idx][0] = 0
ConnectionQueries[idx] = 0
QueryPositions[idx] = 0
}
/*
* Unlike the previous this does not check for a matching connection.
* Unless a plugin breaks I'm not going to take that step.
*/
public __mysql_connect(plid, num)
{
static host[255], user[128], pass[128], dbname[128], error[512]
new errcode
get_string(1, host, 254)
get_string(2, user, 127)
get_string(3, pass, 127)
get_string(4, dbname, 127)
new Handle:info = SQL_MakeDbTuple(host, user, pass, dbname)
new Handle:cn = SQL_Connect(info, errcode, error, 511)
if (cn == Empty_Handle)
{
set_string(5, error, get_param(6))
return 0
}
SQL_FreeHandle(info)
new idx = MakeConnectionIndex(cn)
if (idx == 0)
{
set_string(5, "Reached max unclosed connections", get_param(6))
return 0
}
ConnectionQueries[idx] = 0
return idx
}
public __mysql_query(plid, num)
{
static queryString[4096]
new cn_idx = get_param(1)
new Handle:cn
if ((cn=GetConnectionIndex(cn_idx)) == Empty_Handle)
{
return 0
}
vdformat(queryString, 4095, 2, 3)
new Handle:query = SQL_PrepareQuery(cn, "%s", queryString)
if (!SQL_Execute(query))
{
SQL_QueryError(query, ConnectionErrors[cn_idx], 254)
SQL_FreeHandle(query)
return 0
}
if (ConnectionQueries[cn_idx])
{
SQL_FreeHandle(Handle:ConnectionQueries[cn_idx])
}
ConnectionQueries[cn_idx] = _:query
QueryPositions[cn_idx] = 0
return 1
}
public __mysql_error(plid, num)
{
new cn_idx = get_param(1)
if (Connections[cn_idx] < 1)
{
static error[255]
format(error, 254, "Invalid connection index: %d", cn_idx)
set_string(2, error, get_param(3))
return 1
}
set_string(2, ConnectionErrors[cn_idx], get_param(3))
return 1
}
public __mysql_close(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query != Empty_Handle)
{
SQL_FreeHandle(query)
}
SQL_FreeHandle(cn)
FreeConnectionIndex(cn_idx)
return 1
}
public __mysql_nextrow(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (QueryPositions[cn_idx] != 0)
{
SQL_NextRow(query)
}
if (SQL_MoreResults(query))
{
return ++QueryPositions[cn_idx]
}
return 0
}
public __mysql_getresult(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (!SQL_MoreResults(query))
{
return 0
}
static name[64]
get_string(2, name, 63)
new column = SQL_FieldNameToNum(query, name)
if (column == -1)
{
log_error(AMX_ERR_NATIVE, "Invalid column name: %s", name)
return 0
}
switch (num)
{
case 2:
{
return SQL_ReadResult(query, column)
}
case 3:
{
new Float:fma
SQL_ReadResult(query, column, fma)
set_param_byref(3, _:fma)
}
case 4:
{
static str[2048]
SQL_ReadResult(query, column, str, 2047)
set_string(3, str, get_param_byref(4))
}
}
return 1
}
public __mysql_getfield(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (!SQL_MoreResults(query))
{
return 0
}
switch (num)
{
case 2:
{
return SQL_ReadResult(query, get_param(2)-1)
}
case 3:
{
new Float:fma
SQL_ReadResult(query, get_param(2)-1, fma)
set_param_byref(3, _:fma)
}
case 4:
{
static str[2048]
SQL_ReadResult(query, get_param(2)-1, str, 2047)
set_string(3, str, get_param_byref(4))
}
}
return 1
}
public __mysql_affected_rows(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_AffectedRows(query)
}
public __mysql_num_fields(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_NumColumns(query)
}
public __mysql_insert_id(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_GetInsertId(query)
}
public __mysql_num_rows(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_NumResults(query)
}
public __mysql_field_name(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
new column = get_param(2) - 1
if (column < 0 || column >= SQL_NumColumns(query))
{
return 0
}
new field[64]
SQL_FieldNumToName(query, column, field, 63)
set_string(3, field, get_param(4))
return 1
}

View File

@@ -0,0 +1,730 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#include <VexdUM_const>
#include <VexdUM_stock>
/* Forwards */
new g_FwdTouch
new g_FwdThink
new g_FwdSpawn
new g_FwdClientPreThink
new g_FwdClientPostThink
new g_FwdEmitSound
new g_FwdEmitAmbientSound
new g_FwdSetModel
new g_FwdTraceLine
new g_FwdSetCliKeyValue
new g_FwdKeyValue
new g_PlayerModels[33][64]
new g_PlayerModeled[33]
/* User Messages */
new g_msgDamage
new g_msgDeathMsg
new g_msgScoreInfo
new g_LastTrace = 0
VexdUM_Register()
{
/* Fakemeta Hooks */
register_forward(FM_EmitSound, "Hook_FM_EmitSound")
register_forward(FM_EmitAmbientSound, "Hook_FM_EmitAmbientSound")
register_forward(FM_SetModel, "Hook_FM_SetModel")
register_forward(FM_SetClientKeyValue, "Hook_FM_SetClientKeyValue")
register_forward(FM_KeyValue, "Hook_FM_KeyValue")
register_forward(FM_Touch, "Hook_FM_Touch")
register_forward(FM_Think, "Hook_FM_Think")
register_forward(FM_Spawn, "Hook_FM_Spawn")
register_forward(FM_PlayerPreThink, "Hook_FM_PlayerPreThink")
register_forward(FM_PlayerPostThink, "Hook_FM_PlayerPostThink")
register_forward(FM_ClientUserInfoChanged, "Hook_ClientUserInfoChanged")
// Only register the traceline forward if there actually is a plugin
// that needs it. Otherwise this will mess with set_user_hitzones
new pluginnum = get_pluginsnum();
for (new i = 0; i < pluginnum; i++)
{
if (plugin_flags(0, i) & AMX_FLAG_OLDFILE && // plugin is an AMX plugin being emulated
get_func_id("traceline", i) != -1) // plugin needs traceline
{
register_forward(FM_TraceLine, "Hook_FM_TraceLine")
break;
}
}
/* Global Forwards */
g_FwdTouch = CreateMultiForwardEx("entity_touch", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_CELL)
g_FwdThink = CreateMultiForwardEx("entity_think", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdSpawn = CreateMultiForwardEx("entity_spawn", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdClientPreThink = CreateMultiForwardEx("client_prethink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL)
g_FwdClientPostThink = CreateMultiForwardEx("client_postthink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL)
g_FwdEmitSound = CreateMultiForwardEx("emitsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdEmitAmbientSound = CreateMultiForwardEx("emitambientsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdSetModel = CreateMultiForwardEx("set_model", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdTraceLine = CreateMultiForwardEx("traceline", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdSetCliKeyValue = CreateMultiForwardEx("setclientkeyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING, FP_STRING)
g_FwdKeyValue = CreateMultiForwardEx("keyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
/* User Messages */
g_msgDamage = get_user_msgid("Damage")
g_msgDeathMsg = get_user_msgid("DeathMsg")
g_msgScoreInfo = get_user_msgid("ScoreInfo")
}
VexdUM_Natives()
{
/* implicit compatibility */
register_native("is_entity", "__is_entity")
register_native("find_entity", "__find_entity")
register_native("find_entity_sphere", "__find_entity_sphere")
register_native("in_view_cone", "__in_view_cone")
register_native("get_offset_int", "__get_offset_int")
register_native("set_offset_int", "__set_offset_int")
register_native("trace_line", "__trace_line")
register_native("traceline_get_int", "__traceline_get_int")
register_native("traceline_set_int", "__traceline_set_int")
register_native("traceline_get_edict", "__traceline_get_edict")
register_native("traceline_set_edict", "__traceline_set_edict")
register_native("traceline_set_float", "__traceline_set_float")
register_native("can_see", "__can_see")
register_native("user_spawn", "__user_spawn")
register_native("get_maxentities", "__get_maxentities")
register_native("PointContents", "__PointContents")
register_native("DispatchKeyValue", "__DispatchKeyValue")
register_native("entity_use","__entity_use")
register_native("get_num_ents","__get_num_ents")
register_native("take_damage","__take_damage")
if (g_ModType == MOD_CSTRIKE)
{
register_native("set_user_model", "__cs_set_user_model")
} else {
register_native("set_user_model", "__set_user_model")
}
}
VexdUM_ClientConnect(id)
{
g_PlayerModels[id][0] = 0
g_PlayerModeled[id] =0
}
SetClientKeyValue(id, const key[], const value[])
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
return engfunc(EngFunc_SetClientKeyValue, id, buffer, key, value)
}
GetClientKeyValue(id, const key[], value[], maxlen)
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
engfunc(EngFunc_InfoKeyValue, buffer, key, value, maxlen)
}
Death(victim, killer, weapon[64], hs)
{
if(pev(victim,pev_takedamage) > DAMAGE_NO)
{
new inflictor = pev(killer,pev_owner)
if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT))
{
if(equal(weapon,""))
{
pev(killer,pev_viewmodel2,weapon,63)
replace(weapon,63,"models/v_","")
weapon[strlen(weapon) - 4] = '^0'
}
}
else if(inflictor > 0 && inflictor < get_maxplayers())
{
if(equal(weapon,""))
{
pev(killer,pev_viewmodel2,weapon,63)
replace(weapon,63,"weapon_","")
replace(weapon,63,"monster_","")
replace(weapon,63,"func_","")
}
if(inflictor == victim)
{
killer = victim
} else {
killer = inflictor
}
}
message_begin(MSG_ALL,g_msgDeathMsg)
write_byte(killer)
write_byte(victim)
write_byte(hs)
write_string(weapon)
message_end()
new vname[32],vauthid[32],vteam[32]
get_user_name(victim,vname,31)
get_user_authid(victim,vauthid,31)
get_user_team(victim,vteam,31)
if(victim == killer)
{
log_message("^"%s<%i><%s><%s>^" killed self with ^"%s^"^n",vname,get_user_userid(victim),
vauthid,vteam,weapon)
}
else if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT))
{
new kname[32],kauthid[32],kteam[32],team
get_user_name(killer,kname,31)
get_user_authid(killer,kauthid,31)
team = get_user_team(killer,kteam,31)
log_message("^"%s<%i><%s><%s>^" killed ^"%s<%i><%s><%s>^" with ^"%s^"^n",kname,get_user_userid(killer),
kauthid,kteam,vname,get_user_userid(victim),vauthid,vteam,weapon)
new Float:frags
pev(killer,pev_frags,frags)
set_pev(killer,pev_frags,frags+1.0)
message_begin(MSG_ALL,g_msgScoreInfo)
write_byte(killer)
write_short(floatround(frags))
write_short(get_user_deaths(killer))
write_short(0)
write_short(team)
message_end()
pev(victim,pev_frags,frags)
set_pev(victim,pev_frags,frags+1.0)
} else {
log_message("^"%s<%i><%s><%s>^" killed by ^"%s^"^n",vname,get_user_userid(victim),vauthid,vteam,weapon)
}
set_msg_block(g_msgDeathMsg,BLOCK_ONCE)
dllfunc(DLLFunc_ClientKill,victim)
}
}
public __is_entity(plid, num)
{
new ent = get_param(1)
return is_entity(ent)
}
public __find_entity(plid, num)
{
static entstr[256]
new startEnt, type
startEnt = get_param(1)
get_string(2, entstr, 255)
type = get_param(3)
return find_entity(startEnt, entstr, type)
}
public __find_entity_sphere(plid, num)
{
new ent
new Float:orig[3]
new Float:radius
ent = get_param(1)
get_array_f(2, orig, 3)
radius = get_param_f(3)
return find_entity_sphere(ent, orig, radius)
}
public __in_view_cone(plid, num)
{
new ent
new Float:orig[3]
ent = get_param(1)
get_array_f(2, orig, 3)
return in_view_cone(ent, orig)
}
public __get_offset_int(plid, num)
{
new ent = get_param(1)
new offs = get_param(2)
new linux = get_param(3)
return get_pdata_int(ent, offs, linux)
}
public __set_offset_int(plid, num)
{
return set_offset_int(get_param(1), get_param(2), get_param(3), get_param(4))
}
public __trace_line(plid, num)
{
new ent = get_param(1)
new Float:vStart[3], Float:vEnd[3], Float:vReturn[3]
get_array_f(2, vStart, 3)
get_array_f(3, vEnd, 3)
if (ent == FM_NULLENT)
engfunc(EngFunc_TraceLine, vStart, vEnd, IGNORE_MONSTERS, 0, 0)
else
engfunc(EngFunc_TraceLine, vStart, vEnd, DONT_IGNORE_MONSTERS, ent, 0)
get_tr2(0, TraceResult:TR_vecEndPos, vReturn)
set_array_f(4, vReturn, 3)
new traceHit = get_tr2(0, TraceResult:TR_pHit)
if (!pev_valid(traceHit))
return FM_NULLENT
return traceHit
}
public __traceline_get_int(plid, num)
{
new iSet = get_param(1)
new iValue = 0
switch (iSet)
{
case TR_INT_fAllSolid:
iValue = get_tr2(g_LastTrace, TraceResult:TR_AllSolid)
case TR_INT_fStartSolid:
iValue = get_tr2(g_LastTrace, TraceResult:TR_StartSolid)
case TR_INT_fInOpen:
iValue = get_tr2(g_LastTrace, TraceResult:TR_InOpen)
case TR_INT_fInWater:
iValue = get_tr2(g_LastTrace, TraceResult:TR_InWater)
case TR_INT_iHitgroup:
iValue = get_tr2(g_LastTrace, TraceResult:TR_iHitgroup)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return iValue
}
public __traceline_set_int(plid, num)
{
new iSet = get_param(1)
new iValue = get_param(2)
switch (iSet)
{
case TR_INT_fAllSolid:
set_tr2(g_LastTrace, TraceResult:TR_AllSolid, iValue)
case TR_INT_fStartSolid:
set_tr2(g_LastTrace, TraceResult:TR_StartSolid, iValue)
case TR_INT_fInOpen:
set_tr2(g_LastTrace, TraceResult:TR_InOpen, iValue)
case TR_INT_fInWater:
set_tr2(g_LastTrace, TraceResult:TR_InWater, iValue)
case TR_INT_iHitgroup:
set_tr2(g_LastTrace, TraceResult:TR_iHitgroup, iValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __traceline_get_edict(plid, num)
{
new iSet = get_param(1)
new iValue = 0
switch (iSet)
{
case TR_ENT_pHit:
iValue = get_tr2(g_LastTrace, TraceResult:TR_pHit)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return iValue
}
public __traceline_set_edict(plid, num)
{
new iSet = get_param(1)
new iValue = get_param(2)
switch (iSet)
{
case TR_ENT_pHit:
set_tr2(g_LastTrace, TraceResult:TR_pHit, iValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public Float:__traceline_get_float(plid, num)
{
new iSet = get_param(1)
new Float:fValue = 0.0
switch (iSet)
{
case TR_FL_flFraction:
get_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue)
case TR_FL_flPlaneDist:
get_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return fValue
}
public __traceline_set_float(plid, num)
{
new iSet = get_param(1)
new Float:fValue = get_param_f(2)
switch (iSet)
{
case TR_FL_flFraction:
set_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue)
case TR_FL_flPlaneDist:
set_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __traceline_get_vector(plid, num)
{
new iSet = get_param(1)
new Float:vValue[3]
switch (iSet)
{
case TR_VEC_vecEndPos:
get_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue)
case TR_VEC_vecPlaneNormal:
get_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
set_array_f(2, vValue, 3)
return 1
}
public __traceline_set_vector(plid, num)
{
new iSet = get_param(1)
new Float:vValue[3]
get_array_f(2, vValue, 3)
switch (iSet)
{
case TR_VEC_vecEndPos:
set_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue)
case TR_VEC_vecPlaneNormal:
set_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __can_see(plid, num)
{
return can_see(get_param(1), get_param(2))
}
public __user_spawn(plid, num)
{
return dllfunc(DLLFunc_Spawn, get_param(1))
}
public __set_user_model(plid, num)
{
new id = get_param(1)
if (id < 1 || id > g_MaxPlayers)
{
return 0
}
new model[64]
get_string(2, model, 63)
if (model[0] == 0)
{
if (!g_PlayerModeled[id])
{
return 0
}
g_PlayerModeled[id] = 0
g_PlayerModels[id][0] = 0
dllfunc(DLLFunc_ClientUserInfoChanged, id)
} else {
copy(g_PlayerModels[id], 63, model)
g_PlayerModeled[id] = 1
SetClientKeyValue(id, "model", model)
}
return 1
}
public __cs_set_user_model(plid, num)
{
new id = get_param(1)
new model[64]
get_string(2, model, 63)
return cs_set_user_model(id, model)
}
public __get_maxentities(plid, num)
{
return get_maxentities()
}
public __PointContents(plid, num)
{
new Float:vCheckAt[3]
get_array_f(1, vCheckAt, 3)
return point_contents(vCheckAt)
}
public __DispatchKeyValue(plid, num)
{
new ent = get_param(1)
new szClassname[32], szKey[32], szValue[32]
if (pev_valid(ent))
{
get_string(2, szKey, 31)
get_string(3, szValue, 31)
pev(ent, pev_classname, szClassname, 31)
set_kvd(0, KV_ClassName, szClassname)
set_kvd(0, KV_KeyName, szKey)
set_kvd(0, KV_Value, szValue)
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue, ent, 0)
}
return 1
}
public __entity_use(plid, num)
{
new entUsed = get_param(1)
new entOther = get_param(2)
return dllfunc(DLLFunc_Use,entUsed,entOther)
}
public __get_num_ents(plid, num)
{
return engfunc(EngFunc_NumberOfEntities)
}
public __take_damage(plid, num)
{
new victim = get_param(1)
new attacker = get_param(2)
new Float:orig[3]
get_array_f(3,orig,3)
new Float:dmg = get_param_f(4)
new bit = get_param(5)
new wpnName[64]
get_string(6,wpnName,63)
new hs = get_param(7)
if(pev(victim,pev_takedamage) > DAMAGE_NO)
{
set_pev(victim,pev_dmg_inflictor,attacker)
new Float:olddmg
pev(victim,pev_dmg_take,olddmg)
set_pev(victim,pev_dmg_take,olddmg+dmg)
message_begin(MSG_ONE, g_msgDamage, {0,0,0} , victim)
write_byte(0)
write_byte(floatround(olddmg+dmg))
write_long(bit)
write_coord(floatround(orig[0]))
write_coord(floatround(orig[1]))
write_coord(floatround(orig[2]))
message_end()
new Float:health
pev(victim,pev_health,health)
if((dmg >= health) && (health > 0.0))
{
Death(victim,attacker,wpnName,hs)
} else {
set_pev(victim,pev_health,health-dmg)
}
}
}
/*********************************
***** HOOKS *********************
*********************************/
public Hook_ClientUserInfoChanged(id, buffer)
{
if (g_PlayerModeled[id] && (pev(id, pev_deadflag) == DEAD_NO))
{
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public Hook_FM_EmitSound(entid, channel, const sample[]) //we don't care about the rest
{
new ret
ExecuteForward(g_FwdEmitSound, ret, entid, sample)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_EmitAmbientSound(entid, Float:pos[3], const sample[]) //we don't care about the rest
{
new ret
ExecuteForward(g_FwdEmitAmbientSound, ret, entid, sample)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_SetModel(entid, const model[])
{
new ret
ExecuteForward(g_FwdSetModel, ret, entid, model)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_TraceLine(Float:v1[3], Float:v2[3], noMonsters, skip_ent, ptr)
{
g_LastTrace = ptr
engfunc(EngFunc_TraceLine, v1, v2, noMonsters, skip_ent, ptr)
new ret
ExecuteForward(g_FwdTraceLine, ret, skip_ent)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_SetClientKeyValue(id, const infobuffer[], const key[], const value[])
{
new ret
ExecuteForward(g_FwdSetCliKeyValue, ret, id, key, value)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_KeyValue(ent, kvd)
{
new ret
ExecuteForward(g_FwdKeyValue, ret, ent)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Touch(ent1, ent2)
{
new ret
ExecuteForward(g_FwdTouch, ret, ent1, ent2)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Think(entid)
{
new ret
ExecuteForward(g_FwdThink, ret, entid)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Spawn(entid)
{
new ret
ExecuteForward(g_FwdSpawn, ret, entid)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_PlayerPreThink(id)
{
new ret
ExecuteForward(g_FwdClientPreThink, ret, id)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_PlayerPostThink(id)
{
new ret
if (g_PlayerModeled[id])
{
new model[64]
GetClientKeyValue(id, "model", model, 63)
if (!equal(g_PlayerModels[id], model))
{
SetClientKeyValue(id, "model", g_PlayerModels[id])
}
}
ExecuteForward(g_FwdClientPostThink, ret, id)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}