SA-MP Forums Archive
Parsing global variable as function parameter bug? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Parsing global variable as function parameter bug? (/showthread.php?tid=635199)



Parsing global variable as function parameter bug? - Riwerry - 03.06.2017

Hey guys, I have self made function to which I parse values stored in global variable, but I have problem. I'm calling this function from two different places as following:

PHP код:
//Inside OnDialogResponse
MDC_LookUp(playeridMDC_g_sPlayer[playerid][E_MDC_LOOK_UP_METHOD], inputtext);
//OnPlayerClickTD (refresh button)
MDC_LookUp(playeridMDC_g_sPlayer[playerid][E_MDC_LOOK_UP_METHOD], MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_INPUT]);
//And that's start of my function
MDC_LookUp(playeridmethodinput[], bool:error false)
{
    
MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_METHOD] = 1337;
    
printf("Variable value %i"method);
        
//other code
}
//After first call method parameter prints correct number (according to one parsed in OnResponse func call), but on second call changing global variable's value changes also local method value as it print's 1337 and I don't understand why. 



Re: Parsing global variable as function parameter bug? - JustNothing - 03.06.2017

because you set 'MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_METHOD]' to 1337 and when you call func another time you just use 'MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_METHOD]' which is set to 1337


Re: Parsing global variable as function parameter bug? - Riwerry - 03.06.2017

That's true, how coudln't I get it lol, thank you.