Raised This Month: $51 Target: $400
 12% 

Statement Always Proves False?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
QOOOOOOOOQ
Senior Member
Join Date: Dec 2012
Old 12-22-2012 , 23:47   Statement Always Proves False?
Reply With Quote #1

Just a simple print-to-chat when someone actually joins the game, instead of when someone starts loading the map, and these never pass true therefore never print-to-chat that the player has either joined/left, why is that? My suspection is that im not using functions in the exact way their supposed to be used... which i wouldnt know when to/when not to use them at certain times since im so new, advice?


PHP Code:
public OnClientConnected(client){
    if(
Client_IsValid(client) && !IsFakeClient(client)){
        
PrintToChatAll("[NEWS] Player %N has joined the game."client);
    }
}

//and the OnClientDisconnect...

public OnClientDisconnect(client){
    if(
Client_IsValid(client) && !IsFakeClient(client)){
        
PrintToChatAll("[NEWS] Player %N has joined the game."client);
    }

Client_IsValid(client) just says: (using smlib v0.11 by berni btw)
PHP Code:
stock bool:Client_IsValid(clientbool:checkConnected=true//set checkConnected to false to skip the IsClientConnected check
{
    if (
client 4096) {
        
client EntRefToEntIndex(client);
    }

    if (
client || client MaxClients) {
        return 
false;
    }

    if (
checkConnected && !IsClientConnected(client)) {
        return 
false;
    }
    
    return 
true;

QOOOOOOOOQ is offline
Dravu
Senior Member
Join Date: May 2010
Old 12-23-2012 , 00:12   Re: Statement Always Proves False?
Reply With Quote #2

Have you tried doing "Client_IsValid(client, false)" instead?
Dravu is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 12-23-2012 , 06:38   Re: Statement Always Proves False?
Reply With Quote #3

I would personally use OnClientPutInServer and then make an if statement checking if they are connected, ingame and not a fake client.

Code:
public OnClientPutInServer(client)
{
    if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client)){
        PrintToChatAll("[NEWS] Player %N has joined the game.", client);
    }
}
TheGodKing is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 12-23-2012 , 07:59   Re: Statement Always Proves False?
Reply With Quote #4

Quote:
Originally Posted by TheGodKing View Post
I would personally use OnClientPutInServer and then make an if statement checking if they are connected, ingame and not a fake client.

Code:
public OnClientPutInServer(client)
{
    if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client)){
        PrintToChatAll("[NEWS] Player %N has joined the game.", client);
    }
}
IsClientConnected is used within IsClientInGame so the former is not required.
__________________
11530 is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 12-23-2012 , 10:28   Re: Statement Always Proves False?
Reply With Quote #5

Quote:
Originally Posted by 11530 View Post
IsClientConnected is used within IsClientInGame so the former is not required.
Thanks, I was never really sure about those two checks being together, I always had them both to be safe.
TheGodKing is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-23-2012 , 10:45   Re: Statement Always Proves False?
Reply With Quote #6

Quote:
Originally Posted by QOOOOOOOOQ View Post
PHP Code:
    if (client 4096) {
        
client EntRefToEntIndex(client);
    } 
This part is useless as well. Entity references aren't supported for clients.
psychonic is offline
QOOOOOOOOQ
Senior Member
Join Date: Dec 2012
Old 12-23-2012 , 17:07   Re: Statement Always Proves False?
Reply With Quote #7

May i ask what the difference between OnclientPutInServer and OnClientConnected is? Because it seems to me that accordinf to the docs, they do EXACTLY the same thing?
QOOOOOOOOQ is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 12-24-2012 , 05:17   Re: Statement Always Proves False?
Reply With Quote #8

Code:
stock bool:IsClientActual(client)
{
	if (client < 1 || client > MaxClients || !IsClientInGame(client)) return false;
	return true;
}

stock bool:IsClientHuman(client)
{
	if (IsClientActual(client) && !IsFakeClient(client)) return true;
	return false;
}



public OnClientConnected(client)
{ 
    if(IsClientHuman(client)) PrintToChatAll("[NEWS] Player %N has joined the game.", client);
}
Skyy is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-24-2012 , 05:48   Re: Statement Always Proves False?
Reply With Quote #9

Quote:
Originally Posted by QOOOOOOOOQ View Post
May i ask what the difference between OnclientPutInServer and OnClientConnected is? Because it seems to me that accordinf to the docs, they do EXACTLY the same thing?
OnClientConnect/ed are fired once the client connects to the server. OnClientPutInServer fires once they've been placed into the game (normally when the loading screen is finished and the MOTD comes up).
bl4nk 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 20:22.


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