SA-MP Forums Archive
Command Help - 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: Command Help (/showthread.php?tid=246387)



Command Help - Tommy_Mandaz - 04.04.2011

Hello,

I am trying to create a /towcar command:

pawn Код:
if(strcmp(cmd,"/towcar",true)==0)
    {
        if(PlayerInfo[playerid][pJob] == 7 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
            {
                if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                {
                    DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                }
                else
                {
                    AttachTrailerToVehicle(VIDS,GetPlayerVehicleID(playerid));
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You are not in a tow truck");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command");
        }
        return 1;
    }
When I compile I get no errors or warnings, but when I go in game and I do /towcar next to a vehicle and I am in a tow truck it does not tow the vehicle. Help me out and thanks.


Re: Command Help - airsoft - 04.04.2011

>_> You already Posted This
https://sampforum.blast.hk/showthread.php?pid=1150280#pid1150280

But Here, Just put this in your command or whatever... this is in my script
pawn Код:
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,"Car Towed!");
                    }
                }
                if  (!Found)
                {
                SendClientMessage(playerid,0xFFFF00AA,"There is no car in range.");
                }
            }



Re: Command Help - Tommy_Mandaz - 05.04.2011

Yes and I needed help but no one would help, can someone actually show me what I am doing wrong I want to learn not copy and paste but thanks.


Re: Command Help - (SF)Noobanatior - 05.04.2011

where does the VIDS value come from?