Raised This Month: $ Target: $400
 0% 

Can't get rid of a tag mismatch


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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`
 



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