SA-MP Forums Archive
Tow Script [+REP] - 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)
+--- Thread: Tow Script [+REP] (/showthread.php?tid=344760)



Tow Script [+REP] - AarabMoney - 22.05.2012

Hello,

Anyone have a tow script for me?
With /tow /untow.

Ill give you +REP thank you in advance.


Re: Tow Script [+REP] - Ruben_Alonso - 22.05.2012

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;
 }



Re: Tow Script [+REP] - vvhy - 22.05.2012

Here's one you can use with just the press of a button tow/untow action key default is alt when your in a vehicle

Код:
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)<5.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,"Car towed!");
}
}
}
}
}



Re: Tow Script [+REP] - AarabMoney - 22.05.2012

Thanks for helping, you guys have a rep+