Raised This Month: $ Target: $400
 0% 

Player connecting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
webbhelp
Member
Join Date: Jan 2010
Old 02-01-2010 , 10:33   Player connecting
Reply With Quote #1

Hi!

I want to now if a player connect, and I will then kick him if the game already has start!
If not, His ingame name will be showed in a panel/menu, with tag: connecting

The things is: How do I check if a player is Connecting!
if the game has start, how do i "kick" him, and give him a message before he is ingame: "You can't connect right now, the game is already running".

Which functions is there I can use to check if the player is connected and/or the player is ConnectING?

Thanks!
webbhelp is offline
Frus
Senior Member
Join Date: Aug 2009
Old 02-01-2010 , 10:39   Re: Player connecting
Reply With Quote #2

Code:
if (IsClientConnected(client) && !IsClientInGame(client))
I would expect does what you want in your final question.

But I would expect these forwards would be the most helpful to you:

http://docs.sourcemod.net/api/index....d=show&id=388&
http://docs.sourcemod.net/api/index....d=show&id=389&

Code:
forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
forward OnClientPutInServer(client);
(If it isn't clear, onclientconnect gets fired first, more or less the instant they double click your server in server browser, onclientputinserver or isclientingame are fired more or less when they finish loading).

Although I have to ask why sv_password isn't suitable for what you need.

Last edited by Frus; 02-01-2010 at 10:41.
Frus is offline
webbhelp
Member
Join Date: Jan 2010
Old 02-03-2010 , 04:49   Re: Player connecting
Reply With Quote #3

I don't want to use sv_password because if the game/pcw, hasn't begun, you got access to join the server, but if it has started, you will receive a message like "The game has already begun, and you can't connect right now"

forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);

That seems to be a good one, rejectmsg is what I want to give the client who is trying to connect.

But one thing:
Is that a function, or what is it, forward, made me confused actually!
I see it is a bool, so I think it's not a function, more like a method, in an if(), or?

What is forward?

Thanks!
webbhelp is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2010 , 06:07   Re: Player connecting
Reply With Quote #4

Have you already read the sourcemod doc ?

http://wiki.alliedmods.net/Introduct...cePawn#Publics

Forwards are like global events that get called if your plugin provides a public function for it. There is nothing you have todo except specifying the function.

the bool: just is the type of the return value of the function.
you should have a look at other plugins and see how they work and especially read the docs.

Greetings ~Berni
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
webbhelp
Member
Join Date: Jan 2010
Old 02-09-2010 , 13:25   Re: Player connecting
Reply With Quote #5

I don't get it work, but I am pretty sure I did wrong to and I think I now what the wrong is:


public bool:OnClientConnect(client, new string:rejectMsg[40] = "The game has already begun, try another time", sizeof(rejectMsg) )
{
if(started == true)
{
return false;
}
}

I got a several of error message: Invalid function or declaration... I think the problem is new string:rejectMsg..., How do I write instead if I want an error message when I use return false;?

Thanks!
webbhelp is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 02-09-2010 , 19:28   Re: Player connecting
Reply With Quote #6

The rejectMsg string is provided by the function. I don't think it can have a default value either.

Here...
PHP Code:
public bool:OnClientConnect(clientString:rejectmsg[], maxlen)
{
    if (
started)
    {
        
Format(rejectmsgmaxlen"The game has already begun, try another time.");
        return 
false;
    }
    return 
true;

How bout letting people join spectator instead of giving them the boot .
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
webbhelp
Member
Join Date: Jan 2010
Old 03-26-2010 , 09:10   Re: Player connecting
Reply With Quote #7

Hi!

Sry I have forgot to reply but THANKS a lot for helping me

This is A PCW script, so... the player will not get into spectator
webbhelp is offline
Reply



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 05:14.


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