Returning a float. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Returning a float. (
/showthread.php?tid=446396)
Returning a float. -
Jack.7331 - 25.06.2013
Код:
stock GetInt(playerid, var[])
{
new file[256];
format(file, sizeof(file), "Users/%s.uf", GetName(playerid));
if(dini_Exists(file))
{
return dini_Int(file, var);
}
return 1;
}
stock GetString(playerid, var[])
{
new file[256];
format(file, sizeof(file), "Users/%s.uf", GetName(playerid));
if(dini_Exists(file))
{
return dini_Get(file, var);
}
return 1;
}
stock GetFloat(playerid, var[])
{
new file[256];
format(file, sizeof(file), "Users/%s.uf", GetName(playerid));
if(dini_Exists(file))
{
new Float:value = dini_Float(file, var);
return value;
}
return 1;
}
And on the following lines I get errors:
if(dini_Exists(file))
{
return dini_Get(file, var);
}
return 1;
} - the return 1; line - error 079: inconsistent return types (array & non-array)
new Float:value = dini_Float(file, var);
return value;
}
return 1;
} - the return value; line.
warning 213: tag mismatch
Re: Returning a float. -
Vince - 25.06.2013
First error is pretty clear. You can't return both a string and integer from the same function. Either they're both strings, or both integers.
Second warning; change the function header to this:
pawn Код:
stock Float:GetFloat(playerid, var[])
If a warning pops up about 'forcing reparse' then also add this on top of your script:
pawn Код:
forward Float:GetFloat(playerid, var[])
Other than that, please stop using dini; use something faster.