AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   print_chat commands (https://forums.alliedmods.net/showthread.php?t=127806)

macas5 05-25-2010 03:47

print_chat commands
 
Hello i am making a plugin and in one tutorial i found commands like ^n, %i etc. I know what means ^n, but i don't know others could anyone make a list of these and say how to use them and what is they for? Thanks in advace :)

mysticssjgoku4 05-25-2010 03:53

Re: print_chat commands
 
Please anyone feel free to correct me, but I believe:

Some Examples:
%f = Float value = 0.000000
%.2f = 0.00
%.3f = 0.000

%s = String = "Wuzzup!"
%i = Integer = 4
%d = Data (I think this can be used universally, should show string/integer/floats)
--------------------
Usually you use these when formatting some type of string, as in for a message related to usually health, name, steamid, and other generated information.
Say you want to display the client id and steamid of a user, you would need to do...

Code:
new s[32]; get_user_authid(id,s,sizeof(s)); new msg[64]; format(msg,sizeof(msg),"ID: %i, SteamID: %s",id,s);

macas5 05-25-2010 04:13

Re: print_chat commands
 
Thanks :) just as i wanted :) theres left one question. Where you writed
Quote:

format(msg,sizeof(msg),"ID: %i, SteamID: %s",id,s);
do variables (id, s) go in order, or somehow bind it?

Brreaker 05-25-2010 09:24

Re: print_chat commands
 
In order, the first %i is represented by the first variable after the "", in this case, ID...The second is represented by the second variable, in this case S...And so on :)
As far as I know, %d = %i = integer ( not sure about that )
also, for client_print you can use
PHP Code:

client_print(idprint_chat""ID: %iSteamID: %s", id, s); 

And as I know:
^n = new line
^t = TAB spacing

Now if I'm right, in Pawn you can use the characters from c++ language like
Code:

\n        newline
\r        carriage return
\t        tab
\v        vertical tab
\b        backspace
\f        form feed (page feed) // I don't think you will find it in pawn
\a        alert (beep) // neither this one
\'        single quote (')
\"        double quote (")
\?        question mark (?)
\\        backslash (\)

using ^ instead of \ so it will be
Code:

^n        newline
^r        carriage return
^t        tab
^v        vertical tab
^b        backspace
^f        form feed (page feed)
^a        alert (beep)
^'        single quote (')
^"        double quote (")
^?        question mark (?)
^\        backslash (\)

Or you could use
PHP Code:

#define ctrlchar '\' 


macas5 05-25-2010 10:26

Re: print_chat commands
 
I tried to make
Code:

new menu= menu_create("Choose where to spend points. You currently have %i points", "pts_handler", playerpts[id])
But i still get "Choose where to spend points. You currently have %i points" without getting a playerpts[id] number. Help :cry:

mysticssjgoku4 05-25-2010 13:23

Re: print_chat commands
 
Quote:

Originally Posted by macas5 (Post 1190677)
I tried to make
Code:

new menu= menu_create("Choose where to spend points. You currently have %i points", "pts_handler", playerpts[id])
But i still get "Choose where to spend points. You currently have %i points" without getting a playerpts[id] number. Help :cry:

Link to menu_create
http://www.amxmodx.org/funcwiki.php?go=func&id=798
Code:
menu_create ( title[], handler[], ml=0 )

Link to format
http://www.amxmodx.org/funcwiki.php?go=func&id=49
Code:
format ( output[], len, const format[], ... )

Ahh, see unforunately you cannot use that function "menu_create" to format a string. So you would have to do something like..
Code:
new szTitle[64]; format(szTitle,sizeof(szTitle),"Choose where to spend points. You currently have %i points",playerpts[id]); new menu = menu_create(szTitle, "pts_handler");

Hope this helps!

macas5 05-25-2010 14:14

Re: print_chat commands
 
And again mysticssjgoku4 saves the day! :D Thank you very much :)

mysticssjgoku4 05-25-2010 15:35

Re: print_chat commands
 
np =)


All times are GMT -4. The time now is 05:23.

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