Trailer attaching
#1

Hello I have attempted to make a command which attaches a random trailer to a truck, now I have set up the 3 trailer id's in to a new:
pawn Код:
new Trailers[3][1] =
{
    403,
    514,
    515,
};
Which I have no idea if it is right, guessing it isn't seeing as it isn't working. now here's my command:
pawn Код:
CMD:trailer(playerid, params[])
{
    new vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
    if(IsATruck(vehicleid))
    {
        new randtrailer = random( sizeof( Trailers ) );
        AttachTrailerToVehicle(randtrailer, IsATruck(vehicleid));
        SendClientMessage(playerid, COLOR_RED, "INFO: Trailer attached");
        printf("%d", randtrailer);
    }
    return 1;
}

stock IsATruck(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 435, 450, 584, 591: return 1;
    }
    return 1;
}
With the "IsATruck" attached the the command.
Reply
#2

I just found a little mistake:

pawn Код:
AttachTrailerToVehicle(randtrailer, IsATruck(vehicleid));
Replace with
pawn Код:
AttachTrailerToVehicle(randtrailer, vehicleid);
Reply
#3

PHP код:
CMD:trailer(playeridparams[])
{
    new 
vehicleid;
    
vehicleid GetPlayerVehicleID(playerid);
    if(
IsATruck(vehicleid))
    {
        new 
randtrailer randomsizeofTrailers ) );
        
AttachTrailerToVehicle(randtrailervehicleid);
        
SendClientMessage(playeridCOLOR_RED"INFO: Trailer attached");
        
printf("%d"randtrailer);
    }
    return 
1;
}
stock IsATruck(vehicleid)
{
    switch(
GetVehicleModel(vehicleid))
    {
        case 
435450584591: return 1;
    }
    return 
1;

Try this

Edit : Late, Thanks to the Anti-Spam System ^^.
Reply
#4

It still doesn't want to work, it maybe because of the way I am setting the trailers on the top code.
Reply
#5

Wait a minute!
Those aren't Trailers model IDs! I just noticed that now.
https://sampwiki.blast.hk/wiki/Vehicles:Trailers
EDIT: I just noticed that your IsATruck code contains the trailer ids, instead of trucks' ones!
Reply
#6

Quote:
Originally Posted by -Luis
Посмотреть сообщение
It still doesn't want to work, it maybe because of the way I am setting the trailers on the top code.
You need to Put the Trailer's ID instead of randtrailer

Example

PHP код:
AttachTrailerToVehicle(450vehicleid); 
450 is "Article Trailer 2"

Check this https://sampwiki.blast.hk/wiki/Vehicles:Trailers


EDIT : You better be Kidding me...
Reply
#7

It still isn't working, the debug is not saying the trailer id but 0, 1, 2, 3 etc..
Reply
#8

Post the current code.
Reply
#9

pawn Код:
CMD:trailer(playerid, params[])
{
    new vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
    if(IsATruck(vehicleid))
    {
        new randtrailer = random( sizeof( Trailers ) );
        AttachTrailerToVehicle(randtrailer, vehicleid);
        SendClientMessage(playerid, COLOR_RED, "INFO: Trailer attached");
        printf("%d", randtrailer);
    }
    return 1;
}

stock IsATruck(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 403, 514, 515: return 1;
    }
    return 1;
}
Reply
#10

When you use /trailer IG, it says : Unkown CMD ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)