Raised This Month: $32 Target: $400
 8% 

Weird values when returning incremental


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-06-2014 , 17:06   Weird values when returning incremental
Reply With Quote #1

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
__________________
Black Rose is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-06-2014 , 17:48   Re: Weird values when returning incremental
Reply With Quote #2

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
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 06-06-2014 at 17:55.
Backstabnoob is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-06-2014 , 19:08   Re: Weird values when returning incremental
Reply With Quote #3

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.
klippy is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-06-2014 , 19:19   Re: Weird values when returning incremental
Reply With Quote #4

Yeah, that's actually how we got in contact with this weird issue.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:48.


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