AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Handle joins to server (https://forums.alliedmods.net/showthread.php?t=53774)

wpf 04-10-2007 16:34

Handle joins to server
 
Hello!
I'm trying to write a script that will handle player joins to my server. I'm totally new to this so I need a little help and maybe a tip (or lots of).

I have a database with X player names. Each name is associated with a clan id. I'm using AMX Mod X. The idea:

When the first player connects, I want to check if his name does exist in the database. If it does, he will automatically be put in CT or T. If not, he will be banned. The next four from his clan will also be put in the same team.

The next player, whose clan id is not equal to the first player's, will be put in the other team, and of course also the four following clan members. If there's empty slots within, say, 5 minutes, everybody will be kicked out.

Now over to the hard part, get it working. I've read the Wiki and docs on amxmodx.org but I cannot figure out when I will check against the database. I need to hook on some event, but cannot find any "join event".

And how do I kick everybody 5 minutes after the first player has joined if there's less than 10 players connected? Can I use the set_task() function for that?

stupok 04-10-2007 17:09

Re: Handle joins to server
 
Taken from amxmodx.inc:

Code:

/* Called on client connection. */
forward client_connect(id);

/* Called when client gets valid STEAM id (usually
* between client_connect() and client_putinserver()). */
forward client_authorized(id);

/* Called when client is disconnecting from server. */
forward client_disconnect(id);

/* Called when client is entering to a game. */
forward client_putinserver(id);

I would suggest client_putinserver() since I don't know when the player's name is actually accessible. I think you should use steamids instead of names, though.

You can use set_task to execute a function after some period of time, yes.

Something like:

Code:

set_task(300.0, "function")

wpf 04-12-2007 00:54

Re: Handle joins to server
 
thank you!


All times are GMT -4. The time now is 06:33.

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