Else statement get's called, even though if statement above is true
#1

Hello, I have a little issue in my code. Shortly, inside of callback OnPlayerClickPlayerTextDraw I have this if and else statement:

PHP код:
// ...
else if(playertextid == MDC_g_sPlayer[playerid][E_MDC_TEXTDRAW][39])
{
    if(
MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_CACHE] == MDC_LOOK_UP_CACHE_ESSENTIAL)
    {
    }
    else
    {
        
printf("%i"MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_CACHE]); //Prints 1, so it equals to MDC_LOOK_UP_CACHE_ESSENTIAL
        
MDC_Update(playeridMDC_UPDATE_TECHNIQUE_WIPE_CONTENT_MDC_ITEM_LOOK_UPMDC_CONTENT_LICENSE);
    }
    return 
1;
}
//... 
So, the else statement is being called, even though the if above is true. But once I add some code under if code block, else statement isn't getting called.
Reply
#2

are you sure about it? print and check MDC_LOOK_UP_CACHE_ESSENTIAL too.
Reply
#3

PHP код:
#define MDC_LOOK_UP_CACHE_ESSENTIAL            (1) 
And when I do this, it's also working fine
PHP код:
else if(playertextid == MDC_g_sPlayer[playerid][E_MDC_TEXTDRAW][39]) 

    
printf("%i"MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_CACHE]); //Prints 1, so it equals to MDC_LOOK_UP_CACHE_ESSENTIAL 
    
if(MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_CACHE] == MDC_LOOK_UP_CACHE_ESSENTIAL
    { 
    } 
    else 
    { 
        
MDC_Update(playeridMDC_UPDATE_TECHNIQUE_WIPE_CONTENT_MDC_ITEM_LOOK_UPMDC_CONTENT_LICENSE); 
    } 
    return 
1

So does this:
PHP код:
else if(playertextid == MDC_g_sPlayer[playerid][E_MDC_TEXTDRAW][39]) 

    
printf("%i"MDC_LOOK_UP_CACHE_ESSENTIAL); //Prints 1 
    
if(MDC_g_sPlayer[playerid][E_MDC_LOOK_UP_CACHE] == MDC_LOOK_UP_CACHE_ESSENTIAL
    { 
    } 
    else 
    { 
        
MDC_Update(playeridMDC_UPDATE_TECHNIQUE_WIPE_CONTENT_MDC_ITEM_LOOK_UPMDC_CONTENT_LICENSE); 
    } 
    return 
1

I have also tried to execute same code in main() and ZCMD command, it worked fine too.
So maybe it has something to do with OnPlayerClickPTD callback?

There must be some magic in my code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)