22.05.2012, 15:09
pawn Код:
CMD:tow(playerid, params[])
{
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You have to be inside a tow truck");
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
{
new Float:pX1,Float:pY1,Float:pZ1;
GetPlayerPos(playerid,pX1,pY1,pZ1);
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(pX1-vX)<7.0)&&(floatabs(pY1-vY)<7.0)&&(floatabs(pZ1-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
}
}
}
return 1;
}