26.02.2011, 19:33
Hi,
First of all: I know, there is a "floatround" function. But that function rounds a float to an integer.
Someone needed a function that rounded the number behind the dot (eg. 5.555 = 5.6)
So I tried to make it. It didn't work :/. I tried it on two ways, both failed.
First one
Warnings+Errors:
(the function is line 5-2
Function 2
Errors+Warnings:
(this one is from line 5-27)
Can someone help me?
Especially with the second one (that one'll return as string, because I didn't found a function that could change a string to float or int to float).
I'm also really annoyed about line 12:
It says argument mismatch. I don't get it! the 'input' is a float, so it should change 'float' to a string!
- Kevin
p.s.
Yes, I'd also tried this:
1- String to Value (strval)
2- Value to Float (float)
Didn't work either.
First of all: I know, there is a "floatround" function. But that function rounds a float to an integer.
Someone needed a function that rounded the number behind the dot (eg. 5.555 = 5.6)
So I tried to make it. It didn't work :/. I tried it on two ways, both failed.
First one
pawn Код:
stock RoundFloat(Float:value)
{
new Float:output1,
Float:output2,
Float:output,
tmpstr[50],
split[2][25]
;
strmid(tmpstr, value, 0, false);
for(new i = 0; i < strlen(tmpstr); i++){
if(tmpstr[i] == '.'){
strmid(split[0][0], tmpstr[0], 0, i);
strmid(split[1][i], tmpstr[i], 0, false);
break;
}
else continue;
}
output1 = strval(float(split[0]));
output2 = strval(float(split[1]));
output = floatadd(Float:output1, Float:output2);
return Float:output;
}
Код:
C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(13) : error 035: argument type mismatch (argument 2) C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(24) : error 035: argument type mismatch (argument 1) C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(25) : error 035: argument type mismatch (argument 1) C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(27) : warning 213: tag mismatch C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(5) : warning 203: symbol is never used: "value"

Function 2
pawn Код:
stock RoundFloat(Float:input)
{
new str[50],
split[2][25],
tmpoutput,
Float:floattmpoutput
;
format(str, 50, "%s", floatstr(input));
for(new i = 0; i < strlen(str); i++){
if(str[i] == '.'){
strins(split[0][0], str[0], 0, i);
strins(split[1][0], str[i], 0);
break;
}
else continue;
}
tmpoutput = strval(split[1][0]);
tmpoutput = float(tmpoutput);
floattmpoutput = floatround(tmpoutput);
tmpoutput = floatstr(split[1][0]);
format(str, 50, "%s.%s", split[0][0], split[1][0]);
return str;
}
Код:
C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(12) : error 035: argument type mismatch (argument 1) C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(22) : warning 213: tag mismatch C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(24) : warning 213: tag mismatch C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(23) : warning 204: symbol is assigned a value that is never used: "floattmpoutput" C:\Users\Kevin\Desktop\SAMP\Mafia-RP\gamemodes\empty.pwn(5) : warning 203: symbol is never used: "input"
Can someone help me?
Especially with the second one (that one'll return as string, because I didn't found a function that could change a string to float or int to float).
I'm also really annoyed about line 12:
pawn Код:
format(str, 50, "%s", floatstr(input));
- Kevin
p.s.
Yes, I'd also tried this:
1- String to Value (strval)
2- Value to Float (float)
Didn't work either.