Raised This Month: $ Target: $400
 0% 

[Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-16-2013 , 22:47   [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #1

Hello,

edit : new error GetConVarInt (see below)

Thanks


Solved: thanks to author (Sir) of this script

Last edited by eric0279; 09-19-2013 at 19:31.
eric0279 is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-16-2013 , 23:01   Re: "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #2

Line numbers would help greatly, but it doesn't look like that would compile at all unfortunately. You're missing a definition and assignment for g_hPubBlock. FindConVar isn't guaranteed to succeed either, so maybe it's that.
KyleS is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 09-16-2013 , 23:47   Re: "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #3

FIXED


PHP Code:
GetConVarBool(g_hVanillaBlock
Replace (This is a Integer, not a Boolean.)
PHP Code:
GetConVarInt(g_hVanillaBlock
-------------------------------------------
PHP Code:
GetConVarBool(g_hReady
Replace (This is a Integer, not a Boolean.)
PHP Code:
GetConVarInt(g_hReady
-------------------------------------------
PHP Code:
GetConVarBool(g_hPubBlock
Change (Because this is not a ConVar, just a boolean.
PHP Code:
g_hPubBlock 
-------------------------------------------
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <smlib>
#include <colors>

new Handle:g_hVanillaBlock        INVALID_HANDLE;
new 
Handle:hTimer            INVALID_HANDLE;
new 
Handle:g_hReady            INVALID_HANDLE;

new 
bool:bHandled false;
new 
bool:g_hPubBlock false;

public 
OnPluginStart()
{
    
g_hVanillaBlock CreateConVar("4d2_Vanilla_bloked""1""Test");
    
g_hReady FindConVar("l4d_ready_enabled");
    
    
bHandled false;
}

public 
OnClientPostAdminCheck(client)
{
    if(!
GetConVarInt(g_hVanillaBlock) || GetConVarInt(g_hReady) || IsAdminHere() > || !CheckMaps()) return;
    
    if (
bHandled)
    {
        if (
IsAdminHere() > 0Handled();
        return;
    }

    if(
IsValidClient(client) && !IsFakeClient(client))
    {
        
bHandled true;
        
CreateTimer(25.0NotifyPubs_TIMER_REPEAT);
        
hTimer CreateTimer(100.0KickPubs);
        
    }
}


public 
OnClientDisconnect_Post(client)
{
    if(
GetRealClientCount() == 0Handled();
    else
    {
        if(!
g_hPubBlock || bHandled || GetConVarInt(g_hReady) || IsAdminHere() > || !CheckMaps()) return;
        
        if(
IsValidClient(client) && !IsFakeClient(client))
        {
            
bHandled true;
            
CreateTimer(25.0NotifyPubs_TIMER_REPEAT);
            
hTimer CreateTimer(100.0KickPubs);
        }
    }        
}

public 
Action:NotifyPubs(Handle:Timerany:client)
{
    
//Notify
}

public 
Action:KickPubs(Handle:Timerany:junk)
{
    
//Kick
}

bool:IsValidClient(client)
{
    if (
client <= || client MaxClients) return false;
    if (!
IsClientInGame(client)) return false;
    if (
IsClientSourceTV(client) || IsClientReplay(client)) return false;
    return 
true;
}

GetRealClientCount()
{
    new 
clients 0;
    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i)) clients++;
    }
    return 
clients;
}

IsAdminHere()
{
    new 
clients 0;
    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && IsClientConnected(i) && Client_IsAdmin(i)) clients++;
    }
    return 
clients;
}

Handled()
{
    
bHandled false;
    if (
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
        
hTimer INVALID_HANDLE;
    }
}

CheckMaps()
{
    
decl String:mapname[128];
    
GetCurrentMap(mapnamesizeof(mapname));
    
    if (
strncmp(mapname"c1"2) == 0
    
|| strncmp(mapname"c2"2) == 0
    
|| strncmp(mapname"c3"2) == 0
    
|| strncmp(mapname"c4"2) == 0
    
|| strncmp(mapname"c6"2) == 0
    
|| strncmp(mapname"c7"2) == 0
    
|| strncmp(mapname"c8"2) == 0
    
|| strncmp(mapname"c9"2) == 0
    
|| strncmp(mapname"c10"3) == 0
    
|| strncmp(mapname"c11"3) == 0
    
|| strncmp(mapname"c12"3) == 0
    
|| strncmp(mapname"c13"3) == 0) return true;
    else if (
strncmp(mapname"c5"2) == 0)
    {
        if (
strncmp(mapname"c5m1_dark"9) != 0
        
&& strncmp(mapname"c5m2_dark"9) != 0
        
&& strncmp(mapname"c5m3_dark"9) != 0
        
&& strncmp(mapname"c5m4_dark"9) != 0
        
&& strncmp(mapname"c5m5_dark"9) != 0) return true;
    }
    
    return 
false;

__________________

Last edited by Marcus101RR; 09-16-2013 at 23:50.
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-17-2013 , 05:40   Re: "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #4

Thanks Marcus101RR, work's fine!
eric0279 is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-18-2013 , 22:05   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #5

wtf....

now is GetConVarInt :

Quote:
L 09/19/2013 - 03:571: SourceMod error session started
L 09/19/2013 - 03:571: Info (map "c2m1_highway") (file "errors_20130919.log")
L 09/19/2013 - 03:571: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:571: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:571: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:573: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:573: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:573: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:576: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:576: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:576: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:576: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:576: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:576: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:576: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:576: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:576: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:57:55: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:57:55: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:57:55: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:58:01: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 09/19/2013 - 03:58:01: [SM] Displaying call stack trace for plugin "PubLocker.smx":
L 09/19/2013 - 03:58:01: [SM] [0] Line 45, G:\L4D2\Backup_Myriapulse\Server\addons\sourc emod\scripting\PubLocker.sp::OnClientPostAdmi nCheck()
L 09/19/2013 - 03:58:12: Error log file session closed.
code complet :
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <l4d2util>
#include <sdkhooks>
#include <smlib>
#include <colors>

// - Enable/Disable "Fixes"
new Handle:g_hServerCVar             INVALID_HANDLE;
new 
Handle:g_hPubBlock               INVALID_HANDLE;

// - PubBlocker
new boolbHandled false;
new 
HandlehTimer INVALID_HANDLE;
new 
Handleg_hReady INVALID_HANDLE;

public 
Plugin:myinfo 
{
    
name "L4D2 Game/Server Tweaks&Fixes",
    
author "Sir, Thrawn, Griffin",
    
description "What Name says",
    
version "1.4a",
    
url "https://github.com/SirPlease/SirCoding"
}

public 
OnPluginStart()
{
    
//CVars.
    
g_hServerCVar CreateConVar("GSTF_ServerCVar""1""Block Server CVar Changes being Broadcasted?");
    
g_hPubBlock CreateConVar("GSTF_BlockPub""1""Only allow Competitive Games on Server?");
    
g_hReady FindConVar("l4d_ready_enabled");

    
//Server CVar
    
HookEvent("server_cvar"Event_ServerCvarEventHookMode_Pre);
    
    
bHandled false;
}

public 
OnClientPostAdminCheck(client)
{
    
//if(!GetConVarBool(g_hPubBlock) || GetConVarBool(g_hReady) || IsAdminHere() > 0 || !CheckMaps()) return;
    
    
if(!GetConVarInt(g_hPubBlock) || bHandled || GetConVarInt(g_hReady) || IsAdminHere() > || !CheckMaps()) return;
    
    if (
bHandled)
    {
        if (
IsAdminHere() > 0Handled();
        return;
    }
    
    if(
IsValidClient(client) && !IsFakeClient(client))
    {
        
bHandled true;
        
CreateTimer(25.0NotifyPubs_TIMER_REPEAT);
        
hTimer CreateTimer(150.0KickPubs);    
    }
}

//Server Cvar
//-----------

public Action:Event_ServerCvar(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
GetConVarBool(g_hServerCVar)) return Plugin_Handled;
    return 
Plugin_Continue;
}

//Block Non-Competitive Games
//---------------------------

public OnClientDisconnect_Post(client)
{
    if(
GetRealClientCount() == 0Handled();
    else
    {
        if(!
GetConVarInt(g_hPubBlock) || bHandled || GetConVarInt(g_hReady) || IsAdminHere() > || !CheckMaps()) return;
        
        if(
IsValidClient(client) && !IsFakeClient(client))
        {
            
bHandled true;
            
CreateTimer(25.0NotifyPubs_TIMER_REPEAT);
            
hTimer CreateTimer(150.0KickPubs);
        }
    }        
}

public 
Action:NotifyPubs(Handle:timer)
{
    if(!
bHandled) return Plugin_Stop;
    
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Only use this server for {default}Competitive Play");
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Everyone will be kicked unless a {default}!match {blue}config is loaded");
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Vanilla server: {default}mm_dedicated_force_servers {blue}46.18.93.40:27015 {default}or mm_dedicated_force_servers {blue}141.138.153.190:27015");
    return 
Plugin_Continue;
}

public 
Action:KickPubs(Handle:timer)
{
    
ServerCommand("sm_kick @all Only Competitive Play on this Server");
    
Handled();
}

//Stocks and such
//------------------------------

bool:IsValidClient(client)
{
    if (
client <= || client MaxClients) return false;
    if (!
IsClientInGame(client)) return false;
    if (
IsClientSourceTV(client) || IsClientReplay(client)) return false;
    return 
true;
}

GetRealClientCount()
{
    new 
clients 0;
    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i)) clients++;
    }
    return 
clients;
}

IsAdminHere()
{
    new 
clients 0;
    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && IsClientConnected(i) && Client_IsAdmin(i)) clients++;
    }
    return 
clients;
}

Handled()
{
    
bHandled false;
    if (
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
        
hTimer INVALID_HANDLE;
    }
}

// Check if Config has to be loaded - Makes exception for Custom Map play.
// Sloppy, but effective.
CheckMaps()
{
    
decl String:mapname[128];
    
GetCurrentMap(mapnamesizeof(mapname));
    
    if (
strncmp(mapname"c1"2) == 0
    
|| strncmp(mapname"c2"2) == 0
    
|| strncmp(mapname"c3"2) == 0
    
|| strncmp(mapname"c4"2) == 0
    
|| strncmp(mapname"c6"2) == 0
    
|| strncmp(mapname"c7"2) == 0
    
|| strncmp(mapname"c8"2) == 0
    
|| strncmp(mapname"c9"2) == 0
    
|| strncmp(mapname"c10"3) == 0
    
|| strncmp(mapname"c11"3) == 0
    
|| strncmp(mapname"c12"3) == 0
    
|| strncmp(mapname"c13"3) == 0) return true;
    else if (
strncmp(mapname"c5"2) == 0)
    {
        if (
strncmp(mapname"c5m1_dark"9) != 0
        
&& strncmp(mapname"c5m2_dark"9) != 0
        
&& strncmp(mapname"c5m3_dark"9) != 0
        
&& strncmp(mapname"c5m4_dark"9) != 0
        
&& strncmp(mapname"c5m5_dark"9) != 0) return true;
    }
    
    return 
false;

eric0279 is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 09-18-2013 , 23:06   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #6

PHP Code:
GetConVarInt(g_hReady
We do not have control over other plugin's variables, make sure this variable is an integer and not a boolean.
__________________

Last edited by Marcus101RR; 09-18-2013 at 23:07.
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 09-18-2013 , 23:40   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #7

It doesn't matter. All ConVars are strings and GetConVarInt/Bool just changes it into a format that you want/expect. In this case, you'd except this ConVar to be a boolean. The issue could likely be that l4d_ready_enabled doesn't exist at the moment this plugin starts, as that ConVar comes from another plugin. I'd recommend searching for the ConVar OnConfigsExecuted instead of OnPluginStart, as well as checking if FindConVar returns INVALID_HANDLE for when the ConVar still can't be found.
__________________
11530 is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-19-2013 , 01:09   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #8

l4d_ready_enabled exist on OnPluginStart (return 0).

made ​​some changes and if I have a problem, I'll look for OnConfigsExecuted

Thanks

eric0279 is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 09-19-2013 , 01:33   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #9

"Solved", "See below".
I don't see a solution. I don't even know what the problem caused.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-19-2013 , 01:35   Re: [Solved] "GetConVarBool" reported: Invalid convar handle 0 (error 4) ?
Reply With Quote #10

Quote:
Originally Posted by Dr. Greg House View Post
"Solved", "See below".
I don't see a solution. I don't even know what the problem caused.
I changed to avoid any ambiguity ;)
eric0279 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 02:27.


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