AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Trash (https://forums.alliedmods.net/forumdisplay.php?f=22)
-   -   [HOWTO]Player Connects (https://forums.alliedmods.net/showthread.php?t=51424)

FormulaZero 02-17-2007 18:47

[HOWTO]Player Connects
 
* This will explain and tell you how to get when a player is connected*

  • Information
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.
PHP Code:

new name[32

Characters here. [32] stores information.

Now let's get his name!
PHP Code:

get_user_name(idname31

This saves the users name.

We can set our hud message now!
PHP Code:

set_hudmessage(2250015450665100, -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(idname31

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(idname31)
    
set_hudmessage(225000.050.4506.06.00.50.5, -1)
    
show_hudmessage(0"Hello and Welcome %s!."name)


%s - This stores and shows the clients name. This is a character array. (String)



P34nut 02-17-2007 18:52

Re: [FAQ]Player Connect
 
Quote:

Originally Posted by FormulaZero
The 0 makes sure that only the player connecting is shown this message. "Hello and Welcome %s" is the message that the player will see.

This is so wrong.
The 0 will show the hud message to everyone

FormulaZero 02-17-2007 18:53

Re: [HOWTO]Player Connects
 
Oh, type error put 0 instead of 1 sorry.
FIXED

P34nut 02-17-2007 18:55

Re: [HOWTO]Player Connects
 
Well its still wrong.
The first parameter of show_hudmessage needs to be the ID of the player and that is not always 1

In this case use id

FormulaZero 02-17-2007 18:56

Re: [HOWTO]Player Connects
 
FIXED

Brad 02-17-2007 18:58

Re: [HOWTO]Player Connects
 
This 'tutorial' is useless. Trashing since it doesn't even belong anywhere else.


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

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