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

Client is not in-game error [Solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HelpMe
Senior Member
Join Date: Jun 2013
Location: Home
Old 08-25-2013 , 17:14   Client is not in-game error [Solved]
Reply With Quote #1

Solution: https://forums.alliedmods.net/showpo...23&postcount=2

When I load my plugin it gets those errors in the bottom I do not really know how to fix it so I need help once again... and yes I know the
Code:
OnClientConnected
{
Players += 1;
}
code is bad but if you have a better idea post it please :I



Code:
#include <sourcemod>
#include <clients>
#include <morecolors>

//Cvars|Handles
new Players = 0
new Handle:h_HUDTIMER = INVALID_HANDLE;
new Handle:HUDTIMER = INVALID_HANDLE;
new Handle:h_HUDFADEIN;
new Handle:h_HUDFADEOUT;
new Handle:h_HUDHOLDTIME;
new Handle:cvarRed;
new Handle:cvarGreen;
new Handle:cvarBlue;
new Handle:cvarAlpha;
new Handle:cvarhudx;
new Handle:cvarhudy;
//VARIABLES
new g_Red;
new g_Green;
new g_Blue;
new g_Alpha;
new Float:Hudx;
new Float:Hudy;
new Float:Holdtime;
new Float:Fadein;
new Float:Fadeout;

public Plugin:myinfo = 
{
	name = "ServerPlayers",
	author = "Benjamin",
	description = "How many players there is in server",
	version = "2.0",
	url = "http://steamcommunity.com/id/BenjaminHT/"
}

public OnPluginStart()
{
	cvarhudx = CreateConVar("sm_hudx", "0.043", "Hud message x position. -1 = center.", FCVAR_PLUGIN, true, -1.0, true, 1.0);
	cvarhudy = CreateConVar("sm_hudy", "-1.0", "Hud message y position. -1 = center.", FCVAR_PLUGIN, true, -1.0, true, 1.0);
	cvarAlpha = CreateConVar("sm_hudalpha", "100.0", "Alpha.", FCVAR_PLUGIN, true, 0.0, true, 255.0);
	cvarBlue = CreateConVar("sm_hudblue", "20.0", "Color in RGB(Blue).", FCVAR_PLUGIN, true, 0.0, true, 255.0);
	cvarGreen = CreateConVar("sm_hudgreen", "255.0", "Color in RGB(Green).", FCVAR_PLUGIN, true, 0.0, true, 255.0);
	cvarRed = CreateConVar("sm_hudred", "90.0", "Color in RGB(Red).", FCVAR_PLUGIN, true, 0.0, true, 255.0);
	h_HUDFADEOUT = CreateConVar("sm_hud_fadeout_time", "1.0", "How much time it should take to fade out.", FCVAR_PLUGIN, true, 0.1, true, 5.0);
	h_HUDFADEIN = CreateConVar("sm_hud_fadein_time", "1.0", "How much time it should take to fade in.", FCVAR_PLUGIN, true, 0.1, true, 5.0);
	h_HUDHOLDTIME = CreateConVar("sm_hud_hold_time", "4.0", "How Long it should hold the text.", FCVAR_PLUGIN, true, 1.0, true, 30.0);
	h_HUDTIMER = CreateConVar("sm_hudtimer", "40.0", "Timer before it prints to the HUD.", FCVAR_PLUGIN, true, 6.0, true, 290.0);
	RegConsoleCmd("sm_players", MaxPlayers);
	AutoExecConfig(true, "server_players");
}

//public OnMapStart()
public OnMapEnd()
{
        if(HUDTIMER != INVALID_HANDLE && CloseHandle(HUDTIMER))
		{
            HUDTIMER = INVALID_HANDLE;
		}
}
public OnClientPutInServer(client)
{
	HUDTIMER = CreateTimer(GetConVarFloat(h_HUDTIMER), TimerCallBack, client, TIMER_REPEAT);
//CreateTimer(h_HUDTIMER, TimerCallBack, client, TIMER_REPEAT);
}

//===============================================================================
//===============================================================================
public Action:TimerCallBack(Handle:timer, any:client)
{
	Hudx = GetConVarFloat(cvarhudx);
	Hudy = GetConVarFloat(cvarhudy);
	Fadein = GetConVarFloat(h_HUDFADEIN);
	Fadeout = GetConVarFloat(h_HUDFADEOUT);
	Holdtime = GetConVarFloat(h_HUDHOLDTIME);
	g_Red = GetConVarInt(cvarRed);
	g_Green = GetConVarInt(cvarGreen);
	g_Blue = GetConVarInt(cvarBlue);
	g_Alpha = GetConVarInt(cvarAlpha);
	
	new Max = GetMaxClients();
	SetHudTextParams(Hudx, Hudy, Holdtime, g_Red, g_Green, g_Blue, g_Alpha, 0, 6.0, Fadein, Fadeout);
	ShowHudText(client, -1, "There is [%d/%d] players connected", Players, Max);
}

public OnClientConnected(client)
{
	Players  += 1;
}

public OnClientDisconnect(client)
{
	Players -= 1;
	
}

public Action:MaxPlayers(client, args)
{
	new Max = GetMaxClients();
	CReplyToCommand(client, "{default}There is [{green}%d/%d{default}] players connected", Players, Max);
}
Code:
L 08/25/2013 - 22:59:56: [SM] Native "ShowHudText" reported: Client 5 is not in-game
L 08/25/2013 - 22:59:56: [SM] Displaying call stack trace for plugin "AllPlayers.smx":
L 08/25/2013 - 22:59:56: [SM]   [0]  Line 84, C:\tf2server\tf\addons\sourcemod\scripting\AllPlayers.sp::TimerCallBack()

Last edited by HelpMe; 09-13-2013 at 07:50.
HelpMe is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 08-25-2013 , 17:32   Re: Client is not in-game error
Reply With Quote #2

You need to verify the client, also you should pass in the userid and not the clientid with GetClientUserId/GetClientOfUserId

PHP Code:
public OnClientPutInServer(client)
{
    
HUDTIMER CreateTimer(GetConVarFloat(h_HUDTIMER), TimerCallBackGetClientUserId(client), TIMER_REPEAT);
}

//===============================================================================
//===============================================================================
public Action:TimerCallBack(Handle:timerany:userID)
{
    new 
client GetClientOfUserId(userID);
    if(
client && IsClientInGame(client)) {
        
Hudx GetConVarFloat(cvarhudx);
        
Hudy GetConVarFloat(cvarhudy);
        
Fadein GetConVarFloat(h_HUDFADEIN);
        
Fadeout GetConVarFloat(h_HUDFADEOUT);
        
Holdtime GetConVarFloat(h_HUDHOLDTIME);
        
g_Red GetConVarInt(cvarRed);
        
g_Green GetConVarInt(cvarGreen);
        
g_Blue GetConVarInt(cvarBlue);
        
g_Alpha GetConVarInt(cvarAlpha);
        
        new 
Max GetMaxClients();
        
SetHudTextParams(HudxHudyHoldtimeg_Redg_Greeng_Blueg_Alpha06.0FadeinFadeout);
        
ShowHudText(client, -1"There is [%d/%d] players connected"PlayersMax);
    }

__________________
Chaosxk 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 09:07.


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