SA-MP Forums Archive
How to script a Tow Truck? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to script a Tow Truck? (/showthread.php?tid=73211)



How to script a Tow Truck? - Shellegg - 13.04.2009

Is there a FS or something that is for towtruck "tow" others cars?
If yes, can some1 give me a link or something?

I really need that, in my server i cant "tow" cars


Re: How to script a Tow Truck? - Alec24 - 13.04.2009

I used this in my game mode:
Back up to another vehicle and press KEY_ACTION (possibly left control) to tow.

pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
   if ((newkeys==KEY_ACTION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
      {
      if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
        {
            new Float:pX,Float:pY,Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            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(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
                  {
                  Found=1;
                  if    (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                    {
                    DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                    }
                  AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
                  SendClientMessage(playerid,0xFFFF00AA,"[TOW] Car Towed!");
                  }
            }
            if (!Found)
              {
              SendClientMessage(playerid,0xFFFF00AA,"[TOW] There Is No Car In Range.");
              }
          }
      }
    }