Attach player to player? -
jeffery30162 - 23.09.2015
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?
AW: Attach player to player? -
Kaliber - 23.09.2015
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(playerid, pID);
/*
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
Re: Attach player to player? -
jeffery30162 - 23.09.2015
I do not have access to those download sites, could you copy and paste the code here?
AW: Attach player to player? -
Kaliber - 23.09.2015
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 true: TogglePlayerControllable(b,true),MovePlayer(b,WALK_SPEED),stopped{b}=false;
}
return SetPlayerFacingAngle(b,q);
}
Re: Attach player to player? -
jeffery30162 - 23.09.2015
could you explain to me what happens?
AW: Attach player to player? -
Kaliber - 23.09.2015
...look what i wrote..the player follows the other player
Just check it out
Re: Attach player to player? -
xVIP3Rx - 24.09.2015
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.