PDA

View Full Version : How to....Object in front of player


iFiras
07/12/2013, 04:26 PM
Deleted.

iFiras
07/12/2013, 04:56 PM
Deleted.

Hansrutger
07/12/2013, 05:01 PM
http://wiki.sa-mp.com/wiki/AttachObjectToPlayer


new myobject;
myobject = CreateObject(19341, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToPlayer(myobject, playerid, 1.5, 0.5, 0.0, 0.0, 1.5, 2);

Copied from the link. And if you want to add it at a certain time you should put the "new myobject" as global, "myobject = Crea..." in OnGameModeInit and the "Attach..." when you want the object to be placed. Also change the "playerid" part to the right id of the player. :)

Konstantinos
07/12/2013, 05:10 PM
****** wrote GetXYInFrontOfPlayer. Just get the player's position (for the z - height), then use the function to get the x and y for the range of 0.5 and create the object at the x, y and z - 1.0

iFiras
08/12/2013, 02:47 PM
Deleted.

iFiras
08/12/2013, 02:57 PM
Deleted.

Roel
08/12/2013, 03:09 PM
It's like this in code, but it's not in front of player when i tested in-game, please someone give me working code
GetPlayerPos(playerid,Xp,Yp,Zp);
GetXYInFrontOfPlayer(playerid,Xp,Yp,0.5);
ROBBERYSAFE = CreateObject(1829,Xp-0.5, Yp+0.5, Zp-0.5,0,0,0);

I think you shouldn't add those 0.5 at the createobject.
So just use it like this:
GetPlayerPos(playerid,Xp,Yp,Zp);
GetXYInFrontOfPlayer(playerid,Xp,Yp,0.5);
ROBBERYSAFE = CreateObject(1829,Xp, Yp, Zp-1.0,0,0,0);

But im not sure, since I never used this function, but it seems logical

iFiras
08/12/2013, 04:48 PM
Deleted.

iFiras
08/12/2013, 05:07 PM
Deleted.

iFiras
08/12/2013, 05:53 PM
Deleted.

FakkChass
08/12/2013, 06:12 PM
removed

Nero_3D
08/12/2013, 06:14 PM
Its like Roel said, try higher values for the distance

Also here an example from the wiki

http://wiki.sa-mp.com/wiki/Stocks#Returning_multiple_values