Returning a float.
#1

Код:
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
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)