AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weird values when returning incremental (https://forums.alliedmods.net/showthread.php?t=241630)

Black Rose 06-06-2014 17:06

Weird values when returning incremental
 
Is it just me? Am I being stupid?
1.8.2

Code:
#include <amxmodx> new gVar1; new gVar2 = 2; function1() return gVar1; function2() return gVar2; function3() return ++gVar1; function4() return gVar2++; public plugin_init() {         register_plugin("Test Plugin 4", "", "[ --{-@ ]");         server_print("Test 1: %d", function1());     server_print("Test 2: %d", function2());         server_print("Test 3: %d", function3());     server_print("Test 4: %d", function4());         server_print("Test 5: %d", function3());     server_print("Test 6: %d", function4()); }

Code:

Test 1: 0
Test 2: 2
Test 3: 10
Test 4: 11
Test 5: 11
Test 6: 11


Backstabnoob 06-06-2014 17:48

Re: Weird values when returning incremental
 
I can confirm this, it seems broken.

PHP Code:

#include < amxmodx >

new g_Var1
new g_Var2

function1
( ) return g_Var1 --
function2( ) return -- g_Var2

public plugin_init() 
{
    
server_print"Test 1: %d"function1( ) )
    
server_print"Test 2: %d"function2( ) )


Code:

Test 1: 0
Test 2: 10


klippy 06-06-2014 19:08

Re: Weird values when returning incremental
 
I can confirm this too(without any test code right now). Few months ago i had trouble with this in an Extra Items API for Biohazard, where a native that should register a new item returned an post-incremented value, which wasn't the right one. After i made it that it increments the value first, then returns it, it worked properly.

Backstabnoob 06-06-2014 19:19

Re: Weird values when returning incremental
 
Yeah, that's actually how we got in contact with this weird issue.


All times are GMT -4. The time now is 09:46.

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