Post: How to Spawn Solid Entities and Turrets C++
01-24-2016, 04:10 PM #1
Swaqq
Professional Thanker
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys, today I'm releasing how you can spawn entities in C++. I've been using these for my bunker and it works perfectly.

So first off you need to add these structures:
    
struct gclient_s {
char unk0[0x78];
float origin[3];
char unk1[0x12C];
float viewAngles[3]; //0x353C
char unk2[0x3380];
int oldbuttons;
char unk3[0x8];
int buttons;
char unk4[0x434];
};


struct gagent_s {
char unk[0x100];
};

struct gentity_s {
char unk0[0x1C];
int contents;
char unk1[0x118];
float currentOrigin[3];
float currentAngles[3];
char unk2[0x8];
gclient_s* client;
char unk3[0x4];
gagent_s* agent;
char unk4[0x16];
short classname;
short script_classname;
short script_linkName;
short target;
short targetname;
char unk5[0x2];
unsigned int attachIgnoreCollision;
int spawnflags;
char unk6[0x19];
int health;
char unk7[0xCF];
};





Next you will need these functions
    
gentity_s* G_Spawn()
{
opd_s G_Spawn_t = { 0x00389510, TOC };
gentity_s*(*G_Spawn_f)() = (gentity_s*(*)())&G_Spawn_t;
return G_Spawn_f();
}

