Log in

View Full Version : GetPlayerPos



Lorenc
07-23-2011, 04:07 AM
native Float:GetPlayerPos(clientID, axis);
/* GetPlayerPos
* returns a Float referring to the position value on the specified axis (X_AXIS = X, Y_AXIS = Y, Z_AXIS = Z)
* returns 0: invalid clientID / invalid axis parameter
*/

If I did:


new Float: playerPos;
GetPlayerPos(clientID, playerPos);


Would that output:

X: 0.0 Y: 0.0 Z: 0.0

If I were at that location, usually the function should be like


native GetPlayerPos(clientID, Float:X, Float:Y, Float:Z);


That way we can gather the X, Y, Z

May not of made sense I couldn't explain this lol
native GetPlayerPos(clientID, &x, &y, &z);

foxtacles
07-23-2011, 02:07 PM
ATM you would have to use the function this way:


new Float:x, Float:y, Float:z;
x = GetPlayerPos(clientID, X_AXIS);
y = GetPlayerPos(clientID, Y_AXIS);
z = GetPlayerPos(clientID, Z_AXIS);

I know this sucks and I will change the syntax to that of the function you mentioned above. In fact I wasn't familiar how to write a native which takes references as arguments when I started implementing scripting functions ;)

Lorenc
07-25-2011, 08:40 AM
ATM you would have to use the function this way:


new Float:x, Float:y, Float:z;
x = GetPlayerPos(clientID, X_AXIS);
y = GetPlayerPos(clientID, Y_AXIS);
z = GetPlayerPos(clientID, Z_AXIS);

I know this sucks and I will change the syntax to that of the function you mentioned above. In fact I wasn't familiar how to write a native which takes references as arguments when I started implementing scripting functions ;)


You don't have to man, you can simply make a function:



stock GetPlayerPosFixed(playerid, &Float:X, &Float:Y, &Float:Z)
{
X = GetPlayerPos(clientID, X_AXIS);
Y = GetPlayerPos(clientID, Y_AXIS);
Z = GetPlayerPos(clientID, Z_AXIS);
}


Thanks alot Recycler, never knew it :D

This function should work, I'll place it in the useful functions thread