PDA

View Full Version : ObjectMovingToPlayer


SteSte
06/07/2017, 08:23 PM
Hello everyone, so I titled this thread ObjectMovingToPlayer which means that an object moves to the player, but I don't know how to script it, I saw it at a server once, an object was following me, and it injures me if I let it touch me.
I don't know if its possible but the object was probably attached to a bot which is programmed to follow the player.

So I know its possible to attach an object at an npc, then have the npc follow the player, so I want to create fire around the object and when it hits the player it explodes, so anybody knows if an object moving to a player exist?
is it possible to create a object and make it move? like the deer in vwh-rp.





ObjectMovingTowardsPlayer(playerid, objectid, speed, float: x, float:y, float:z);

Lbaker
06/07/2017, 08:37 PM
So you can create simple function :

forward ObjectMovingTowardsPlayer(playerid, objectid, speed);
public ObjectMovingTowardsPlayer(playerid, objectid, speed)
{
new Float:PlayerPos[MAX_PLAYERS][3];
GetPlayerPos(playerid, PlayerPos[playerid][0], PlayerPos[playerid][1], PlayerPos[playerid][2]);
GetPlayerFacingAngle(playerid, PlayerPos[playerid][3]);
MoveObject(objectid, PlayerPos[playerid][0], PlayerPos[playerid][1], PlayerPos[playerid][2], speed, PlayerPos[playerid][3]);
return 1;
}

SteSte
06/07/2017, 08:53 PM
So you can create simple function :

forward ObjectMovingTowardsPlayer(playerid, objectid, speed);
public ObjectMovingTowardsPlayer(playerid, objectid, speed)
{
new Float:PlayerPos[MAX_PLAYERS][3];
GetPlayerPos(playerid, PlayerPos[playerid][0], PlayerPos[playerid][1], PlayerPos[playerid][2]);
GetPlayerFacingAngle(playerid, PlayerPos[playerid][3]);
MoveObject(objectid, PlayerPos[playerid][0], PlayerPos[playerid][1], PlayerPos[playerid][2], speed, PlayerPos[playerid][3]);
return 1;
}


Nice, I'll test that.