AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hooking the first connection of a player (https://forums.alliedmods.net/showthread.php?t=146577)

bibu 12-29-2010 14:31

Hooking the first connection of a player
 
How can I get, if the user got the first time on the server? So basically, I would like to print them a special client_print to their first connect.

fysiks 12-29-2010 14:44

Re: Hooking the first connection of a player
 
First connect in what scope?

bibu 12-29-2010 15:05

Re: Hooking the first connection of a player
 
For example I found a new server, connected to it first time. But the second time or more I should not get the client_print.

fysiks 12-29-2010 15:10

Re: Hooking the first connection of a player
 
You would need to create a list of all the people that have connected to the server. Each time someone connects, you check the list. If they are not in the list then print the message and add them to the list. If they are already in the list, don't print the message.

However, this list can get extremely long and can cause adverse side effects. I would not recommend doing this at all.

It may be possible to pull from stats (for this 'list'; not entirely sure though), if they have stats then don't print the message. I'm not sure how often stats reset though. On my clans server they reset after 3500 unique connections.

bibu 12-29-2010 15:21

Re: Hooking the first connection of a player
 
I really don't know how to work with a list or something, so I thought some users here have maybe experience with that also with that server side effects which you now told.

ConnorMcLeod 12-29-2010 15:27

Re: Hooking the first connection of a player
 
I would use nvault because i don't know how to use other systems ;)

Once you have printed to player, set nvault with his steamid to 1.
nvault_get returns 0 if key doesn't exist, this way you can know if users come for first fime.

bibu 12-30-2010 13:50

Re: Hooking the first connection of a player
 
Thanks connor, would something like this be right?

PHP Code:

public client_putinserver(id)
{
    if(
is_user_bot(id))
    {
        return 
PLUGIN_HANDLED
    
}
    new 
szKey[40];
    
formatexszKey charsmaxszKey ) , "%sCONNECT" g_szAuthID[id] );
    
    new 
iConnect nvault_getg_Vault szKey );
    
    if ( 
iConnect )
    {
        
client_printid print_chat "[First Connect] This is your more times to connecting to our server. =)" );
    }
    else
    {
        
nvault_setg_Vault szKey "1" );
        
client_printid print_chat "[First Connect] This is your first time to connecting to our server. =)" );
    }


It returns me everytime true. I also tried removing the vault file, but no success.

ConnorMcLeod 12-30-2010 14:05

Re: Hooking the first connection of a player
 
You don't need to format the nvault key, steamid is enough if the vault is unique.

bibu 12-31-2010 06:08

Re: Hooking the first connection of a player
 
Ok, did that, still it doesn't work how it should.

SpeeDeeR 12-31-2010 09:55

Re: Hooking the first connection of a player
 
Actually it does but how do you think it will print the messages when the player is still connecting.


All times are GMT -4. The time now is 01:59.

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