Raised This Month: $ Target: $400
 0% 

Problem with Variables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bigbuck
Senior Member
Join Date: Jul 2009
Old 09-29-2009 , 10:39   Problem with Variables
Reply With Quote #1

I'm having a bit of a problem using placeholders, sorry if I'm using the wrong term, in my plugin. Take this line for example:

PHP Code:
LogToFile(FF_LogFile"%s attacked %2s for %3s damage and was slapped with %4s damage"attacker_namevictim_nametotal_damageslap_damage); 
The attacker and victim names show just fine, but the damage will show whatever it wants if it shows at all. total_damage is the dmg_health and dmg_armor added together from the player_hurt event and is left as an int. slap_damage is a ConVarInt. I will attach the plugin in case you want to look at the whole thing.
Attached Files
File Type: sp Get Plugin or Get Source (css_ff_manager.sp - 292 views - 5.5 KB)

Last edited by Bigbuck; 09-29-2009 at 13:09.
Bigbuck is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-29-2009 , 15:32   Re: Problem with Variables
Reply With Quote #2

You don't need to do %2s, %3s, etc, only %s. Also you should use either %i or %d for integer types. I suggest you take a look at this section of the wiki:
http://wiki.alliedmods.net/Format_Cl...mat_Specifiers
bl4nk is offline
Bigbuck
Senior Member
Join Date: Jul 2009
Old 09-29-2009 , 15:50   Re: Problem with Variables
Reply With Quote #3

Thanks, I was looking for that yesterday and I guess I didn't look hard enough. Just to be sure, this would be correct wouldn't it?

PHP Code:
LogToFile(FF_LogFile"%s attacked %s for %i damage and was slapped with %i damage"attacker_namevictim_nametotal_damageslap_damage); 
Bigbuck 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 22:59.


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