02.04.2013, 19:25
pawn Code:
if(!strcmp(tmp, "/tow", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehid = GetPlayerVehicleID(playerid);
if(IsTrailerAttachedToVehicle(vehid))
{
DetachTrailerFromVehicle(vehid);
}
else
{
new Float:pX,Float:pY,Float:ppZ;
GetPlayerPos(playerid,pX,pY,ppZ);
new Float:vX,Float:vY,Float:vZ;
new Found=0;
new vid=0;
while((vid<MAX_VEHICLES)&&(!Found))
{
vid++;
GetVehiclePos(vid,vX,vY,vZ);
if((floatabs(pX-vX) < 7.0) && (floatabs(pY-vY) < 7.0)&& (floatabs(ppZ-vZ) < 7.0) && (vid != vehid))
{
Found=1;
AttachTrailerToVehicle(vid, vehid);
}
}
}
if(!Found)
{
SendClientMessage(playerid, COLOR_RED2, "<!> "COL_WHITE"There is no car in range.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED2, "<!> "COL_WHITE"You must be in a vehicle to do this.");
return 1;
}
return 1;
}