27.07.2015, 23:36
I want to make an command or cops /followme , so when i type /followme [player 1] , the player 1 start walking in my direction
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);
}