Raised This Month: $ Target: $400
 0% 

How to change entity name ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Icetea16
Member
Join Date: Jul 2015
Location: France
Old 09-04-2015 , 11:59   How to change entity name ?
Reply With Quote #1

Hello,

I tried to change name of my entity but no success ...

My code:

Code when i set the first name:
PHP Code:
        char sTargetName[128];
        
Format(sTargetNamesizeof(sTargetName), "imprimante-%i-0"GetClientUserId(client)); 
Code for change entity name:
PHP Code:
        char sTargetName[128];
        
Entity_GetName(imprimantesTargetNamesizeof(sTargetName));
        
        
char sExplode[3][128];
        
ExplodeString(sTargetName"-"sExplode3128);
        
        
int iCurrentMoney StringToInt(sExplode[2]);
        
        
iCurrentMoney += PROD_IMPRIMANTE;
        
Format(sTargetNamesizeof(sTargetName), "imprimante-%i-%i"GetClientUserId(StringToInt(sExplode[1])), iCurrentMoney);
        
        
SetEntPropString(imprimanteProp_Data"m_iName"sTargetName);
        
        
PrintToChatAll("%i €"iCurrentMoney); 
When i want to set the entity name, my PrintToChatAll don't work.

I tried this:
PHP Code:
Entity_SetName(imprimantesTargetName);
Entity_SetTargetName(imprimantesTargetName); 
Thanks for help ^^'
__________________
I'm French, sorry for my bad english...

Last edited by Icetea16; 09-04-2015 at 12:03.
Icetea16 is offline
Icetea16
Member
Join Date: Jul 2015
Location: France
Old 09-04-2015 , 12:04   Re: How to change entity name ?
Reply With Quote #2

Fixed sorry ^^'


Old:
PHP Code:
Format(sTargetNamesizeof(sTargetName), "imprimante-%i-%i"GetClientUserId(StringToInt(sExplode[1])), iCurrentMoney); 
Fix:
PHP Code:
Format(sTargetNamesizeof(sTargetName), "imprimante-%i-%i"StringToInt(sExplode[1]), iCurrentMoney); 
__________________
I'm French, sorry for my bad english...
Icetea16 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-04-2015 , 12:10   Re: How to change entity name ?
Reply With Quote #3

You can also DispatchKeyValue on the "targetname" key to change the name of the entity.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 09-04-2015 , 12:15   Re: How to change entity name ?
Reply With Quote #4

And you should allways avoid that (particurarly players), if you are not renaming your entities. It might easily break something.

Eg: gore plugin renames players and that breaks everything you want to parent to players...
KissLick is offline
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 07:35.


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