HexToDec won't work
#1

Код:
public HexToDec(hex[])
public HexToDec(hex[])
{
    new st[1];
	new result,Float:in;
    result = 0;
    in = 0;
    while(strlen(hex) != 0)
    {
		//strins(st, hex[strlen(hex)-1], 0, 1);
		strmid(st, hex, strlen(hex), strlen(hex));
		strdel(hex,strlen(hex)-1,strlen(hex));
		result = result + GetVal(st)*floatround(floatpower(16, in),floatround_ceil);
		in = in+1;
    }
    return result;
}
Ok, so I have some color I input in this public. It is formatted RRGGBB. So I take each symbol from there, but the thing is every time prinf claims my symbol I get with strmid is nothing. What am I doing wrong, my friends?
Reply
#2

PHP код:
stock HexToInt(string[]){
    if(
string[0] == 0) return 0;
    new 
cur 1res 0;
    for(new 
strlen(string)-1>= 0i--){
        if(
string[i] < 58){
            
res res cur * (string[i] - 48);
        } else {
            
res res cur * (string[i] - 55);
        }
        
cur cur 16;
    }
    return 
res;

Reply
#3

I'll check it out now.

P.S. Wow that's fast!
Reply
#4

https://sampwiki.blast.hk/wiki/Colors_Li...alue_with_pawn
Reply
#5

It works, thanks a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)