09.09.2017, 15:22
Okay, you will need a new command, and callback: here is command you can edit it for yourself:
at the top of script you will need a new variables:
You will reset that variables when player is connected to default value witch you want, also you will need to check is draged player disconected then kill timer, did he died...
and here is callback witch will be called by timer every 0,8seconds
PHP код:
CMD:drag( playerid, params[] ) {
new id, Float:Pos[ 3 ];
if( sscanf( params, "u", id )) return usage( playerid,"/drag [ID]" );
if( id == playerid ) return greska( playerid,"You cannot drag yourself!");
if( id == INVALID_PLAYER_ID ) return greska( playerid,"Player Not Connected");
GetPlayerPos( id, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
if( !IsPlayerInRangeOfPoint( playerid, 5.0, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] )) return greska( playerid,"Player not near you");
DragPlayerID[ playerid ] = id; DragTimer[ playerid ] = SetTimerEx( "Dragged", 800, true, "i", playerid, 1 ); Draged[ id ] = playerid;
return true;
}
PHP код:
new DragPlayerID[MAX_PLAYERS];
new Draged[MAX_PLAYERS];
new DragTimer[MAX_PLAYERS];
and here is callback witch will be called by timer every 0,8seconds
PHP код:
forward Dragged( playerid );
public Dragged( playerid ) {
if( Draged[ DragPlayerID[ playerid ] ] != -1 ) {
if( IsPlayerConnected( playerid ) ) {
if( IsPlayerConnected( DragPlayerID[ playerid ] ) ) {
if( !IsPlayerInAnyVehicle( playerid ) && ( !IsPlayerInAnyVehicle( DragPlayerID[ playerid ] ) || IsPlayerInAnyVehicle( DragPlayerID[ playerid ] ) ) ) {
new Float:Pos[ 3 ];
GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
SetPlayerPos( DragPlayerID[ playerid ], Pos[ 0 ], Pos[ 1 ] + 0.4, Pos[ 2 ] );
SetPlayerInterior( DragPlayerID[ playerid ], GetPlayerInterior( playerid ) );
SetPlayerVirtualWorld( DragPlayerID[ playerid ], GetPlayerVirtualWorld( playerid ) );
}
else if( IsPlayerInAnyVehicle( playerid ) && !IsPlayerInAnyVehicle( DragPlayerID[ playerid ] ) ) {
new vehicle = GetPlayerVehicleID(playerid);
if( IsSeatAvailable( vehicle, 1 ) ) {
PutPlayerInVehicle( DragPlayerID[ playerid ], vehicle, 1 );
}
else if( IsSeatAvailable( vehicle, 2 ) ) {
PutPlayerInVehicle( DragPlayerID[ playerid ], vehicle, 2 );
}
else if( IsSeatAvailable( vehicle, 3 ) ) {
PutPlayerInVehicle( DragPlayerID[ playerid ], vehicle, 3 );
}
}
}
else {
DragPlayerID[ playerid ] = -1; Draged[ playerid ] = -1;
SCM( playerid, PLAVA2, "* Player left a server!");
KillTimer( DragTimer[ playerid ] );
}
}
}
return true;
}