L L4D2node

CCSPlayer::GiveNamedItem

0x0065acc0 · 700 bytes · __cdecl

_ZN9CCSPlayer13GiveNamedItemEPKciP11CBaseEntity

Decompiled

undefined (3 params)

/* CCSPlayer::GiveNamedItem(char const*, int, CBaseEntity*) */

undefined4 CCSPlayer::GiveNamedItem(char *param_1,int param_2,CBaseEntity *param_3)

{
  uint uVar1;
  CBaseEdict *this;
  int iVar2;
  int *piVar3;
  uint *puVar4;
  CBaseEntity *pCVar5;
  undefined *puVar6;
  uint uVar7;
  CBaseCombatWeapon *pCVar8;
  uint uVar9;
  int local_30;
  Vector local_28 [24];
  
  if (param_2 == 0) {
    return 0;
  }
  if (*(char *)param_2 == '\0') {
    return 0;
  }
  iVar2 = _V_stricmp((char *)param_2,"weapon_shield");
  if (iVar2 == 0) {
    return 0;
  }
  piVar3 = (int *)CreateEntityByName((char *)param_2,-1,true);
  if (piVar3 == (int *)0x0) {
LAB_0065ad3d:
    Msg("NULL Ent in GiveNamedItem!\n");
    return 0;
  }
  puVar4 = (uint *)(**(code **)(*piVar3 + 0xc))(piVar3);
  uVar7 = *puVar4;
  if (uVar7 == 0xffffffff) goto LAB_0065ad3d;
  uVar9 = uVar7 & 0xfff;
  puVar6 = g_pEntityList + uVar9 * 0x10;
  if (((puVar6 == (undefined *)0xfffffffc) || (uVar1 = *(uint *)(puVar6 + 8), uVar1 != uVar7 >> 0xc)
      ) || (*(int *)(puVar6 + 4) == 0)) goto LAB_0065ad3d;
  (**(code **)(*(int *)param_1 + 0x234))(local_28,param_1);
  puVar6 = g_pEntityList + uVar9 * 0x10;
  if ((puVar6 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar6 + 8))) {
    pCVar5 = (CBaseEntity *)0x0;
  }
  else {
    pCVar5 = *(CBaseEntity **)(puVar6 + 4);
  }
  CBaseEntity::SetLocalOrigin(pCVar5,local_28);
  piVar3 = (int *)(g_pEntityList + uVar9 * 0x10 + 4);
  if ((piVar3 == (int *)0x0) || (uVar1 != *(uint *)(g_pEntityList + uVar9 * 0x10 + 8))) {
    local_30 = 0;
  }
  else {
    local_30 = *(int *)(g_pEntityList + uVar9 * 0x10 + 4);
  }
  uVar7 = *(uint *)(local_30 + 0x148) | 0x40000000;
  if (*(uint *)(local_30 + 0x148) != uVar7) {
    if (*(char *)(local_30 + 0x6c) == '\0') {
      this = *(CBaseEdict **)(local_30 + 0x30);
      if (this != (CBaseEdict *)0x0) {
        *(uint *)this = *(uint *)this | 0x101;
        iVar2 = CBaseEdict::GetChangeAccessor(this);
        *(undefined2 *)(iVar2 + 2) = 0;
        piVar3 = (int *)(g_pEntityList + uVar9 * 0x10 + 4);
      }
    }
    else {
      *(byte *)(local_30 + 0x70) = *(byte *)(local_30 + 0x70) | 1;
    }
    *(uint *)(local_30 + 0x148) = uVar7;
  }
  if (piVar3 == (int *)0x0) {
    pCVar8 = (CBaseCombatWeapon *)0x0;
  }
  else {
    if ((uVar1 == piVar3[1]) && (*piVar3 != 0)) {
      pCVar8 = (CBaseCombatWeapon *)
               __dynamic_cast(*piVar3,&CBaseEntity::typeinfo,&CBaseCombatWeapon::typeinfo,0);
      if ((pCVar8 != (CBaseCombatWeapon *)0x0) && (param_3 != (CBaseEntity *)0x0)) {
        (**(code **)(*(int *)pCVar8 + 0x3ac))(pCVar8,param_3);
        pCVar5 = (CBaseEntity *)0x0;
        piVar3 = (int *)(g_pEntityList + uVar9 * 0x10 + 4);
        if (piVar3 == (int *)0x0) goto LAB_0065ae3d;
      }
    }
    else {
      pCVar8 = (CBaseCombatWeapon *)0x0;
    }
    if (uVar1 == piVar3[1]) {
      pCVar5 = (CBaseEntity *)*piVar3;
      goto LAB_0065ae3d;
    }
  }
  pCVar5 = (CBaseEntity *)0x0;
LAB_0065ae3d:
  DispatchSpawn(pCVar5,true);
  param_1[0x299d] = '\x01';
  puVar6 = g_pEntityList + uVar9 * 0x10;
  if ((((puVar6 != (undefined *)0xfffffffc) && (uVar1 == *(uint *)(puVar6 + 8))) &&
      (piVar3 = *(int **)(puVar6 + 4), piVar3 != (int *)0x0)) &&
     ((*(byte *)(piVar3 + 0x53) & 1) == 0)) {
    (**(code **)(*piVar3 + 0x1b4))(piVar3,param_1);
  }
  param_1[0x299d] = '\0';
  StockPlayerAmmo((CCSPlayer *)param_1,pCVar8);
  puVar6 = g_pEntityList + uVar9 * 0x10;
  if (puVar6 == (undefined *)0xfffffffc) {
    return 0;
  }
  if (uVar1 != *(uint *)(puVar6 + 8)) {
    return 0;
  }
  return *(undefined4 *)(puVar6 + 4);
}

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)