Make a player follow other player?
#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


Messages In This Thread
Make a player follow other player? - by Metharon - 27.07.2015, 23:36
Re: Make a player follow other player? - by Abagail - 27.07.2015, 23:40
Re: Make a player follow other player? - by SpikeSpigel - 27.07.2015, 23:42
Re: Make a player follow other player? - by Onfroi - 27.07.2015, 23:53
Re: Make a player follow other player? - by xVIP3Rx - 27.07.2015, 23:55

Forum Jump:


Users browsing this thread: 1 Guest(s)