31.07.2015, 00:44
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):
At the end of the command:
Here is the full command:
And here is the original command (command before I edited it, when it worked fine):
Thank you :)
Here are the codes I added to add the function (Turn on commercial vehicles and vehicles only owned by player):
PHP код:
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)
PHP код:
else SendErrorMessage(playerid, "No tienes las llaves de este vehiculo."); //You dont have the keys of the vehicle!
return 1;
}
PHP код:
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;
}
PHP код:
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;
}