Raised This Month: $12 Target: $400
 3% 

[CS:GO] Modify Map Entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-21-2015 , 12:49   [CS:GO] Modify Map Entities
Reply With Quote #1

As the title says, how can we get the (key?)values of entity(s) named "something" and then modify it?
For example, we cannot make a weapon entity in hammer with 0/0 ammo. If we put "ammo" with value 0 then it spawns weapon with 20/0 ammo. So I need to edit this weapon entity named "gun_1" and make its ammo 0/0 or 1/0 according to my needs.
__________________

Last edited by yash1441; 08-21-2015 at 12:50. Reason: Better Title
yash1441 is offline
Send a message via Skype™ to yash1441
iEx5
Member
Join Date: Aug 2014
Location: Saint-Petersburg
Old 08-22-2015 , 06:32   Re: [CS:GO] Modify Map Entities
Reply With Quote #2

By cycling all entities..

for(new i = 1;i < GetMaxEntities();i++)
{
if(IsValidEntity(i))
{
new X[128];
if(GetEdictClassname(i, X, sizeof(X))){
if(StrEqual("class_name_here", X,false))
{
//Do something with that entity
//As Example SetEntPropEnt(i,Prop_Data,"m_hOwnerEntity",cl ient)....
}
}
}
}
__________________
Do not advertise (including in signatures) the sale of turnkey (i.e. pre-made) plugins.
iEx5 is offline
Send a message via Skype™ to iEx5
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-22-2015 , 11:11   Re: [CS:GO] Modify Map Entities
Reply With Quote #3

Quote:
Originally Posted by iEx5 View Post
By cycling all entities..

for(new i = 1;i < GetMaxEntities();i++)
{
if(IsValidEntity(i))
{
new X[128];
if(GetEdictClassname(i, X, sizeof(X))){
if(StrEqual("class_name_here", X,false))
{
//Do something with that entity
//As Example SetEntPropEnt(i,Prop_Data,"m_hOwnerEntity",cl ient)....
}
}
}
}
So, class_name_here is to be replaced by, say, weapon_ak47 right? and how do I get the Property name(const char[] prop)?
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
iEx5
Member
Join Date: Aug 2014
Location: Saint-Petersburg
Old 08-22-2015 , 16:54   Re: [CS:GO] Modify Map Entities
Reply With Quote #4

Yep.
__________________
Do not advertise (including in signatures) the sale of turnkey (i.e. pre-made) plugins.
iEx5 is offline
Send a message via Skype™ to iEx5
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-22-2015 , 17:54   Re: [CS:GO] Modify Map Entities
Reply With Quote #5

That is the SLOWER way to do it (source: benchmarked it).

The best way to do it is:

PHP Code:
int iEntity = -1;
while ((
iEntity FindEntityByClassname(iEntity"put your classname here")) != -1)
{
// Using iEntity as the entity index, do what you need to do in here.

And as for using the property name you use any of the GetEntProp functions (GetEntProp, GetEntPropString, GetEntPropFloat, GetEntPropEnt) depending on the property type (usually GetEntProp is used).

PHP Code:
int DefIndex GetEntProp(iEntityProp_Send"m_iDefinitionIndex"); 
You can find a list of netprops (property names) for each entity classname using sm_dump_datamaps and sm_dump_netprops.

Spoiler

Last edited by Potato Uno; 08-22-2015 at 17:58.
Potato Uno is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 08-22-2015 , 18:52   Re: [CS:GO] Modify Map Entities
Reply With Quote #6

Quote:
Originally Posted by Potato Uno View Post
benchmarked it
:-O can you please do a benchmark with SDKHooks OnEntityCreated -> hook entity spawned ?
KissLick is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-23-2015 , 02:11   Re: [CS:GO] Modify Map Entities
Reply With Quote #7

Thanks Potato! Really useful information.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode