| danielkza |
08-08-2008 12:35 |
Re: Can't get rid of a tag mismatch
Quote:
Originally Posted by Emp`
(Post 666220)
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 i = sizeof(AMX_SUPER_COLORS_NAME) // Loop decrementing the counter, and break on color found // If no color was found, i == -1 while(i-- > 0 && !equali(AMX_SUPER_COLORS_NAME[i],arg,charsmax(arg))) {} new temp_color[3] // We found our color,copy values to temp array if(i >= 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 }
|