Help please! Theres a buggy bug in my command!
#1

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):

PHP код:
new 0sizeof(dmvCars); i++;
    new 
0sizeof(rentCars); c++;
    if (
carid Car_GetID(carid) != -&& Car_IsOwner(playeridcarid) && IsPlayerInVehicle(playeriddmvCars[i]) && IsPlayerInVehicle(playeridrentCars[c]))
    { (
After this goes all the funcions
At the end of the command:

PHP код:
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:

PHP код:
CMD:motor(playeridparams[])
{
    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 
0sizeof(dmvCars); i++;
    new 
0sizeof(rentCars); c++;
    if (
carid Car_GetID(carid) != -&& Car_IsOwner(playeridcarid) && IsPlayerInVehicle(playeriddmvCars[i]) && IsPlayerInVehicle(playeridrentCars[c]))
    {
        if(
IsPlayerInVehicle(playeriddmvCars[i]))
        {
            if (!
PlayerData[playerid][pDrivingTest]) return SendClientMessage(playerid, -1"Escribe /examen para comenzar el examen de conuccion.");
        }
        if(
IsPlayerInVehicle(playeridrentCars[c]))
        {
            if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") == 0) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
              if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") == 0) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
             if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") != vehicleid) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
        }
        
    switch (
GetEngineStatus(vehicleid))
    {
        case 
false:
        {
            
SetEngineStatus(vehicleidtrue);
            
ShowPlayerFooter(playerid"Has ~g~encendido~w~ el motor del vehiculo!");
            
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s acciona la llave y pone el motor en marcha acto seguido desembraga."ReturnName(playerid0));
        }
        case 
true:
        {
            
SetEngineStatus(vehicleidfalse);
            
ShowPlayerFooter(playerid"Has ~r~apagado~w~ el motor del vehiculo!");
            
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s acciona la llave y apaga el vehiculo."ReturnName(playerid0));
       }
      }
        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):

PHP код:
CMD:motor(playeridparams[])
{
    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 
0sizeof(dmvCars); i++)
    {
        if(
IsPlayerInVehicle(playeriddmvCars[i]))
        {
            if (!
PlayerData[playerid][pDrivingTest]) return SendClientMessage(playerid, -1"Escribe /examen para comenzar el examen de conuccion.");
        }
     }
    for(new 
0sizeof(rentCars); i++)
    {
        if(
IsPlayerInVehicle(playeridrentCars[i]))
        {
            if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") == 0) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
              if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") == 0) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
             if(
GetPVarInt(playerid"RentedCar") == && GetPVarInt(playerid"RentVehKey") != vehicleid) return SendClientMessage(playerid, -1"No tienes las llaves de este vehiculo.");
        }
    }
        
    switch (
GetEngineStatus(vehicleid))
    {
        case 
false:
        {
            
SetEngineStatus(vehicleidtrue);
            
ShowPlayerFooter(playerid"Has ~g~encendido~w~ el motor del vehiculo!");
            
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s acciona la llave y pone el motor en marcha acto seguido desembraga."ReturnName(playerid0));
        }
        case 
true:
        {
            
SetEngineStatus(vehicleidfalse);
            
ShowPlayerFooter(playerid"Has ~r~apagado~w~ el motor del vehiculo!");
            
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s acciona la llave y apaga el vehiculo."ReturnName(playerid0));
        }
    }
    return 
1;

Thank you :)
Reply
#2

Someone? No? Okay :c
Reply
#3

Removed.
Reply
#4

Thank you but it still does not work , I enter to a car I own and it still says that its not my car.
Reply
#5

Removed
Reply
#6

Thank you
Reply
#7

patato.
Reply
#8

Up, help please.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)