L L4D2node

CBasePlayer::CreateViewModel

0x007ac490 · 333 bytes · __thiscall

_ZN11CBasePlayer15CreateViewModelEi

Decompiled

undefined (2 params)

/* CBasePlayer::CreateViewModel(int) */

void __thiscall CBasePlayer::CreateViewModel(CBasePlayer *this,int param_1)

{
  uint uVar1;
  CBaseEdict *this_00;
  CBaseEntity *this_01;
  undefined4 *puVar2;
  int iVar3;
  undefined *puVar4;
  undefined4 local_20 [4];
  
  uVar1 = *(uint *)(this + param_1 * 4 + 0x1f84);
  if ((((uVar1 != 0xffffffff) &&
       (puVar4 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar4 != (undefined *)0xfffffffc)) &&
      (*(uint *)(puVar4 + 8) == uVar1 >> 0xc)) && (*(int *)(puVar4 + 4) != 0)) {
    return;
  }
  this_01 = (CBaseEntity *)CreateEntityByName("viewmodel",-1,true);
  if (this_01 != (CBaseEntity *)0x0) {
    if (((byte)this[0x14d] & 8) != 0) {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
    }
    CBaseEntity::SetAbsOrigin(this_01,(Vector *)(this + 0x2e0));
    CBaseViewModel::SetOwner((CBaseViewModel *)this_01,(CBaseEntity *)this);
    CBaseViewModel::SetIndex((CBaseViewModel *)this_01,param_1);
    DispatchSpawn(this_01,true);
    CBaseEntity::FollowEntity(this_01,(CBaseEntity *)this,true);
    puVar2 = (undefined4 *)(**(code **)(*(int *)this_01 + 0xc))(this_01);
    local_20[0] = *puVar2;
    iVar3 = memcmp(this + param_1 * 4 + 0x1f84,local_20,4);
    if (iVar3 != 0) {
      if (this[0x6c] == (CBasePlayer)0x0) {
        this_00 = *(CBaseEdict **)(this + 0x30);
        if (this_00 != (CBaseEdict *)0x0) {
          *(uint *)this_00 = *(uint *)this_00 | 0x101;
          iVar3 = CBaseEdict::GetChangeAccessor(this_00);
          *(undefined2 *)(iVar3 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CBasePlayer)((byte)this[0x70] | 1);
      }
      *(undefined4 *)(this + param_1 * 4 + 0x1f84) = local_20[0];
    }
  }
  return;
}

SourceMod gamedata

paste into addons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)

Just a Signatures{} block, ready to drop into a gamedata file. Wire it up in your plugin however you like - SDKCall, DHooks, raw memory ops, or anything else.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)