CMD:drag(playerid,params[])
{
new id, Float:X, Float:Y, Float:Z;
if(!PlayerInfo[playerid][pFaction] < 1) return SCM(playerid, COLOR_GREY,"You're not authorized to use this command.");
else if(isDragged[id] == true) return SCM(playerid, COLOR_LIGHTRED, "That player is already being dragged.");
else if(sscanf(params,"ui", playerid)) return SCM(playerid, COLOR_GREY,"[Usage:] /drag, id.");
if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_LIGHTRED,"That player is not connected.");
if(id == playerid) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't drag yourself.");
if(!IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z)) return SCM(playerid, COLOR_GREY,"That player is not near you.");
isDragged[id] = true;
isDragging[playerid] = true;
return 1;
}
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;
}
new DragPlayerID[MAX_PLAYERS];
new Draged[MAX_PLAYERS];
new DragTimer[MAX_PLAYERS];
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;
}
Okay, you will need a new command, and callback: here is command you can edit it for yourself:
PHP код:
PHP код:
and here is callback witch will be called by timer every 0,8seconds PHP код:
|
(1383) : error 017: undefined symbol "IsSeatAvailable"
(1386) : error 017: undefined symbol "IsSeatAvailable"
(1389) : error 017: undefined symbol "IsSeatAvailable"
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, "* Player left a server!");
KillTimer( DragTimer[ playerid ] );
}
}
}
return true;
}
new OneSeatVehicles[ 38 ] = {
425, 430, 432, 441, 446, 448, 452, 453,
454, 464, 465, 472, 473, 476, 481, 484,
485, 486, 493, 501, 509, 510, 519, 520,
530, 531, 532, 539, 553, 564, 568, 571,
572, 574, 583, 592, 594, 595
};
stock IsSeatAvailable( vehicleid, seat ) {
new carmodel = GetVehicleModel( vehicleid);
for (new i = 0; i < sizeof( OneSeatVehicles ); i++ ) {
if( carmodel == OneSeatVehicles[i] ) return 0;
}
foreach(new i : Player) {
if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seat) return 0;
}
return true;
}