|
Author
|
Message
|
|
BANNED
Join Date: Feb 2007
Location: Sector 7G
|

02-17-2007
, 18:47
[HOWTO]Player Connects
|
#1
|
* This will explain and tell you how to get when a player is connected*
This FAQ will break down a code. This code will contain when a player joins and enters
============================================= ===
First let's write the first part:
PHP Code:
public client_putinserver(id)
Since we got this done we need to go further and set are task!
PHP Code:
set_task(3.0, "welcome", id)
This tells us that the player has just connected. You can replace "welcome" with anything you want, but you'll need that later on. "welcome" is not the message that will be displayed.
Allright, since we know the user has conected let's move on.
Characters here. [32] stores information.
Now let's get his name!
PHP Code:
get_user_name(id, name, 31)
This saves the users name.
We can set our hud message now!
PHP Code:
set_hudmessage(225, 0, 0, 15, 45, 0, 6, 6, 5, 100, -1) show_hudmessage(id, "Hello and Welcome %s!.", name)
The numbers in set_hudmessage sets where the text will be displayed, in this case -1 is needed at the end. Allways seperate numbers with ,.
show_hudmessage - The id makes sure that only the player connecting is shown this message. "Hello and Welcome %s" is the message that the player will see. name at the end was user in
PHP Code:
get_user_name(id, name, 31)
So we must use the same text used in the middle there, in this case it's name.
We have gotten our full code now:
PHP Code:
public client_putinserver(id) { set_task(3.0, "welcome", id) }
public welcome(id) { new name[32] get_user_name(id, name, 31) set_hudmessage(225, 0, 0, 0.05, 0.45, 0, 6.0, 6.0, 0.5, 0.5, -1) show_hudmessage(0, "Hello and Welcome %s!.", name) }
%s - This stores and shows the clients name. This is a character array. (String)
Last edited by FormulaZero; 02-17-2007 at 18:57.
|
|
|
|