SA-MP Forums Archive
if(IsTrailerAttachedToVehicle(vehicleid) == 403) - 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: if(IsTrailerAttachedToVehicle(vehicleid) == 403) (/showthread.php?tid=462286)



if(IsTrailerAttachedToVehicle(vehicleid) == 403) - JonesyFoCoTDM - 06.09.2013

Hi there, I've been trying to add "if(IsTrailerAttachedToVehicle(vehicleid) == 403)" into this command, but I'm not having much luck. To state the obvious, I want the command to only work if the player is inside vehicle id 403 pulling a trailer.

Thanks in advance to anyone able to help.

Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 403)
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}



Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Ahrim - 06.09.2013

And what does it do for now, if I may ask?

Try This.

Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(vehicleid == 403)
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}
You were trying to get the vehicle's model ID, not Vehicle's ID.


Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - JonesyFoCoTDM - 06.09.2013

Quote:
Originally Posted by Ahrim
Посмотреть сообщение
And what does it do for now, if I may ask?

Try This.

Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(vehicleid == 403)
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}
You were trying to get the vehicle's model ID, not Vehicle's ID.
The command works, at the moment it only allows me to use the command whilst being in the truck. But, I need it to be pulling a trailer too. If the truck isn't pulling a trailer, I don't want the command to work basically.

EDIT: That code is no good for be by the way, the one I currently have works fine. It has to be the vehicle mode ID for it to work on all vehicle id's "403", if I did it with your code, it would only work on the 403rd spawned car I beleive.


Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Ahrim - 06.09.2013

What is the trailer's vehicle id?

Nevermind, try this

pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}



Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Dragonsaurus - 06.09.2013

Check for vehicle model not vehicle ID:
pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetVehicleModelID(GetPlayerVehicleID(playerid));
    if(vehicleid == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}



Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Ahrim - 06.09.2013

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Check for vehicle model not vehicle ID:
pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetVehicleModelID(GetPlayerVehicleID(playerid));
    if(vehicleid == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}
Hmmph, you're right. Oh well, he said he's trying to get it to Vehicle ID 403, not the model. But I think that's what he was trying to say.

EDIT:He edited. nvm.


Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - JonesyFoCoTDM - 06.09.2013

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Check for vehicle model not vehicle ID:
pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetVehicleModelID(GetPlayerVehicleID(playerid));
    if(vehicleid == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}
Compiled that and received this:

Код:
C:\Users\Lee\Desktop\SAMP coding\gamemodes\truckerjob.pwn(387) : error 017: undefined symbol "GetVehicleModelID"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Ahrim - 06.09.2013

try this

pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}



Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - Dragonsaurus - 06.09.2013

Oops it is
pawn Код:
GetVehicleModel(GetPlayerVehicleID(playerid))
Edit: Ahrim's code is fine, I did some mistakes at mine xD


Re: if(IsTrailerAttachedToVehicle(vehicleid) == 403) - JonesyFoCoTDM - 06.09.2013

Quote:
Originally Posted by Ahrim
Посмотреть сообщение
try this

pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 403 && IsTrailerAttachedToVehicle(vehicleid))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry Packaging.\nMainstreet Ammunation.\nFlint Food Factory.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, 0xE64D51FF, "[*]Message: You need to be in a truck with a trailer to use this command!");
    return 1;
}
Works, thank you and everyone else who tried to help. Much appreciated.