Vehicle Engine system -
Xenforox - 12.01.2015
Hello guys, i'm having a few problems finding a way to make /e works for faction cars
PHP код:
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,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;
}
}
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
PHP код:
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]??
Re: Vehicle Engine system -
rickisme - 12.01.2015
what's your problem ?
engine can't start or what ?
please explain more
Re: Vehicle Engine system -
Xenforox - 12.01.2015
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!
Re: Vehicle Engine system -
rickisme - 12.01.2015
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;
}
Re: Vehicle Engine system -
Xenforox - 12.01.2015
It's not working, it keeps telling me "You don't have keys for this vehicle."
Re: Vehicle Engine system -
Xenforox - 12.01.2015
Anyone else can suggest a way to resolve my problem please?
Re: Vehicle Engine system -
Raisingz - 12.01.2015
Код:
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;
}
Re: Vehicle Engine system -
Xenforox - 12.01.2015
Even the second way proposed by Raisingz is not working! Please help me. i'll owe you big times :S
Re: Vehicle Engine system -
Xenforox - 13.01.2015
Anyone? Just suggest some solutions please
!
Re: Vehicle Engine system -
Ciarannn - 13.01.2015
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?