Parsing global variable as function parameter bug?
#1

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. 
Reply
#2

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
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)