ObjectMovingToPlayer - 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: ObjectMovingToPlayer (
/showthread.php?tid=637002)
ObjectMovingToPlayer -
SteSte - 06.07.2017
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);
Re: ObjectMovingToPlayer -
Lbaker - 06.07.2017
So you can create simple function :
PHP код:
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;
}
Re: ObjectMovingToPlayer -
SteSte - 06.07.2017
Quote:
Originally Posted by Lbaker
So you can create simple function :
PHP код:
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.