Make a player follow other player?
#1

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

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

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.
Reply
#4

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

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);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)