Detecting trailer types wont work?
#1

Hello! I want to detect the different trailer types, like if you attach a Petrol Trailer you have to transport Gasoline from a to b, and not wood, and like if you have cargo trailer you have to haul stone etc, the system is now just generating random missions to the all 3 trailer types :/

Why wont it work?
http://pastebin.com/NdTJ21zY
Reply
#2

PHP код:
if( GetVehicleModelGetVehicleTrailervehicleid ) ) ==584)
{
    return 
SendClientMessageplayerid, -1"fuel trailer attached !" );

Reply
#3

Quote:
Originally Posted by Mister0
Посмотреть сообщение
PHP код:
if( GetVehicleModelGetVehicleTrailervehicleid ) ) ==584)
{
    return 
SendClientMessageplayerid, -1"fuel trailer attached !" );

Have you ever read the code i posted? If, please tel me! I dont see where i should put this..
Reply
#4

Under
Код:
dcmd_work(playerid, params[])
Put
Код:
if( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) ==584) 
{ 
    return SendClientMessage( playerid, -1, "Haul Fuel from [LS]Los Santos to [SF]San Fierro with Petrol Trailer!" ); 
}
else if( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) ==435) 
{ 
    return SendClientMessage( playerid, -1, " Haul Drills from [SF]San Fierro to [LS]Los Santos with Cargo Trailer" ); 
}
else
{ 
    return SendClientMessage( playerid, -1, "You Don't have a Trailer!" ); 
}
You can make more trailer types with else if!
Use https://sampwiki.blast.hk/wiki/Vehicles:Trailers
Reply
#5

Quote:
Originally Posted by Godey
Посмотреть сообщение
Under
Код:
dcmd_work(playerid, params[])
Put
Код:
if( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) ==584) 
{ 
    return SendClientMessage( playerid, -1, "Haul Fuel from [LS]Los Santos to [SF]San Fierro with Petrol Trailer!" ); 
}
else if( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) ==435) 
{ 
    return SendClientMessage( playerid, -1, " Haul Drills from [SF]San Fierro to [LS]Los Santos with Cargo Trailer" ); 
}
else
{ 
    return SendClientMessage( playerid, -1, "You Don't have a Trailer!" ); 
}
You can make more trailer types with else if!
Use https://sampwiki.blast.hk/wiki/Vehicles:Trailers
It is okay that i am little clucker, but i do not post just to get post, but do you post just to get higher amount of posts? Did you ever read the description?
Reply
#6

Its simple

first of all define your trailer variables.

PHP код:
new trailer[12];//You can increase or decrease the amount of variable. 
then go OnGameModInt and create trailer vehicles

PHP код:
//Normal Trailers
trailer[0] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[1] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[2] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[3] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[4] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[5] = AddStaticVehicle(435Float:xFloat:yFloat:zFloat:angle, -1, -1);
//Fuel Trailers
trailer[6] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[7] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[8] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[9] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[10] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1);
trailer[11] = AddStaticVehicle(584Float:xFloat:yFloat:zFloat:angle, -1, -1); 
Now create 2 stocks to detect the Trailer is fuel one or normal
PHP код:
stock NormalTrailer(vehicleid)
{
  if(
GetVehicleTrailer(vehicleid) == trailer[0] || GetVehicleTrailer(vehicleid) == trailer[1] || GetVehicleTrailer(vehicleid) == trailer[2]) return 1;
  if(
GetVehicleTrailer(vehicleid) == trailer[3] || GetVehicleTrailer(vehicleid) == trailer[4] || GetVehicleTrailer(vehicleid) == trailer[5]) return 1;
  return 
0;
}
stock FuelTrailer(vehicleid)
{
    if(
GetVehicleTrailer(vehicleid) == trailer[6] || GetVehicleTrailer(vehicleid) == trailer[7] ||GetVehicleTrailer(vehicleid) == trailer[8] ||GetVehicleTrailer(vehicleid) == trailer[9]) return 1;
    if(
GetVehicleTrailer(vehicleid) == trailer[10] || GetVehicleTrailer(vehicleid) == trailer[11]) return 1;
    return 
0;

After This goto your function of truck mission
PHP код:
stock T_NewJob(playerid)
{
    new 
MisRand random(sizeof(MisLocations));
    new 
vID GetPlayerVehicleID(playerid);
    if(
GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
    {
        if(
IsTrailerAttachedToVehicle(vID))
        {
            if(
NormalTrailer(vID))//Its Normal Trailer
               
{
            
                
//Your code for Normal Trailer
            
}
            else if(
FuelTrailer(vID))
            {
                
//Your code for Fuel Trailer
            
}
        }
        else
        {
                
SendClientMessage(playerid, -1"You need a trailer!");
        }
    }
    else
    {
        
SendClientMessage(playerid, -1"You must be in a Truck to perform this!");
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by Flybyu
Посмотреть сообщение
It is okay that i am little clucker, but i do not post just to get post, but do you post just to get higher amount of posts? Did you ever read the description?
Have you even read the "How to get help thread"?
Reply
#8

Quote:

It is okay that i am little clucker, but i do not post just to get post, but do you post just to get higher amount of posts?

Trying to help.. you didn't even tell where to put them.
Quote:

Did you ever read the description?

What description?
Reply
#9

Quote:
Originally Posted by Godey
Посмотреть сообщение
Trying to help.. you didn't even tell where to put them.

What description?
I posted link here, as it said in the topic, why wont it work? i asked why it wont work and description of how i meant it should be
http://pastebin.com/NdTJ21zY
Reply
#10

So what you've done, is followed a tutorial, then you expect people to fix your addition?

Just because you put an if statement in, doesn't mean it'll do anything extra.


Under T_NewJob, you have an if, yet you don't assign them any different mission based on that if. That's why it's not working as you think it should.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)