AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   tag mismatch (https://forums.alliedmods.net/showthread.php?t=117342)

One 01-31-2010 06:11

tag mismatch
 
hi,

sorry but i dont know what i did wrong.

PHP Code:

public player_menu(id)
{
    if(
get_pcvar_num(g_leach_cvar) == 0//The Leader has Flag
    
{
        if(!
g_player_is_leader[iPlayer] || !get_user_flags(id) & ADMIN_ADMIN)
        {
            
client_print(id,print_chat,"You are not the leader.only the leader has acces to use this command")
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
showing_menu(id)
        }
    }
    else if(
get_pcvar_num(g_leach_cvar) == 1//Only admin has Flag
    
{
        if(!
get_user_flags(id) & ADMIN_ADMIN)
        {
            
client_print(id,print_chat,"Only admin has acces to use this command.")
            return 
PLUGIN_HANDLED;
        }
        if(
get_user_flags(id) & ADMIN_ADMIN)
        {
            
showing_menu(id)
        }
    }
    return 
PLUGIN_HANDLED


i get :

PHP Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team

C
:\Programme\AMX Mod X\pawn\temp720.sma(28) : warning 213tag mismatch
C
:\Programme\AMX Mod X\pawn\temp720.sma(40) : warning 213tag mismatch
Header size
:           1108 bytes
Code size
:             6716 bytes
Data size
:             2112 bytes
Stack
/heap size:      16384 bytesestimated maxusage=781 cells (3124 bytes)
Total requirements:   26320 bytes

2 Warnings
.
Done.

Compilation Time0,42 sec 

where am i wrong ? oO

Seta00 01-31-2010 06:16

Re: tag mismatch
 
You are using a bitwise operation between a boolean and an integer, use bitwise not:
Code:

~get_user_flags(id) & ADMIN_ADMIN
instead of logical not:
Code:

!get_user_flags(id) & ADMIN_ADMIN

One 01-31-2010 06:19

Re: tag mismatch
 
damn :-)))) :P

ty

ConnorMcLeod 01-31-2010 06:33

Re: tag mismatch
 
You still make beginners errors like

if( get_pcvar_num( blabla ) == 0 )
else if( get_pcvar_num( blabla ) == 1 )

First line implies that second line is equal to 1, so you don't need to check again the cvar.
If the cvar can take more than 0/1, then cache the result in a var, or use a switch operator.

One 01-31-2010 06:56

Re: tag mismatch
 
Quote:

Originally Posted by ConnorMcLeod (Post 1073925)
You still make beginners errors like

if( get_pcvar_num( blabla ) == 0 )
else if( get_pcvar_num( blabla ) == 1 )

First line implies that second line is equal to 1, so you don't need to check again the cvar.
If the cvar can take more than 0/1, then cache the result in a var, or use a switch operator.

yop. i just wanted to be sure about this :P forgot to edit it :P its now attached in new plugins :P i know i have there many wrong codes :P hope anyone will flame about the code :P

fysiks 01-31-2010 17:17

Re: tag mismatch
 
Code:

~get_user_flags(id) & ADMIN_ADMIN
=?

Code:

!(get_user_flags(id) & ADMIN_ADMIN)
right? Just wanted to make sure. I usually stick with logical operators when I can. They are easier to comprehend for me :).

Arkshine 02-01-2010 08:28

Re: tag mismatch
 
Yes, it's the same.


All times are GMT -4. The time now is 07:25.

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