Vehicle Engine system
#1

Hello guys, i'm having a few problems finding a way to make /e works for faction cars

PHP код:
CMD:e(playeridparams[])
{
           new 
vehicleid GetPlayerVehicleID(playerid);
           new 
lightsalarmdoorsbonnetbootobjective,string[256];
           if(
vehicleid != INVALID_VEHICLE_ID)
           if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridGREY"You must be in a vehicle before you can do this!");
           if(
GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playeridGREY"Only the driver can do this!");
           if(
PlayerInfo[playerid][OwnedCarID] == vehicleid)
           {
                 if(
Cars[vehicleid][CarEngine] == 0)
                 {
                  
                     
format(stringsizeof(string), "* %s has started the vehicles engine."RemoveUnderLine(name));
                     
NearByMessage(playeridPURPLEstring);
                     
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                     
Cars[vehicleid][CarEngine] = 1;
                 }
                 else if(
Cars[vehicleid][CarEngine] == 1)
                 {
                    
                      
format(stringsizeof(string), "* %s has stopped the vehicles engine."RemoveUnderLine(name));
                      
NearByMessage(playeridPURPLEstring);
                      
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                      
Cars[vehicleid][CarEngine] = 0;
                  }
           }
           if(
PlayerInfo[playerid][OwnedCarID] != vehicleid)
           {
                   
SendClientMessage(playeridGREY"You don't have keys for this vehicle.");
           }
           return 
1;

Here is the enum of the cars

PHP код:
enum Vehicles
{
    
CarModel,
    
CarColour1,
    
CarColour2,
    
CarNos,
    
CarGroup,
    
CarEngine,
    
CarLock,
    
FloatCarPosX,
    
FloatCarPosY,
    
FloatCarPosZ,
    
FloatCarZAngle,
    
GameID,
};
new 
Cars[MAX_VEHICLES][Vehicles]; 
Can you guys suggest a way to edit the /e command and make it able to /e if PlayerInfo[playerid][Faction] = Cars[vehicleid][CarGroup]??
Reply
#2

what's your problem ?

engine can't start or what ?

please explain more
Reply
#3

Alright. The engine system works properly..if you're in your own car, you can turn the engine on, if it's not your car, it says that you don't have the keys.
Now i want to make it so when you get in a group car vehicle, you would be able to turn the engine off!
Reply
#4

you already answer your question =,= just put if PlayerInfo[playerid][Faction] = Cars[vehicleid][CarGroup] like you said,

pawn Код:
forward SetVehicleEngine(playerid, vehicleid);
public SetVehicleEngine(playerid, vehicleid)
{
     if(Cars[vehicleid][CarEngine] == 0)
     {
     
         format(string, sizeof(string), "* %s has started the vehicles engine.", RemoveUnderLine(name));
         NearByMessage(playerid, PURPLE, string);
         SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
         Cars[vehicleid][CarEngine] = 1;
     }
     else if(Cars[vehicleid][CarEngine] == 1)
     {
       
          format(string, sizeof(string), "* %s has stopped the vehicles engine.", RemoveUnderLine(name));
          NearByMessage(playerid, PURPLE, string);
          SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
          Cars[vehicleid][CarEngine] = 0;
      }
}

CMD:e(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new lights, alarm, doors, bonnet, boot, objective,string[256];
    if(vehicleid != INVALID_VEHICLE_ID)
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, GREY, "You must be in a vehicle before you can do this!");
    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, GREY, "Only the driver can do this!");
    if(PlayerInfo[playerid][OwnedCarID] == vehicleid) SetVehicleEngine(playerid, vehicleid);
    else if(PlayerInfo[playerid][OwnedCarID] != vehicleid)
    {
        if(PlayerInfo[playerid][Faction] == Cars[vehicleid][CarGroup]) SetVehicleEngine(playerid, vehicleid);
        else SendClientMessage(playerid, GREY, "You don't have keys for this vehicle.");
    }
    return 1;
}
Reply
#5

It's not working, it keeps telling me "You don't have keys for this vehicle."
Reply
#6

Anyone else can suggest a way to resolve my problem please?
Reply
#7

Код:
enum Vehicles
{
    CarModel,
    CarColour1,
    CarColour2,
    CarNos,
    CarGroup,
    CarEngine,
    CarLock,
    Float: CarPosX,
    Float: CarPosY,
    Float: CarPosZ,
    Float: CarZAngle,
    GameID,
};
new Cars[MAX_VEHICLES][Vehicles];  

CMD:e(playerid, params[])
{
   new vehicleid = GetPlayerVehicleID(playerid);
   new lights, alarm, doors, bonnet, boot, objective,string[256];
   if(vehicleid != INVALID_VEHICLE_ID)
   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, GREY, "You must be in a vehicle before you can do this!");
   if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, GREY, "Only the driver can do this!");
   if(PlayerInfo[playerid][OwnedCarID] == vehicleid || PlayerInfo[playerid][Faction] == Vehicles[vehicleid][CarGroup])
   {
		 if(Cars[vehicleid][CarEngine] == 0)
		 {
		  
			 format(string, sizeof(string), "* %s has started the vehicles engine.", RemoveUnderLine(name));
			 NearByMessage(playerid, PURPLE, string);
			 SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
			 Cars[vehicleid][CarEngine] = 1;
		 }
		 else if(Cars[vehicleid][CarEngine] == 1)
		 {
			
			  format(string, sizeof(string), "* %s has stopped the vehicles engine.", RemoveUnderLine(name));
			  NearByMessage(playerid, PURPLE, string);
			  SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
			  Cars[vehicleid][CarEngine] = 0;
		  }
   }
   else
   {
		   SendClientMessage(playerid, GREY, "You don't have keys for this vehicle.");
   }
   return 1;
}
Reply
#8

Even the second way proposed by Raisingz is not working! Please help me. i'll owe you big times :S
Reply
#9

Anyone? Just suggest some solutions please !
Reply
#10

Quote:
Originally Posted by Xenforox
Посмотреть сообщение
Anyone? Just suggest some solutions please !
Just so I'm clear on this, you want it so when the player types /e, the engine will only start if they are in a group/faction?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)