Raised This Month: $ Target: $400
 0% 

Can't get rid of a tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-07-2008 , 18:20   Can't get rid of a tag mismatch
Reply With Quote #1

This is my code
PHP Code:
stock GetArgColor(arg_num,{Float,_}:color[3],tag tagof(color))
{
    new 
arg[32]
    
read_argv(arg_num,arg,charsmax(arg))
    
    if(!
strlen(arg))
        return 
false
        
    
new sizeof(AMX_SUPER_COLORS_NAME)
    while(
i-- > && !equali(AMX_SUPER_COLORS_NAME[i],arg,charsmax(arg))) {}
    
    if(
>= 0)
    {
        if(
tag == tagof(float))
        {
            
color[0] = float(AMX_SUPER_COLORS_VALUE[i][0])
            
color[1] = float(AMX_SUPER_COLORS_VALUE[i][1])
            
color[2] = float(AMX_SUPER_COLORS_VALUE[i][2])
        }
        else
        {
            
// I tried to do a direct copy here,but I got a tag mismatch even when overriding both tags.
            
color AMX_SUPER_COLORS_VALUE[i]
        }
        
        return 
true
    
}
    else if(!
is_str_num(arg))
        return 
false
        
    
new temp_color[3]
    
temp_color[0] = str_to_num(arg)
    
    if(!
read_argv(++arg_num,arg,charsmax(arg)) || !is_str_num(arg))
        return 
false
    temp_color
[1] = str_to_num(arg)
    
    if(!
read_argv(++arg_num,arg,charsmax(arg)) || !is_str_num(arg))
        return 
false
    temp_color
[2] = str_to_num(arg)
    
    if(
tag == tagof(float))
        
IVecFVec(temp_color,color)
    else
        
temp_color _:color
        
    
return true

I get a tag mismatch error on line
PHP Code:
color AMX_SUPER_COLORS_VALUE[i
I tried overring the tag in left value,in right value,or in both,and I still get a tag mismatch error. Any idea why?
danielkza is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-07-2008 , 22:01   Re: Can't get rid of a tag mismatch
Reply With Quote #2

I forget the reason but you can't do {Float,_}:color[3]. Just do Float:color[3] and convert it to a float or just make another function to get it as an int.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-08-2008 , 12:35   Re: Can't get rid of a tag mismatch
Reply With Quote #3

Quote:
Originally Posted by Emp` View Post
I forget the reason but you can't do {Float,_}:color[3]. Just do Float:color[3] and convert it to a float or just make another function to get it as an int.
I find out a workaround. I'm create a temp_color array(int), use IVecFVec if it's a float, and copyc(_:color,3,temp_color,-1), and get no erros.
Complete code:
PHP Code:
stock GetArgColor(arg_num,{Float,_}:color[3],tag tagof(color))
{
    
// Read first argument
    
new arg[32]
    
read_argv(arg_num,arg,charsmax(arg))
    
    
// Failed, return
    
if(!strlen(arg))
        return 
false
    
    
// Get the size of the color array
    
new sizeof(AMX_SUPER_COLORS_NAME)
    
// Loop decrementing the counter, and break on color found
    // If no color was found, i == -1
    
while(i-- > && !equali(AMX_SUPER_COLORS_NAME[i],arg,charsmax(arg))) {}
    
    new 
temp_color[3]
    
    
// We found our color,copy values to temp array
    
if(>= 0)
        
temp_color AMX_SUPER_COLORS_VALUE[i]
    
    
// Color not found, check for RGB values
    // Argument not a number,fail
    
else if(!is_str_num(arg))
        return 
false

    
else
    {
        
// Copy the first number to the temp array
        
temp_color[0] = clamp(str_to_num(arg),0,255)
        
        
// Read next argument and increment argument counter
        
read_argv(++arg_num,arg,charsmax(arg))
        
        
// Error reading argument or it's not a number,fail
        
if(!strlen(arg) || !is_str_num(arg))
            return 
false
        temp_color
[1] = clamp(str_to_num(arg),0,255)
        
        
// Read next argument and increment argument counter
        
read_argv(++arg_num,arg,charsmax(arg))
        
        
// Error reading argument or it's not a number,fail
        
if(!strlen(arg) || !is_str_num(arg))
            return 
false
        temp_color
[2] = clamp(str_to_num(arg),0,255)
    }
    
    
// Return is a Float:, convert temp array
    
if(tag == tagof(float))
        
IVecFVec(temp_color,color)
    else
        
// This workaround is needed because normal copying(=) would give a tag mismatch warning,no matter what I did
        
copyc(_:color,3,temp_color,256)
        
    return 
true

danielkza is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-09-2008 , 00:32   Re: Can't get rid of a tag mismatch
Reply With Quote #4

Quote:
Originally Posted by danielkza View Post
I find out a workaround. I'm create a temp_color array(int), use IVecFVec if it's a float, and copyc(_:color,3,temp_color,-1), and get no erros.
Complete code:
PHP Code:
stock GetArgColor(arg_num,{Float,_}:color[3],tag tagof(color))
{
    
// Read first argument
    
new arg[32]
    
read_argv(arg_num,arg,charsmax(arg))
    
    
// Failed, return
    
if(!strlen(arg))
        return 
false
    
    
// Get the size of the color array
    
new sizeof(AMX_SUPER_COLORS_NAME)
    
// Loop decrementing the counter, and break on color found
    // If no color was found, i == -1
    
while(i-- > && !equali(AMX_SUPER_COLORS_NAME[i],arg,charsmax(arg))) {}
    
    new 
temp_color[3]
    
    
// We found our color,copy values to temp array
    
if(>= 0)
        
temp_color AMX_SUPER_COLORS_VALUE[i]
    
    
// Color not found, check for RGB values
    // Argument not a number,fail
    
else if(!is_str_num(arg))
        return 
false

    
else
    {
        
// Copy the first number to the temp array
        
temp_color[0] = clamp(str_to_num(arg),0,255)
        
        
// Read next argument and increment argument counter
        
read_argv(++arg_num,arg,charsmax(arg))
        
        
// Error reading argument or it's not a number,fail
        
if(!strlen(arg) || !is_str_num(arg))
            return 
false
        temp_color
[1] = clamp(str_to_num(arg),0,255)
        
        
// Read next argument and increment argument counter
        
read_argv(++arg_num,arg,charsmax(arg))
        
        
// Error reading argument or it's not a number,fail
        
if(!strlen(arg) || !is_str_num(arg))
            return 
false
        temp_color
[2] = clamp(str_to_num(arg),0,255)
    }
    
    
// Return is a Float:, convert temp array
    
if(tag == tagof(float))
        
IVecFVec(temp_color,color)
    else
        
// This workaround is needed because normal copying(=) would give a tag mismatch warning,no matter what I did
        
copyc(_:color,3,temp_color,256)
        
    return 
true

it might compile fine, but it won't work (I've tried something similar before)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-09-2008 , 11:58   Re: Can't get rid of a tag mismatch
Reply With Quote #5

Quote:
Originally Posted by Emp` View Post
it might compile fine, but it won't work (I've tried something similar before)
I tested it and it works absolutely fine. I see no reason why it wouldn't work. In pawn integers and chars are the same tag(none), so it will make no difference. Also, since all the values are clamped beetween 0 and 255,-1 will never appear. By limiting the length I make sure only the correct part will be copied. Don't see the problem here.
danielkza 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 05:34.


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