Created
February 11, 2020 12:47
-
-
Save TheByKotik/ce12d9233fbe267476f9d688d270296e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma newdecls required | |
#pragma semicolon 1 | |
#include <sourcemod> | |
public void OnPluginStart() | |
{ | |
RegServerCmd( "sm_test", TEST ); | |
} | |
Action TEST (int args) | |
{ | |
ConVar cv = CreateConVar( "test_convar", "-1", "" ); | |
if ( cv != cv.SetBool( false ) ) { PrintToServer( "Something wrong with SetBool." ); } | |
if ( cv != cv.SetInt( 1 ) ) { PrintToServer( "Something wrong with SetInt." ); } | |
if ( cv != cv.SetFloat( 2.0 ) ) { PrintToServer( "Something wrong with SetFloat." ); } | |
if ( cv != cv.SetString( "Test" ) ) { PrintToServer( "Something wrong with SetString." ); } | |
if ( cv != cv.RestoreDefault() ) { PrintToServer( "Something wrong with RestoreDefault." ); } | |
if ( cv != cv.SetBounds( ConVarBound_Lower, true, -1.0 ) ) { PrintToServer( "Something wrong with RestoreDefault." ); } | |
if ( cv != cv.AddChangeHook( OnCvarChanged ) ) { PrintToServer( "Something wrong with AddChangeHook." ); } | |
if ( cv != cv.RemoveChangeHook( OnCvarChanged ) ) { PrintToServer( "Something wrong with OnCvarChanged." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ) | |
) { PrintToServer( "Something wrong on 1." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ) | |
) { PrintToServer( "Something wrong on 2." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ).SetString( "Test" ) | |
) { PrintToServer( "Something wrong on 3." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ).SetString( "Test" ).RestoreDefault() | |
) { PrintToServer( "Something wrong on 4." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ).SetString( "Test" ).RestoreDefault().SetBounds( ConVarBound_Lower, true, -1.0 ) | |
) { PrintToServer( "Something wrong on 5." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ).SetString( "Test" ).RestoreDefault().SetBounds( ConVarBound_Lower, true, -1.0 ).AddChangeHook( OnCvarChanged ) | |
) { PrintToServer( "Something wrong on 6." ); } | |
if ( | |
cv != cv.SetBool( false ).SetInt( 1 ).SetFloat( 2.0 ).SetString( "Test" ).RestoreDefault().SetBounds( ConVarBound_Lower, true, -1.0 ).AddChangeHook( OnCvarChanged ).RemoveChangeHook( OnCvarChanged ) | |
) { PrintToServer( "Something wrong on 7." ); } | |
if ( (cv.BoolValue = false), cv.BoolValue != false ) { PrintToServer( "Something wrong on BoolValue." ); } | |
if ( (cv.IntValue = 123), cv.IntValue != 123 ) { PrintToServer( "Something wrong on IntValue." ); } | |
if ( (cv.FloatValue = 321.5), cv.FloatValue != 321.5 ) { PrintToServer( "Something wrong on FloatValue." ); } | |
if ( (cv.Flags = 4+2+1), cv.Flags != 4+2+1 ) { PrintToServer( "Something wrong on FloatValue." ); } | |
PrintToServer( "Ended convar test." ); | |
return Plugin_Handled; | |
} | |
stock void OnCvarChanged (const ConVar Cvar, const char[] szOld, const char[] szNew) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment