CBasePlayer::GiveNamedItem
0x007ab950 · 552 bytes · __cdecl
_ZN11CBasePlayer13GiveNamedItemEPKcibP11CBaseEntity
Decompiled
undefined (4 params)
/* CBasePlayer::GiveNamedItem(char const*, int, bool, CBaseEntity*) */
undefined4 CBasePlayer::GiveNamedItem(char *param_1,int param_2,bool param_3,CBaseEntity *param_4)
{
uint uVar1;
CBaseEdict *this;
int iVar2;
int *piVar3;
uint *puVar4;
int iVar5;
CBaseEntity *pCVar6;
int *piVar7;
uint uVar8;
undefined *puVar9;
undefined4 *puVar10;
uint uVar11;
undefined3 in_stack_0000000d;
iVar2 = CBaseCombatCharacter::Weapon_OwnsThisType
((CBaseCombatCharacter *)param_1,(char *)param_2,_param_3);
if (iVar2 != 0) {
return 0;
}
piVar3 = (int *)CreateEntityByName((char *)param_2,-1,true);
if (piVar3 == (int *)0x0) {
LAB_007ab9d9:
Msg("NULL Ent in GiveNamedItem!\n");
return 0;
}
puVar4 = (uint *)(**(code **)(*piVar3 + 0xc))(piVar3);
uVar8 = *puVar4;
if (uVar8 == 0xffffffff) goto LAB_007ab9d9;
uVar11 = uVar8 & 0xfff;
iVar2 = uVar11 * 0x10;
puVar9 = g_pEntityList + iVar2;
if (((puVar9 == (undefined *)0xfffffffc) || (uVar1 = *(uint *)(puVar9 + 8), uVar1 != uVar8 >> 0xc)
) || (*(CBaseEntity **)(puVar9 + 4) == (CBaseEntity *)0x0)) goto LAB_007ab9d9;
CBaseEntity::SetLocalOrigin(*(CBaseEntity **)(puVar9 + 4),(Vector *)(param_1 + 0x39c));
piVar3 = (int *)(g_pEntityList + iVar2 + 4);
if ((piVar3 == (int *)0x0) || (uVar1 != *(uint *)(g_pEntityList + iVar2 + 8))) {
iVar2 = 0;
}
else {
iVar2 = *(int *)(g_pEntityList + iVar2 + 4);
}
uVar8 = *(uint *)(iVar2 + 0x148) | 0x40000000;
if (*(uint *)(iVar2 + 0x148) != uVar8) {
if (*(char *)(iVar2 + 0x6c) == '\0') {
this = *(CBaseEdict **)(iVar2 + 0x30);
if (this != (CBaseEdict *)0x0) {
*(uint *)this = *(uint *)this | 0x101;
iVar5 = CBaseEdict::GetChangeAccessor(this);
*(undefined2 *)(iVar5 + 2) = 0;
piVar3 = (int *)(g_pEntityList + uVar11 * 0x10 + 4);
}
}
else {
*(byte *)(iVar2 + 0x70) = *(byte *)(iVar2 + 0x70) | 1;
}
*(uint *)(iVar2 + 0x148) = uVar8;
}
if (piVar3 != (int *)0x0) {
if (((uVar1 == piVar3[1]) && (*piVar3 != 0)) &&
(piVar7 = (int *)__dynamic_cast(*piVar3,&CBaseEntity::typeinfo,&CBaseCombatWeapon::typeinfo,0
), piVar7 != (int *)0x0)) {
(**(code **)(*piVar7 + 0x3ac))(piVar7,_param_3);
piVar3 = (int *)(g_pEntityList + uVar11 * 0x10 + 4);
if (piVar3 == (int *)0x0) goto LAB_007aba89;
}
if (uVar1 == piVar3[1]) {
pCVar6 = (CBaseEntity *)*piVar3;
goto LAB_007aba8b;
}
}
LAB_007aba89:
pCVar6 = (CBaseEntity *)0x0;
LAB_007aba8b:
iVar2 = uVar11 * 0x10;
DispatchSpawn(pCVar6,true);
puVar10 = (undefined4 *)(g_pEntityList + iVar2 + 4);
if (puVar10 != (undefined4 *)0x0) {
if (((uVar1 == *(uint *)(g_pEntityList + iVar2 + 8)) &&
(piVar3 = *(int **)(g_pEntityList + iVar2 + 4), piVar3 != (int *)0x0)) &&
((*(byte *)(piVar3 + 0x53) & 1) == 0)) {
(**(code **)(*piVar3 + 0x1b4))(piVar3,param_1);
puVar10 = (undefined4 *)(g_pEntityList + iVar2 + 4);
if (puVar10 == (undefined4 *)0x0) {
return 0;
}
}
if (uVar1 == puVar10[1]) {
return *puVar10;
}
}
return 0;
}
SourceMod gamedata
paste intoaddons/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.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.