03.01.2013, 22:47
Hello, I have a RP GM and I converted its engine system to the new system with VehicleParamsEx. I have this code:
It works perfectly less in a thing:
The code permit turn on and off the engine of a car only if the fuel of the car is more than 0 and if the player has got the key of the car, but I want that when a player try to turn on the engine without the keys, a message saying "You dont have the keys" appears, but when I try to turn on a car without the keys, nothing happens. Please, help.
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_FIRE)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(IsAnOwnableCar(vehicleid))
{
new carid;
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
else { return 1; }
if(carid == vehicleid)
{
if(engine == 1)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s apaga el motor de su vehнculo.", sendername);
ProxDetector(20.0, playerid, string, Morado,Morado,Morado,Morado,Morado);
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
}
else
{
if (Gas[vehicleid] > 0)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s enciende el motor de su vehнculo.", sendername);
ProxDetector(20.0, playerid, string, Morado,Morado,Morado,Morado,Morado);
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
}
else
{
SendClientMessage(playerid, AmarilloClaro, "A este vehнculo no le queda combustible.");
}
}
}
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
else { return 1; }
if(carid != vehicleid)
{
SendClientMessage(playerid, AmarilloClaro, "No tienes las llaves de este vehнculo.");
}
}
}
}
pawn Код:
if(carid != vehicleid)
{
SendClientMessage(playerid, AmarilloClaro, "No tienes las llaves de este vehнculo.");
}
}