AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   client_print variable (https://forums.alliedmods.net/showthread.php?t=86618)

Otsegolectric! 02-28-2009 07:56

client_print variable
 
I want to print a variable in client_print. I read some around at http://amxmodx.org/doc/ but the %s and %d stuff confuses me and I see no reference to any variable. Could someone explain this to me?

Code:

client_print(0, print_center, "**DEBUG** there are currently ## bots")

TheRadiance 02-28-2009 08:12

Re: client_print variable
 
Hi.
%s - String.
Example:
PHP Code:

new szString32 ]
formatszStringsizeof szString ) - 1"String Phrase" )
client_print0print_chat"This is your phrase: %s"szString 

%d or %i - Integer / cell.
Example:
PHP Code:

new iValue 1
client_print
0print_chat"This is your Integer: %d"iValue 

or
PHP Code:

new szString32 ]
formatszStringsizeof szString ) - 1"1" )
client_print0print_chat"This is your Integer: %d"str_to_num szString ) ) 


Otsegolectric! 02-28-2009 08:40

Re: client_print variable
 
Thanks.

Bugsy 02-28-2009 10:13

Re: client_print variable
 
Quote:

Originally Posted by Otsegolectric! (Post 770930)
Thanks.

If you want to print a float (decimal number) use %f

PHP Code:

new Float:fNum 1.24;
client_printid print_chat "number is %f" fNum ); 


Exolent[jNr] 02-28-2009 14:00

Re: client_print variable
 
There is a full list of these in a thread that I remember arkshine and myself talking about them.

Mlk27 03-01-2009 01:39

Re: client_print variable
 
this one?

http://www.cplusplus.com/reference/c...io/printf.html

Otsegolectric! 03-01-2009 08:18

Re: client_print variable
 
Yeah I figured that.

I needed this for a float-cvar zm_botskill (yes im editing the zombiemod for ts):

PHP Code:

server_cmd("addcustombot Zombie Zombies %f"get_pcvar_float(cvar_botskill)) 


Dores 03-01-2009 09:10

Re: client_print variable
 
Quote:

Originally Posted by Bugsy (Post 770970)
If you want to print a float (decimal number) use %f

PHP Code:

new Float:fNum 1.24;
client_printid print_chat "number is %f" fNum ); 


Also you can limit the number of digits to show up after the decimal point like so:
PHP Code:

new Float:float 0.45;
client_print(0print_chat"Float's value is: %.1f"float);
// It will print 0.4 



All times are GMT -4. The time now is 16:56.

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