SA-MP Forums Archive
Trailer attaching - 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: Trailer attaching (/showthread.php?tid=279153)



Trailer attaching - Luis- - 25.08.2011

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.


Re: Trailer attaching - [MWR]Blood - 25.08.2011

I just found a little mistake:

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



Re: Trailer attaching - =WoR=G4M3Ov3r - 25.08.2011

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 ^^.


Re: Trailer attaching - Luis- - 25.08.2011

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


Re: Trailer attaching - [MWR]Blood - 25.08.2011

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!


Re: Trailer attaching - =WoR=G4M3Ov3r - 25.08.2011

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...


Re: Trailer attaching - Luis- - 25.08.2011

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


Re: Trailer attaching - [MWR]Blood - 25.08.2011

Post the current code.


Re: Trailer attaching - Luis- - 25.08.2011

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



Re: Trailer attaching - =WoR=G4M3Ov3r - 25.08.2011

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