PDA

View Full Version : Vehicle Engine system


Xenforox
12/01/2015, 01:10 PM
Hello guys, i'm having a few problems finding a way to make /e works for faction cars

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)
{
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,al arm,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,a larm,doors,bonnet,boot,objective);
Cars[vehicleid][CarEngine] = 0;
}
}
if(PlayerInfo[playerid][OwnedCarID] != vehicleid)
{
SendClientMessage(playerid, GREY, "You don't have keys for this vehicle.");
}
return 1;
}

Here is the enum of the cars

enum Vehicles
{
CarModel,
CarColour1,
CarColour2,
CarNos,
CarGroup,
CarEngine,
CarLock,
Float: CarPosX,
Float: CarPosY,
Float: CarPosZ,
Float: CarZAngle,
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]??

rickisme
12/01/2015, 01:17 PM
what's your problem ?

engine can't start or what ?

please explain more

Xenforox
12/01/2015, 01:20 PM
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!

rickisme
12/01/2015, 01:35 PM
you already answer your question =,= just put if PlayerInfo[playerid][Faction] = Cars[vehicleid][CarGroup] like you said,



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,al arm,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,a larm,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;
}

Xenforox
12/01/2015, 06:30 PM
It's not working, it keeps telling me "You don't have keys for this vehicle."

Xenforox
12/01/2015, 08:01 PM
Anyone else can suggest a way to resolve my problem please?

Raisingz
12/01/2015, 08:52 PM
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,al arm,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,a larm,doors,bonnet,boot,objective);
Cars[vehicleid][CarEngine] = 0;
}
}
else
{
SendClientMessage(playerid, GREY, "You don't have keys for this vehicle.");
}
return 1;
}

Xenforox
12/01/2015, 10:09 PM
Even the second way proposed by Raisingz is not working! Please help me. i'll owe you big times :S

Xenforox
13/01/2015, 07:53 PM
Anyone? Just suggest some solutions please :(!

Ciarannn
13/01/2015, 10:08 PM
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?