Raised This Month: $ Target: $400
 0% 

Print a text to player like amx_tsay?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Ramirez
Member
Join Date: Aug 2004
Old 01-11-2005 , 20:54  
Reply With Quote #2

The client_print native can be used to do print multiple type of text.

The syntax is:
client_print ( index, type, const message[], ... )

Where "index" is the player that will receive the message.
Type is the type of msg you want..
The types are:
  • print_chat - chat text
    print_console - console message
    print_notify - console in dev mode
    print_center - center say

But if you want to print a colored message in the amx_tsay style
I would use the following native:

set_hudmessage ( red=200, green=100, blue=0, Float=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2, channel=4 )

It is a little harder to use.
But looking at some plugins using it and reading the documentation on this function should be enough to understand it.

Basically, you set the color, the position and the effect then print it with another native:

show_hudmessage ( index, message[], ... )

Where again index is the player that will see the message
And message[] is a string of character(the msg seen)

You can use the following native to create messages:

format ( output[], len, const format[], ... )

This native offers a good amount of control over your message.

You can set it to print a message containing Integers, Floats and Strings.
For example,

new dest[21]
new age = 17
format(dest, 20, "Hello %s. You are %d years old", "Tom",age)
//Dest will contain "Hello Tom. You are 17 years old.

In this case, the "dest" variable will contain:

Hello %s. You are %d years old

%s being a string of character ("Tom" is an exmaple)
%d being an integer value (17 being an example)
And also %f wich isn't used in this example being a float value (1.17 would be a good example)

Try playing with these and if you got anymore question just ask me.

I've supplied a small example to help you learn:




Code:
#include <amxmodx> public plugin_init() {     register_plugin("Hello World","1.0","Ramirez")     register_clcmd("amx_test","mymsg",ADMIN_USER,"- Prints a message") } public mymsg(id) {     set_hudmessage( 200, 100, 0, -1.0, 0.35, 0, 6.0, 12.0, 0.1, 0.2, 4 ) // Sets the msg properties     show_hudmessage(id,"Hello world!") //Prints "Hello World!" in the user's screen with the properties of set_hudmessage return PLUGIN_HANDLED }

Good luck!
Ramirez is offline
 



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 19:29.


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