Follow Player
#1

I need a script that makes it so an object can follow the player wherever he goes. Not sure how to put it in code.
Reply
#2

Search on ******? Or have you tried that? :P
Reply
#3

Quote:
Originally Posted by Drake_Lopez
Посмотреть сообщение
Search on ******? Or have you tried that? :P
Not yet. Thought I'd go straight to the forums.
Reply
#4

new object;

Set timer and do ths:
Quote:

new Float:Coo[3];
GetPlayerPos(id,Coo[0],Coo[1],Coo[2]);
DestroyObject(object);
object = CreateObject(modelid,Coo[0],Coo[1],Coo[2],0.0,0.0,0.0);

Reply
#5

Search there is few Tutorials on it
Reply
#6

Ok, so now how would I make a loop that loops through all the players currently online and selects a random one?
Reply
#7

pawn Код:
stock SelectRandomPlayer()
{
     new random = Random(MAX_PLAYERS);
     if(IsPlayerConnected(random))
     {
           return random;
     }
     else
     {
           SelectRandomPlayer();
     }
}
Paste this as a stock out of a callback
pawn Код:
new randomplayer = SelectRandomPlayer();
SetPlayerHealth(randomplayer, 100);
Change the setplayerhealth with whateva u wanna do with him
Reply
#8

Thanks.
Reply
#9

Ok, so now is there a way I can make it so the object gets set.. let's say about 10 from the player? (I don't know what unit it would be xD)
Reply
#10

Use this function
https://sampwiki.blast.hk/wiki/AttachObjectToPlayer
Syntax
pawn Код:
(objectid, playerid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:rX, Float:rY, Float:rZ)
You can change the offset values to the distance you want between player and object
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)