PDA

View Full Version : Help please! Theres a buggy bug in my command!


Mund0
31/07/2015, 01:44 AM
Hello once again!, sorry for taking your time. I added o function to the command /motor so it could ONLY turn vehicles on and off that are owned by the user and commerical vehicles like DMV vehicles, Taxis, and cars for rent. But when I enter a car and use /motor, it tells me im not in a car owned by me. I also enter to commercial vehicles and it says the same thing. Ive tried fixing it but I just cant.

Here are the codes I added to add the function (Turn on commercial vehicles and vehicles only owned by player):

new i = 0; i < sizeof(dmvCars); i++;
new c = 0; c < sizeof(rentCars); c++;
if (carid = Car_GetID(carid) != -1 && Car_IsOwner(playerid, carid) && IsPlayerInVehicle(playerid, dmvCars[i]) && IsPlayerInVehicle(playerid, rentCars[c]))
{ (After this goes all the funcions)

At the end of the command:

else SendErrorMessage(playerid, "No tienes las llaves de este vehiculo."); //You dont have the keys of the vehicle!
return 1;
}

Here is the full command:

CMD:motor(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new carid = GetPlayerVehicleID(playerid);

if (!IsEngineVehicle(vehicleid))
return SendErrorMessage(playerid, "No estas dentro de ningun coche.");

/* if (IsRefueling[playerid])
return SendErrorMessage(playerid, "Wait until the car tank is refueled.");*/

if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
return SendErrorMessage(playerid, "No eres el conductor.");

if (CoreVehicles[vehicleid][vehFuel] < 1)
return SendErrorMessage(playerid, "No queda gasolina.");

if (ReturnVehicleHealth(vehicleid) <= 300)
return SendErrorMessage(playerid, "Intentas arrancar el coche pero no enciende, parece ser que esta dañado.");


new i = 0; i < sizeof(dmvCars); i++;
new c = 0; c < sizeof(rentCars); c++;
if (carid = Car_GetID(carid) != -1 && Car_IsOwner(playerid, carid) && IsPlayerInVehicle(playerid, dmvCars[i]) && IsPlayerInVehicle(playerid, rentCars[c]))
{

if(IsPlayerInVehicle(playerid, dmvCars[i]))
{
if (!PlayerData[playerid][pDrivingTest]) return SendClientMessage(playerid, -1, "Escribe /examen para comenzar el examen de conuccion.");
}

if(IsPlayerInVehicle(playerid, rentCars[c]))
{
if(GetPVarInt(playerid, "RentedCar") == 0 && GetPVarInt(playerid, "RentVehKey") == 0) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
if(GetPVarInt(playerid, "RentedCar") == 1 && GetPVarInt(playerid, "RentVehKey") == 0) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
if(GetPVarInt(playerid, "RentedCar") == 1 && GetPVarInt(playerid, "RentVehKey") != vehicleid) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
}

switch (GetEngineStatus(vehicleid))
{
case false:
{
SetEngineStatus(vehicleid, true);
ShowPlayerFooter(playerid, "Has ~g~encendido~w~ el motor del vehiculo!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s acciona la llave y pone el motor en marcha acto seguido desembraga.", ReturnName(playerid, 0));
}
case true:
{
SetEngineStatus(vehicleid, false);
ShowPlayerFooter(playerid, "Has ~r~apagado~w~ el motor del vehiculo!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s acciona la llave y apaga el vehiculo.", ReturnName(playerid, 0));
}
}
return 1;
}
else SendErrorMessage(playerid, "No tienes las llaves de este vehiculo.");
return 1;
}

And here is the original command (command before I edited it, when it worked fine):

CMD:motor(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);

if (!IsEngineVehicle(vehicleid))
return SendErrorMessage(playerid, "No estas dentro de ningun coche.");

/* if (IsRefueling[playerid])
return SendErrorMessage(playerid, "Wait until the car tank is refueled.");*/

if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
return SendErrorMessage(playerid, "No eres el conductor.");

if (CoreVehicles[vehicleid][vehFuel] < 1)
return SendErrorMessage(playerid, "No queda gasolina.");

if (ReturnVehicleHealth(vehicleid) <= 300)
return SendErrorMessage(playerid, "Intentas arrancar el coche pero no enciende, parece ser que esta dañado.");


for(new i = 0; i < sizeof(dmvCars); i++)
{
if(IsPlayerInVehicle(playerid, dmvCars[i]))
{
if (!PlayerData[playerid][pDrivingTest]) return SendClientMessage(playerid, -1, "Escribe /examen para comenzar el examen de conuccion.");
}
}

for(new i = 0; i < sizeof(rentCars); i++)
{
if(IsPlayerInVehicle(playerid, rentCars[i]))
{
if(GetPVarInt(playerid, "RentedCar") == 0 && GetPVarInt(playerid, "RentVehKey") == 0) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
if(GetPVarInt(playerid, "RentedCar") == 1 && GetPVarInt(playerid, "RentVehKey") == 0) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
if(GetPVarInt(playerid, "RentedCar") == 1 && GetPVarInt(playerid, "RentVehKey") != vehicleid) return SendClientMessage(playerid, -1, "No tienes las llaves de este vehiculo.");
}
}

switch (GetEngineStatus(vehicleid))
{
case false:
{
SetEngineStatus(vehicleid, true);
ShowPlayerFooter(playerid, "Has ~g~encendido~w~ el motor del vehiculo!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s acciona la llave y pone el motor en marcha acto seguido desembraga.", ReturnName(playerid, 0));
}
case true:
{
SetEngineStatus(vehicleid, false);
ShowPlayerFooter(playerid, "Has ~r~apagado~w~ el motor del vehiculo!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s acciona la llave y apaga el vehiculo.", ReturnName(playerid, 0));
}
}
return 1;
}

Thank you :)

Mund0
31/07/2015, 04:10 AM
Someone? No? Okay :c

Variable™
31/07/2015, 04:12 AM
Removed.

Mund0
31/07/2015, 04:29 AM
Thank you but it still does not work :(, I enter to a car I own and it still says that its not my car.

Variable™
31/07/2015, 04:34 AM
Removed

Mund0
31/07/2015, 04:36 AM
Thank you :)

Mund0
31/07/2015, 05:53 PM
patato.

Mund0
01/08/2015, 03:51 AM
Up, help please.