Arguement Type Mismatch
#1

The line giving error:

PHP код:
    new Dist GetPlayerDistanceFromPoint(playeridSafe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]);
  
This =>>   PlayerTextDrawSetString(playerideditthis[playerid], Dist); 
The error:
Код:
error 035: argument type mismatch (argument 3)
I don't understand what's wrong.
Reply
#2

it should be
PHP код:
new Dist[10];
format(Distsizeof(Dist), "%0.2f"GetPlayerDistanceFromPoint(playeridSafe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]));
PlayerTextDrawSetString(playerideditthis[playerid], Dist); 
Reply
#3

Quote:
Originally Posted by Lokii
Посмотреть сообщение
it should be
PHP код:
new Dist[10];
format(Distsizeof(Dist), "%0.2f"GetPlayerDistanceFromPoint(playeridSafe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]));
PlayerTextDrawSetString(playerideditthis[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:fDisttmpStr[10];
fDist GetPlayerDistanceFromPoint(playeridSafe[sid][safe_Pos][0], Safe[sid][safe_Pos][1], Safe[sid][safe_Pos][2]);
format(tmpStrsizeof(tmpStr), "%0.2f"fDist);
PlayerTextDrawSetString(playerideditthis[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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)