void G_SetModel(gentity_s* ent, char* Model)
{
opd_s G_SetModel_t = { 0x00388294, TOC };
void(*G_SetModel_f)(gentity_s* ent, char* Model) = (void(*)(gentity_s*, char*))&G_SetModel_t;
G_SetModel_f(ent, Model);
}
void SP_Script_Model(gentity_s* ent)
{
opd_s SP_Script_Model_t = { 0x0037DDD4, TOC };
void(*SP_Script_Model_f)(gentity_s* ent) = (void(*)(gentity_s*))&SP_Script_Model_t;
SP_Script_Model_f(ent);
}
void SV_LinkEntity(gentity_s* ent)
{
opd_s SV_LinkEntity_t = { 0x004737A0, TOC };
void(*SV_LinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_LinkEntity_t;
SV_LinkEntity_f(ent);
}
void SV_UnlinkEntity(gentity_s* ent)
{
opd_s SV_UnlinkEntity_t = { 0x00473720, TOC };
void(*SV_UnlinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_UnlinkEntity_t;
SV_UnlinkEntity_f(ent);
}
void SV_SetBrushModel(gentity_s* ent)
{
opd_s SV_SetBrushModel_t = { 0x00457D04, TOC };
void(*SV_SetBrushModel_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_SetBrushModel_t;
SV_SetBrushModel_f(ent);
}

void G_SpawnTurret(gentity_s* ent, const char *weaponinfoname, const int useDropPitch)
{
opd_s G_SpawnTurret_t = { 0x0039E620, TOC };
void(*G_SpawnTurret_f)(gentity_s* ent, const char *weaponinfoname, const int useDropPitch) = (void(*)(gentity_s* , const char *, const int))&G_SpawnTurret_t;
G_SpawnTurret_f(ent, weaponinfoname, useDropPitch);
}


And finally to add
    
gentity_s* SpawnEnt(char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = G_Spawn();
Ent->currentOrigin[0] = Origin[0];
Ent->currentOrigin[1] = Origin[1];
Ent->currentOrigin[2] = Origin[2];
Ent->currentAngles[0] = Angles[0];
Ent->currentAngles[1] = Angles[1];
Ent->currentAngles[2] = Angles[2];
G_SetModel(Ent, Model);
SP_Script_Model(Ent);
SV_UnlinkEntity(Ent);
SV_SetBrushModel(Ent);
SV_LinkEntity(Ent);
return Ent;
}
gentity_s* SpawnTurret(char* TurretType, char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = SpawnEnt(Model, Origin, Angles);
G_SpawnTurret(Ent, TurretType, 0);
}


To spawn a crate, you do:
    
gentity_s* Crate = SpawnEnt("com_plasticcase_green_big_us_dirt",Origin, Angles)

To spawn a Turret, do:
    
gentity_s* Turret = SpawnTurret("sentry_minigun_mp", "npc_sentry_energy_turret_base", Origin, Angles);


Model List:
    
https://pastebin.com/eeziSJTQ

Turrets: //Shark
    
turretheadmg_mp
turretheadenergy_mp
sentry_minigun_mp
remote_turret_mp
remote_energy_turret_mp
killstreak_remote_turret_mp
warbird_turret
ugv_turret_mp
warbird_remote_turret_mp
orbitalsupport_big_turret_mp
orbitalsupport_buddy_turret_mp
recon_drone_turret_mp
drone_assault_remote_turret_mp


Note: You will need to call this in a hook. I was using VM_Notify but R_SetFrameFog should work fine.

Credits:
    
Me - for developing the script
Shark - gentity and gclient struct
(adsbygoogle = window.adsbygoogle || []).push({});

The following 8 users say thank you to Swaqq for this useful post:

Sabotage, gοd, SQUID-EYE, LBK, Loes, John, basshead4ever,

The following user groaned Swaqq for this awful post:

Tears
01-25-2016, 02:15 PM #11
Swaqq
Professional Thanker
Originally posted by Sabotage View Post
you mean "my" menu? you leeching fgt :(


Lmao yeah your menu... lmao only Loes would understand..
01-26-2016, 09:35 PM #12
LBK
Little One
Very goob Job my friends , your Job is always good ! Keep it up ! Your a a good man Smile
01-27-2016, 08:26 PM #13
gοd
Vault dweller
Originally posted by Swaqq View Post
Hey guys, today I'm releasing how you can spawn entities in C++. I've been using these for my bunker and it works perfectly.

So first off you need to add these structures:
    
struct gclient_s {
char unk0[0x78];
float origin[3];
char unk1[0x12C];
float viewAngles[3]; //0x353C
char unk2[0x3380];
int oldbuttons;
char unk3[0x8];
int buttons;
char unk4[0x434];
};


struct gagent_s {
char unk[0x100];
};

struct gentity_s {
char unk0[0x1C];
int contents;
char unk1[0x118];
float currentOrigin[3];
float currentAngles[3];
char unk2[0x8];
gclient_s* client;
char unk3[0x4];
gagent_s* agent;
char unk4[0x16];
short classname;
short script_classname;
short script_linkName;
short target;
short targetname;
char unk5[0x2];
unsigned int attachIgnoreCollision;
int spawnflags;
char unk6[0x19];
int health;
char unk7[0xCF];
};





Next you will need these functions
    
gentity_s* G_Spawn()
{
opd_s G_Spawn_t = { 0x00389510, TOC };
gentity_s*(*G_Spawn_f)() = (gentity_s*(*)())&G_Spawn_t;
return G_Spawn_f();
}

void G_SetModel(gentity_s* ent, char* Model)
{
opd_s G_SetModel_t = { 0x00388294, TOC };
void(*G_SetModel_f)(gentity_s* ent, char* Model) = (void(*)(gentity_s*, char*))&G_SetModel_t;
G_SetModel_f(ent, Model);
}
void SP_Script_Model(gentity_s* ent)
{
opd_s SP_Script_Model_t = { 0x0037DDD4, TOC };
void(*SP_Script_Model_f)(gentity_s* ent) = (void(*)(gentity_s*))&SP_Script_Model_t;
SP_Script_Model_f(ent);
}
void SV_LinkEntity(gentity_s* ent)
{
opd_s SV_LinkEntity_t = { 0x004737A0, TOC };
void(*SV_LinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_LinkEntity_t;
SV_LinkEntity_f(ent);
}
void SV_UnlinkEntity(gentity_s* ent)
{
opd_s SV_UnlinkEntity_t = { 0x00473720, TOC };
void(*SV_UnlinkEntity_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_UnlinkEntity_t;
SV_UnlinkEntity_f(ent);
}
void SV_SetBrushModel(gentity_s* ent)
{
opd_s SV_SetBrushModel_t = { 0x00457D04, TOC };
void(*SV_SetBrushModel_f)(gentity_s* ent) = (void(*)(gentity_s*))&SV_SetBrushModel_t;
SV_SetBrushModel_f(ent);
}

void G_SpawnTurret(gentity_s* ent, const char *weaponinfoname, const int useDropPitch)
{
opd_s G_SpawnTurret_t = { 0x0039E620, TOC };
void(*G_SpawnTurret_f)(gentity_s* ent, const char *weaponinfoname, const int useDropPitch) = (void(*)(gentity_s* , const char *, const int))&G_SpawnTurret_t;
G_SpawnTurret_f(ent, weaponinfoname, useDropPitch);
}


And finally to add
    
gentity_s* SpawnEnt(char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = G_Spawn();
Ent->currentOrigin[0] = Origin[0];
Ent->currentOrigin[1] = Origin[1];
Ent->currentOrigin[2] = Origin[2];
Ent->currentAngles[0] = Angles[0];
Ent->currentAngles[1] = Angles[1];
Ent->currentAngles[2] = Angles[2];
G_SetModel(Ent, Model);
SP_Script_Model(Ent);
SV_UnlinkEntity(Ent);
SV_SetBrushModel(Ent);
SV_LinkEntity(Ent);
return Ent;
}
gentity_s* SpawnTurret(char* TurretType, char* Model, vec3_t Origin, vec3_t Angles)
{
gentity_s* Ent = SpawnEnt(Model, Origin, Angles);
G_SpawnTurret(Ent, TurretType, 0);
}


To spawn a crate, you do:
    
gentity_s* Crate = SpawnEnt("com_plasticcase_green_big_us_dirt",Origin, Angles)

To spawn a Turret, do:
    
gentity_s* Turret = SpawnTurret("sentry_minigun_mp", "npc_sentry_energy_turret_base", Origin, Angles);


Model List:
    
https://pastebin.com/eeziSJTQ

Turrets: //Shark
    
turretheadmg_mp
turretheadenergy_mp
sentry_minigun_mp
remote_turret_mp
remote_energy_turret_mp
killstreak_remote_turret_mp
warbird_turret
ugv_turret_mp
warbird_remote_turret_mp
orbitalsupport_big_turret_mp
orbitalsupport_buddy_turret_mp
recon_drone_turret_mp
drone_assault_remote_turret_mp


Note: You will need to call this in a hook. I was using VM_Notify but R_SetFrameFog should work fine.

Credits:
    
Me - for developing the script
Shark - gentity and gclient struct


Swaqq what would do without the AW God, Sledgehammer Games...


JK Amazing work bby <3

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo