PHP код:
/* SA-MP Include Follow System
*
* © by Kaliber, 2015
*
*
*/
/******************************************************************************/
#if !defined _samp_included
#include <a_samp>
#endif
/******************************************************************************/
#if defined _Follow
#endinput
#endif
#define _Follow
/******************************************************************************/
#if !defined WALK_FAST && !defined WALK_SLOW
#error "Please define WALK_FAST or WALK_SLOW."
#endif
#if defined WALK_FAST
#define WALK_SPEED true
#else
#define WALK_SPEED false
#endif
/******************************************************************************/
/*
native Follow(playerid, followid);
native StopFollow(playerid);
*/
/******************************************************************************/
static stock bool:stopped[MAX_PLAYERS char],bool:vol[MAX_PLAYERS char];
/******************************************************************************/
static stock MovePlayer(playerid,bool:speed) {
return (!speed) ? ApplyAnimation(playerid,!"ped",!"WALK_civi",4.1,1,1,1,1,0) : ApplyAnimation(playerid,!"ped",!"sprint_civi",4.1,1,1,1,1,0);
}
/******************************************************************************/
stock Follow(playerid,pID) {
if(IsPlayerInAnyVehicle(pID)) return 0;
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z),GetPlayerFacingAngle(playerid,a);
SetPlayerFacingAngle(pID,a),MovePlayer(pID,WALK_SPEED);
SetTimerEx(!"@follow",500,0,!"ii",playerid,pID),vol{pID}=true;
return 1;
}
/******************************************************************************/
stock StopFollow(b) return TogglePlayerControllable(b,true),ClearAnimations(b),vol{b}=false;
/******************************************************************************/
static @follow(a,b);@follow(a,b) {
if(!vol{b} || IsPlayerInAnyVehicle(b)) return vol{b}=false;
new Float:x,Float:y,Float:z,Float:q;
GetPlayerPos(a,x,y,z),GetPlayerFacingAngle(a,q),SetTimerEx(!"@follow",500,0,!"ii",a,b);
if(IsPlayerInRangeOfPoint(b,5.0,x,y,z)) return TogglePlayerControllable(b,false),stopped{b}=true;
switch(stopped{b}) {
case true: TogglePlayerControllable(b,true),MovePlayer(b,WALK_SPEED),stopped{b}=false;
}
return SetPlayerFacingAngle(b,q);
}