Attach player to player?
#1

I am making a cop system in my server but I am stuck on trying to find out how to get the criminal to be attached to the cop for the cop can move the player around.

For example:

The cop gets out of his vehicle to go arrest a player. Once the player is arrested the cop has to put the player in his vehicle but it is far away. So the cop grabs or attaches the player to himself for he can then bring him to his vehicle.


How can I do this?
Reply
#2

I wrote you an Include

You can download it here: http://www.mediafire.com/download/52...c5e/follow.inc

To use it:

PHP код:
//In your main Skript:
//If you do it like this, he is following fast (you should do this)
#define WALK_FAST
//or then he walks slow
#define WALK_SLOW
#include <follow>
//The function you can use is:
Follow(playeridpID);
/*
    playerid = the guy who should get followed in your example the cop
    pID = the guy who follows playerid
*/
//To stop it make:
StopFollow(playerid);
/*
    PS: It stops automatically if the player is in a car
*/ 
Greekz
Reply
#3

I do not have access to those download sites, could you copy and paste the code here?
Reply
#4

Sure:

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 
trueTogglePlayerControllable(b,true),MovePlayer(b,WALK_SPEED),stopped{b}=false;
    }
    return 
SetPlayerFacingAngle(b,q);

Reply
#5

could you explain to me what happens?
Reply
#6

...look what i wrote..the player follows the other player

Just check it out
Reply
#7

Quote:
Originally Posted by jeffery30162
Посмотреть сообщение
could you explain to me what happens?
His code simply applies a running or walking animation to a player toward the other player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)