initial import of the bcompat plugins (userland layer)

This commit is contained in:
David Anderson
2006-09-08 14:49:54 +00:00
parent 38e7b9ff58
commit 8df33abd70
13 changed files with 1995 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/**
* 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", AMXX_VERSION_STR, "AMXX Dev Team")
g_MaxPlayers = get_maxplayers()
VexdUM_Register()
}
public plugin_natives()
{
set_module_filter("Plugin_ModuleFilter")
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"))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_connect(id)
{
VexdUM_ClientConnect(id)
}

View File

@ -0,0 +1,182 @@
/**
* 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")
}
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)
}

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,569 @@
/**
* 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]
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_TraceLine, "Hook_FM_TraceLine")
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")
/* Global Forwards */
g_FwdTouch = CreateMultiForward("entity_touch", ET_STOP, FP_CELL, FP_CELL)
g_FwdThink = CreateMultiForward("entity_think", ET_STOP, FP_CELL)
g_FwdSpawn = CreateMultiForward("entity_spawn", ET_STOP, FP_CELL)
g_FwdClientPreThink = CreateMultiForward("client_prethink", ET_IGNORE, FP_CELL)
g_FwdClientPostThink = CreateMultiForward("client_postthink", ET_IGNORE, FP_CELL)
g_FwdEmitSound = CreateMultiForward("emitsound", ET_STOP, FP_CELL, FP_STRING)
g_FwdEmitAmbientSound = CreateMultiForward("emitambientsound", ET_STOP, FP_CELL, FP_STRING)
g_FwdSetModel = CreateMultiForward("set_model", ET_STOP, FP_CELL, FP_STRING)
g_FwdTraceLine = CreateMultiForward("traceline", ET_STOP, FP_CELL)
g_FwdSetCliKeyValue = CreateMultiForward("setclientkeyvalue", ET_STOP, FP_CELL, FP_STRING, FP_STRING)
g_FwdKeyValue = CreateMultiForward("keyvalue", ET_STOP, FP_CELL)
}
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")
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, buffer, key, value)
}
GetClientKeyValue(id, const key[], value[], maxlen)
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
engfunc(EngFunc_InfoKeyValue, buffer, key, value, maxlen)
}
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:
get_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
}
/*********************************
***** 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
}