SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/09/2019, 05:00 PM   #1
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 513
Reputation: 18
Default Towing vehicles

Can someone tell me why this code doesn't work?

pawn Code:
if(newkeys & KEY_YES)
    {
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid) == 525))
        {
            new Float:pX,Float:pY,Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            new Float:vX,Float:vY,Float:vZ;
            new vid=0;
            while((vid<MAX_VEHICLES))
            {
                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)))
                {
                    if(IsTrailerAttachedToVehicle(vehid))
                    {
                        DetachTrailerFromVehicle(vehid);
                    }
                    else
                    {
                        AttachTrailerToVehicle(vid,vehid);
                    }
                }
            }
        }
    }

It doesn't do anything if i press KEY_YES.
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is online now   Reply With Quote
Old 10/09/2019, 06:19 PM   #2
darkdrago
Huge Clucker
 
darkdrago's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 290
Reputation: 38
Default Re: Towing vehicles

Code:
if(newkeys & KEY_YES)
    {
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) //Your mistake were here, you haven't closed your GetVehicleModel
        {
            new Float:pX,Float:pY,Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            new Float:vX,Float:vY,Float:vZ;
            new vid=0;
            while((vid<MAX_VEHICLES))
            {
                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)))
                {
                    if(IsTrailerAttachedToVehicle(vehid))
                    {
                        DetachTrailerFromVehicle(vehid);
                    }
                    else
                    {
                        AttachTrailerToVehicle(vid,vehid);
                    }
                }
            }
        }
    }
__________________
darkdrago is offline   Reply With Quote
Old 10/09/2019, 06:39 PM   #3
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 513
Reputation: 18
Default Re: Towing vehicles

Oh, grazie <3 Fai un salto nel mio discord se ti va
__________________


Discord | Play Now | Website

Add your server to favourites and join our Discord.
Symon is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with towing vehicles and gravity?... WTF?.. FujiNNN Help Archive 0 07/04/2010 02:56 PM
NPC Towing? Torran Help Archive 4 03/02/2010 08:37 PM
Towing soldierman Help Archive 5 23/10/2009 03:42 PM
Towing Car Tom_Dedi Help Archive 4 12/09/2009 12:37 PM
Towing cars. -eXo Help Archive 1 04/05/2009 06:59 PM


All times are GMT. The time now is 07:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.