SA-MP Forums Archive
Make a player follow other player? - 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: Make a player follow other player? (/showthread.php?tid=583365)



Make a player follow other player? - Metharon - 27.07.2015

I want to make an command or cops /followme , so when i type /followme [player 1] , the player 1 start walking in my direction


Re: Make a player follow other player? - Abagail - 27.07.2015

You can't actually make them walk natively, you can freeze them and apply a walking animation towards them though.


Re: Make a player follow other player? - SpikeSpigel - 27.07.2015

You can't make them to walk normally. Just do a command like /drag and the targetid have to do /drag accept. Then the target gets freezed and get's teleported every 3-4 steps to the person that's dragging you. In your case, /followme , /follow accept.


Re: Make a player follow other player? - Onfroi - 27.07.2015

1. Apply a walking animation
2. Get the cops pos
3. Use this function to set the facing angle


Re: Make a player follow other player? - xVIP3Rx - 27.07.2015

pawn Код:
CMD:follow(playerid, params[])
{
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "usage: /follow <ID>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "invalid player id");
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT || GetPlayerState(id) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, -1, "you must be both on foot");

    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerLookAt(id, x, y);
    ApplyAnimation(playerid, "PED", "WALK_civi", 4.1, 1, 1, 1, 1, 1, 1);
    //SetPlayerVelocity(playerid, x, y, z);Fuck math, but you could use something instead of x/y/z to make him move.
    return 1;
}

stock SetPlayerLookAt(playerid, Float:x, Float:y)
{
    new Float:Px, Float:Py, Float: Pa;
    GetPlayerPos(playerid, Px, Py, Pa);
    Pa = floatabs(atan((y-Py)/(x-Px)));
    if (x <= Px && y >= Py) Pa = floatsub(180, Pa);
    else if (x < Px && y < Py) Pa = floatadd(Pa, 180);
    else if (x >= Px && y <= Py) Pa = floatsub(360.0, Pa);
    Pa = floatsub(Pa, 90.0);
    if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
    SetPlayerFacingAngle(playerid, Pa);
}