Values by reference in forwards
This commit is contained in:
@ -403,6 +403,7 @@ enum
|
||||
#define FP_FLOAT 1
|
||||
#define FP_STRING 2
|
||||
#define FP_ARRAY 4
|
||||
#define FP_VAL_BYREF 5 //cell & float are handled in the same way
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
@ -450,4 +451,4 @@ enum HashType
|
||||
Hash_Keccak_512 // Provides Keccak 512 bit hashing
|
||||
};
|
||||
|
||||
#include <cstrike_const> // To keep backward compatibility
|
||||
#include <cstrike_const> // To keep backward compatibility
|
||||
|
61
plugins/testsuite/fwdreftest1.sma
Normal file
61
plugins/testsuite/fwdreftest1.sma
Normal file
@ -0,0 +1,61 @@
|
||||
// vim: set ts=4 sw=4 tw=99 noet:
|
||||
//
|
||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||
// Copyright (C) The AMX Mod X Development Team.
|
||||
//
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
|
||||
#include <amxmodx>
|
||||
|
||||
new g_hMultiForward;
|
||||
new g_hOneForward;
|
||||
|
||||
public plugin_init()
|
||||
{
|
||||
register_plugin("Forward Test (Reference) (1)", "1.0", "Ni3znajomy");
|
||||
|
||||
g_hMultiForward = CreateMultiForward("multi_forward_reference", ET_IGNORE, FP_VAL_BYREF, FP_VAL_BYREF);
|
||||
g_hOneForward = CreateOneForward(find_plugin_byfile("fwdreftest2.amxx"), "one_forward_reference", FP_VAL_BYREF, FP_VAL_BYREF);
|
||||
|
||||
register_srvcmd("fwdref_multi_test", "cmdForwardRefMultiTest");
|
||||
register_srvcmd("fwdref_one_test", "cmdForwardRefOneTest");
|
||||
}
|
||||
|
||||
public cmdForwardRefMultiTest()
|
||||
{
|
||||
new sTestValue[10];
|
||||
|
||||
read_argv(1, sTestValue, charsmax(sTestValue));
|
||||
new iTestValue1 = str_to_num(sTestValue);
|
||||
|
||||
read_argv(2, sTestValue, charsmax(sTestValue));
|
||||
new Float:fTestValue2 = str_to_float(sTestValue);
|
||||
|
||||
server_print("PLUGIN1: MULTI FORWARD START: val1 = %i | val2 = %f", iTestValue1, fTestValue2);
|
||||
new dump;
|
||||
ExecuteForward(g_hMultiForward, dump, iTestValue1, fTestValue2);
|
||||
server_print("PLUGIN1: MULTI FORWARD END: val1 = %i | val2 = %f", iTestValue1, fTestValue2);
|
||||
}
|
||||
|
||||
public cmdForwardRefOneTest()
|
||||
{
|
||||
new sTestValue[10];
|
||||
|
||||
read_argv(1, sTestValue, charsmax(sTestValue));
|
||||
new iTestValue1 = str_to_num(sTestValue);
|
||||
|
||||
read_argv(2, sTestValue, charsmax(sTestValue));
|
||||
new Float:fTestValue2 = str_to_float(sTestValue);
|
||||
|
||||
server_print("PLUGIN1: ONE FORWARD START: val1 = %i | val2 = %f", iTestValue1, fTestValue2);
|
||||
new dump;
|
||||
ExecuteForward(g_hOneForward, dump, iTestValue1, fTestValue2);
|
||||
server_print("PLUGIN1: ONE FORWARD END: val1 = %i | val2 = %f", iTestValue1, fTestValue2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
55
plugins/testsuite/fwdreftest2.sma
Normal file
55
plugins/testsuite/fwdreftest2.sma
Normal file
@ -0,0 +1,55 @@
|
||||
// vim: set ts=4 sw=4 tw=99 noet:
|
||||
//
|
||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||
// Copyright (C) The AMX Mod X Development Team.
|
||||
//
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
|
||||
#include <amxmodx>
|
||||
|
||||
new g_iTestValue1 = 0
|
||||
new Float:g_fTestValue2 = 0.0;
|
||||
|
||||
public plugin_init()
|
||||
{
|
||||
register_plugin("Forward Test (Reference) (2)", "1.0", "Ni3znajomy");
|
||||
|
||||
register_srvcmd("fwdref_set_test_values", "cmdSetTestValues");
|
||||
}
|
||||
|
||||
public cmdSetTestValues()
|
||||
{
|
||||
new sTestValue[10];
|
||||
|
||||
read_argv(1, sTestValue, charsmax(sTestValue));
|
||||
g_iTestValue1 = str_to_num(sTestValue);
|
||||
|
||||
read_argv(2, sTestValue, charsmax(sTestValue));
|
||||
g_fTestValue2 = str_to_float(sTestValue);
|
||||
|
||||
server_print("PLUGIN2: TEST VALUES: val1 = %i | val2 = %f", g_iTestValue1, g_fTestValue2);
|
||||
}
|
||||
|
||||
public multi_forward_reference(&val1, &Float:val2)
|
||||
{
|
||||
server_print("PLUGIN2: MULTI FORWARD START: val1 = %i | val2 = %f", val1, val2);
|
||||
|
||||
val1 = g_iTestValue1;
|
||||
val2 = g_fTestValue2;
|
||||
|
||||
server_print("PLUGIN2: MULTI FORWARD END: val1 = %i | val2 = %f", val1, val2);
|
||||
}
|
||||
|
||||
public one_forward_reference(&val1, &Float:val2)
|
||||
{
|
||||
server_print("PLUGIN2: ONE FORWARD START: val1 = %i | val2 = %f", val1, val2);
|
||||
|
||||
val1 = g_iTestValue1;
|
||||
val2 = g_fTestValue2;
|
||||
|
||||
server_print("PLUGIN2: ONE FORWARD END: val1 = %i | val2 = %f", val1, val2);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user