09.10.2011, 12:27
pawn Код:
if(strcmp(cmdtext, "/towcar", true) == 0)
{
new vehicle = GetPlayerVehicleID( playerid );
if(IsPlayerConnected(playerid))
{
if(GetVehicleModel(vehicle) == 525)
{
new Float:pXa, Float:pYa, Float:pZa;
GetPlayerPos(playerid,pXa,pYa,pZa);
new Float:vX, Float:vY, Float:vZ;
new Found = 0;
new vid = 0;
if(IsTrailerAttachedToVehicle(vehicle))
{
DetachTrailerFromVehicle(vehicle);
}
else
{
while((vid < MAX_VEHICLES) && (!Found))
{
vid++;
GetVehiclePos(vid,vX,vY,vZ);
if((floatabs(pXa-vX) < 7.0) && (floatabs(pYa-vY) < 7.0) && (floatabs(pZa-vZ) < 7.0) && (vid != vehicle))
{
Found = 1;
AttachTrailerToVehicle(vid,vehicle);
}
}
}
}
}
return 1;
}