-
I'm trying to redirect the state of an entity to the index of a disconnected player. Looking at ReHLDS and IDA hw.so, it seems completely possible. But for some reason, it’s not working and crashes the client. If I disable DELTA encoding, everything works as expected. I can't wrap my head around how DELTA encoding works and figure out where the conflict is that prevents updated data from being sent and causes a crash on the client. I disabled DELTA in: SV_CreatePacketEntities(sv_packet_nodelta /*client->delta_sequence == -1 ? sv_packet_nodelta : sv_packet_delta*/, client, to, msg); Test plugin: /* Sublime AMXX-Editor v4.4 */
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <reapi>
#define PLUGIN "Test entity to player index"
#define VERSION "1.0.0-289"
#define AUTHOR "Author"
new tt_modelindex, TeamInfo
new g_ent
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
TeamInfo = get_user_msgid("TeamInfo")
tt_modelindex = engfunc(EngFunc_ModelIndex, "models/player/leet/leet.mdl")
register_forward(FM_AddToFullPack, "fw_AddToFullPack", 1)
g_ent = create_entity("player")
set_pev(g_ent, pev_effects, EF_NOINTERP)
set_pev(g_ent, pev_modelindex, tt_modelindex) // modelindex does not have to be zero for the entity try to be sent to the client
new Float:f[] = { -832.00, -800.00, 164.03 } // TT site in de_dust2
set_pev(g_ent, pev_origin, f)
}
public client_putinserver(id)
{
set_task(1.0, "send_fakeinfo", id)
}
public send_fakeinfo(id)
{
new slot = 30 // test free slot
UTIL_UpdateInfo(id, slot-1, 0, "[free slot]", "urban") // send userinfo, name, model
UTIL_TeamInfo(id, slot, "TERRORIST" ) // send team (for cl_minmodel 1)
}
public fw_AddToFullPack(es_handle, e, ent, host, hostflags, player, pset)
{
if(!is_user_alive(host))
return
if(g_ent == ent)
{
static newIndex
//newIndex = getFreeIndex(host)
newIndex = 30 // test free slot
set_es(es_handle, ES_Number, newIndex)
//set_es(es_handle, ES_ModelIndex, (g_teaminfo[host] == TEAM_CT) ? ct_modelindex : tt_modelindex)
// gamedll addtofullpack set if(player)
//set_es(es_handle, ES_Spectator, 1)
//set_es(es_handle, ES_Friction, 1.0)
//set_es(es_handle, ES_Gravity, 1.0)
//set_es(es_handle, ES_eFlags, 0)
//set_es(es_handle, ES_Health, 100)
//set_es(es_handle, ES_PlayerClass, 0)
// Calculate forward position
new Float:origin[3], Float:angles[3], Float:vForward[3]
// Obtener la posición y los ángulos de vista del host
pev(host, pev_origin, origin)
pev(host, pev_v_angle, angles)
// Convertir los ángulos a un vector de dirección
angle_vector(angles, ANGLEVECTOR_FORWARD, vForward)
// Calcular la nueva posición en la dirección de la vista
origin[0] += vForward[0] * 37.0
origin[1] += vForward[1] * 37.0
origin[2] += vForward[2] * 37.0
origin[2] += 2.5
// Establecer la nueva posición
set_es(es_handle, ES_Origin, origin)
set_es(es_handle, ES_Angles, angles)
// Movetype
set_es(es_handle, ES_MoveType, MOVETYPE_NONE)
// Secuencia con los brazos abiertos
set_es(es_handle, ES_Sequence, 3)
//set_es(es_handle, ES_Sequence, pev(host, pev_sequence))
//set_es(es_handle, ES_GaitSequence, pev(host, pev_gaitsequence))
//set_es(es_handle, ES_AnimTime, get_gametime())
//set_es(es_handle, ES_FrameRate, pev(host, pev_framerate))
// disable interpolation ?
// set_es(es_handle, ES_Effects, EF_NOINTERP)
}
}
stock UTIL_TeamInfo(receiver, player, const team[])
{
message_begin(receiver ? MSG_ONE : MSG_ALL, TeamInfo, _, receiver)
write_byte(player)
write_string(team)
message_end()
}
stock UTIL_UpdateInfo(receiver, slot, userid, const name[], const model[])
{
static info[64]
formatex(info, 63, "\name\%s\model\%s\", name, model)
message_begin(receiver ? MSG_ONE : MSG_ALL, SVC_UPDATEUSERINFO, _, receiver)
write_byte(slot)
write_long(userid)
write_string(info)
write_long(0)
write_long(0)
write_long(0)
write_long(0)
message_end()
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
guess from @hun1er
|
Beta Was this translation helpful? Give feedback.
-
I found a solution: create the entity quickly (plugin_precache) so that it gets an index right after the players. However, I still don't understand the underlying cause of the problem with DELTA encoding. |
Beta Was this translation helpful? Give feedback.
I found a solution: create the entity quickly (plugin_precache) so that it gets an index right after the players. However, I still don't understand the underlying cause of the problem with DELTA encoding.