[HELP with Plugin] Some Variable Errors While Compiling

kushal

Anti-Bulle People
Staff member
Content Writer
// C:\Users\Kushal\Desktop\scripting\AutoFS.sp(41) : warning 219: local variable "status" shadows a variable at a preceding level
// C:\Users\Kushal\Desktop\scripting\AutoFS.sp(41) : warning 204: symbol is assigned a value that is never used: "status"
ALSO WANTED SO THAT THE COUNTER SHOWS TIMER, But Declaring the timer g_XYZ = CreateTimer Says Function Prototype Mismatch.
Help To Initiate The Code Better.

C++:
public OnAllPluginsLoaded()
{
    g_h_Status = FindConVar("wm_status");
    int status = g_h_Status.IntValue;
    HookConVarChange(g_h_Status, OnChanges);
}

public OnChanges(Handle cvar, const char[] oldVal, const char[] newVal)
{
    if (CS_GetPlayingCount() == 10  &&  status == 0)
    {
        CreateTimer(1.0, Command_Forcestart, _, TIMER_REPEAT);
        PrintCenterTextAll("Force Start Initiated.");
    }
    PrintHintTextToAll("Starting Force Start When Ten Players Are Present.");

public Action Command_Forcestart(Handle timer)
{
    CreateTimer(15.0, Command_WarStart);
    PrintCenterTextAll("Automatic Starting Force Start in 20 Seconds.");
    PrintHintTextToAll("Starting Force Start in 20 Seconds.");
}

public Action Command_WarStart(Handle timer)
{
    if (CS_GetPlayingCount() == 10)
    {
        ServerCommand("fs");
    }
}
}
 

Vertigo

⍥????
Staff member
Administrator
Next time better post full code.
I can see only one error at this time.
You are declaring status twice. Globally and also in OnAllPluginsLoaded().
Here is the correct code.
C++:
#include <sourcemod>
#include <warmod>

int status;
ConVar g_h_Status;

public void OnAllPluginsLoaded()
{
    g_h_Status = FindConVar("wm_status");
    status = g_h_Status.IntValue;
    HookConVarChange(g_h_Status, OnChanges);
}

public void OnChanges(Handle cvar, const char[] oldVal, const char[] newVal)
{
    if (CS_GetPlayingCount() == 10  &&  status == 0)
    {
        CreateTimer(1.0, Command_Forcestart, _, TIMER_REPEAT);
        PrintCenterTextAll("Force Start Initiated.");
    }
    PrintHintTextToAll("Starting Force Start When Ten Players Are Present.");
}

public Action Command_Forcestart(Handle timer)
{
    CreateTimer(15.0, Command_WarStart);
    PrintCenterTextAll("Automatic Starting Force Start in 20 Seconds.");
    PrintHintTextToAll("Starting Force Start in 20 Seconds.");
}

public Action Command_WarStart(Handle timer)
{
    if (CS_GetPlayingCount() == 10)
    {
        ServerCommand("fs");
    }
}
 

Vertigo

⍥????
Staff member
Administrator
I guess u need to include cstrike.inc cause that stock is not found in either of the includes
You have already included warmod which in turn uses that include.
 
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock