Amaroq7 / SPMod

SourcePawn Scripting Engine for Half-Life 1 based games
GNU General Public License v3.0
27 stars 12 forks source link

Cvar manager #17

Closed Garey27 closed 5 years ago

Garey27 commented 6 years ago

Description

Implementation of Cvar manager

Motivation and Context

Fix #8 Fix #11

How has this been tested?

public void TestCvarChange_Callback(Cvar cvar, const char[] oldValue, const char[] newValue)
{
        printToServer("Cvar changed:%s\n", newValue);
}
public void OnPluginInit()
{
    printToServer("Create cvar with value = 5.0\n");
    Cvar c = Cvar("test", "5.0", None);
    printToServer("Add callback to cvar\n");
    c.AddHookOnChange(TestCvarChange_Callback);
    printToServer("Print as float\n");
    printToServer("%f\n", c.GetFloat());
    printToServer("Set value to 2.0\n");
    c.SetFloat(2.0);
    printToServer("Print as float\n");
    printToServer("%f\n", c.GetFloat());
    printToServer("Set value to 1337\n");
    c.SetInt(1337);
    printToServer("Print as int\n");
    printToServer("%d\n", c.GetInt());
}

Screenshots (if appropriate):

photo_2018-06-19_08-24-43

Types of changes

Checklist:

Garey27 commented 6 years ago

Needs review

Garey27 commented 6 years ago

Need another review 🐮

Garey27 commented 6 years ago

Sorry, no need review atm, need to fix (I wasn't opened you request full list and fixed only part lol)

Amaroq7 commented 5 years ago

Looks good to me. Thanks for work done implementing it.