Arguement Type Mismatch - 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: Arguement Type Mismatch (
/showthread.php?tid=655366)
Arguement Type Mismatch -
Uvais - 19.06.2018
The line giving error:
PHP код:
new Dist = GetPlayerDistanceFromPoint(playerid, Safe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]);
This =>> PlayerTextDrawSetString(playerid, editthis[playerid], Dist);
The error:
Код:
error 035: argument type mismatch (argument 3)
I don't understand what's wrong.
Re: Arguement Type Mismatch -
Lokii - 19.06.2018
it should be
PHP код:
new Dist[10];
format(Dist, sizeof(Dist), "%0.2f", GetPlayerDistanceFromPoint(playerid, Safe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]));
PlayerTextDrawSetString(playerid, editthis[playerid], Dist);
Re: Arguement Type Mismatch -
Private200 - 19.06.2018
Quote:
Originally Posted by Lokii
it should be
PHP код:
new Dist[10];
format(Dist, sizeof(Dist), "%0.2f", GetPlayerDistanceFromPoint(playerid, Safe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]));
PlayerTextDrawSetString(playerid, editthis[playerid], Dist);
|
Would have been better if you explained what he did wrong rather than give the answer straight away.
"dist" variable should be a float as GetPlayerDistanceFromPoint returns a float value. PlayertextDrawSetString, third argument is supposed to be "string" (and not an integer as in your case or float as in mine). In this case, you either do what Lokii did, or you keep "dist" value and assign it to a temporary string you will use for the textdraw.
I would use the second option since you might need to use this "float" value later on (comparison or anything similar).
PHP код:
new Float:fDist, tmpStr[10];
fDist = GetPlayerDistanceFromPoint(playerid, Safe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]);
format(tmpStr, sizeof(tmpStr), "%0.2f", fDist);
PlayerTextDrawSetString(playerid, editthis[playerid], tmpStr);
This way, you have the opportunity to compare fDist and give more features, like "if(fDist > 10000) SendClientMessage(playerid, -1, "Long distance ahead");" and so on.