Raised This Month: $ Target: $400
 0% 

slow % in hud [solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-10-2007 , 17:06   Re: slow % in hud
Reply With Quote #1

try this please:

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("print","print")
}
public print(){
new string[32]
new pos
pos += formatex( string[pos], 32-pos, " (%d%% first try)",floatround(35.333))
client_print(0,print_chat,"%s",string)
set_hudmessage(255, 0, 0, -1.0, 0.20, 0, 6.0, 12.0,_ ,_ , -1)
show_hudmessage(0,string)
print2()

}
public print2(){
new string[32]
new pos
pos += format( string[pos], 32-pos, " 2(%d%% | % | ^% | \% | /% | %% again| of normal)",floatround(35.333))
client_print(0,print_chat,"%s",string)
set_hudmessage(255, 255, 255, -1.0,0.30 , 0, 6.0, 12.0, _,_ , -1)
show_hudmessage(0,string)

}

only %% works in print chat, nothing else works, but amx_tsay % works
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 10-10-2007 , 22:32   Re: slow % in hud
Reply With Quote #2

Oh now I get it. And I hope I'll be able to explain the problem as English is not my own language.

I'll simplify what you've typed:

PHP Code:
formatex(string[pos], 32-pos"%d %%"floatround(35.333));
client_print(0,print_chat,"%s",string);
set_hudmessage(25500, -1.00.2006.012.0,,, -1);
show_hudmessage(0,string); 
There is a major difference between this:

PHP Code:
client_print(0,print_chat,"%s",string); 
and this:

PHP Code:
show_hudmessage(0,string); 
You first pass your format to formatex function. All %% will become %. Then you pass resulting string as a string parameter to client_print to print it. That's fine.

But when you pass a string into the show_hudmessage, you don't pass it as a string parameter but format itself! It means, that your % in string that was processed by vformat is processed again and is considered not as escape sequence but format initiator.

I assume the solution to that would be:

PHP Code:
set_hudmessage(255255255, -1.0,0.30 06.012.0_,, -1);
show_hudmessage(0"%s"string); 
Check that out, I can't (falling asleep). Hope it helps.
__________________
alien is offline
Send a message via ICQ to alien
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-10-2007 , 23:50   Re: slow % in hud
Reply With Quote #3

holy crap nice explanation

now it works! thx!

WC3_StatusText( id, TXT_RACE_INFO,"%s", szMsgz );
show_hudmessage( id, "%s",szFormattedText );

woot, that was hard
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow 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:58.


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