enum carData {
carID,
carExists,
carModel,
carOwner,
Float:carPos[4],
carColor1,
carColor2,
carPaintjob,
carLocked,
carMods[14],
carImpounded,
carImpoundPrice,
carFaction,
carSiren,
carWeapons[5],
carAmmo[5],
carVehicle
};
CMD:motor(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if (!IsEngineVehicle(vehicleid))
return SendErrorMessage(playerid, "Bu komutu araз iзinde kullanabilirsin.");
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
return SendErrorMessage(playerid, "Sьrьcь değilsiniz.");
if (CoreVehicles[vehicleid][vehFuel] < 1)
return SendErrorMessage(playerid, "Aracın benzin deposu boş.");
if (ReturnVehicleHealth(vehicleid) <= 300)
return SendErrorMessage(playerid, "Araз hasarlı gцrьnьyor, зalıştırılamaz.");
switch (GetEngineStatus(vehicleid))
{
case false:
{
SetEngineStatus(vehicleid, true);
ShowPlayerFooter(playerid, "You have ~g~started~w~ the engine!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s kontağı зevirip aracın motorunu зalıştırır..", ReturnName(playerid, 0));
}
case true:
{
SetEngineStatus(vehicleid, false);
ShowPlayerFooter(playerid, "You have ~r~stopped~w~ the engine!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s kontağı з.", ReturnName(playerid, 0));
}
}
return 1;
}
CMD:lock(playerid, params[])
{
static
id = -1;
if (!IsPlayerInAnyVehicle(playerid) && (id = (House_Inside(playerid) == -1) ? (House_Nearest(playerid)) : (House_Inside(playerid))) != -1 && House_IsOwner(playerid, id))
{
if (!HouseData[id][houseLocked])
{
HouseData[id][houseLocked] = true;
House_Save(id);
ShowPlayerFooter(playerid, "You have ~r~locked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
else
{
HouseData[id][houseLocked] = false;
House_Save(id);
ShowPlayerFooter(playerid, "You have ~g~unlocked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
}
else if (!IsPlayerInAnyVehicle(playerid) && (id = (Business_Inside(playerid) == -1) ? (Business_Nearest(playerid)) : (Business_Inside(playerid))) != -1)
{
if (Business_IsOwner(playerid, id))
{
if (!BusinessData[id][bizLocked])
{
BusinessData[id][bizLocked] = true;
Business_Refresh(id);
Business_Save(id);
ShowPlayerFooter(playerid, "You have ~r~locked~w~ the business!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
else
{
BusinessData[id][bizLocked] = false;
Business_Refresh(id);
Business_Save(id);
ShowPlayerFooter(playerid, "You have ~g~unlocked~w~ the business!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
}
}
else if (!IsPlayerInAnyVehicle(playerid) && (id = (Entrance_Inside(playerid) == -1) ? (Entrance_Nearest(playerid)) : (Entrance_Inside(playerid))) != -1)
{
if (strlen(EntranceData[id][entrancePass]))
{
Dialog_Show(playerid, EntrancePass, DIALOG_STYLE_INPUT, "Entrance Pass", "Please enter the password for this entrance:", "Submit", "Cancel");
}
}
else if ((id = Car_Nearest(playerid)) != -1)
{
static
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective;
GetVehicleParamsEx(CarData[id][carVehicle], engine, lights, alarm, doors, bonnet, boot, objective);
if (Car_IsOwner(playerid, id) || (PlayerData[playerid][pFaction] != -1 && CarData[id][carFaction] == GetFactionType(playerid)))
{
if (!CarData[id][carLocked])
{
CarData[id][carLocked] = true;
Car_Save(id);
ShowPlayerFooter(playerid, "You have ~r~locked~w~ the vehicle!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SetVehicleParamsEx(CarData[id][carVehicle], engine, lights, alarm, 1, bonnet, boot, objective);
}
else
{
CarData[id][carLocked] = false;
Car_Save(id);
ShowPlayerFooter(playerid, "You have ~g~unlocked~w~ the vehicle!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SetVehicleParamsEx(CarData[id][carVehicle], engine, lights, alarm, 0, bonnet, boot, objective);
}
}
}
else SendErrorMessage(playerid, "You are not in range of anything you can lock.");
return 1;
}
not necessarily, he can create a KeyCar variable [playerid] = -1; when connecting and after trying to make the order.
CMD:givekey(playerid, params[]) { new id; sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "/givekey [username/id]"); if(!IsPlayerInVehicle(playerid, /*Your vehicle*/)) return /*Message*/ KeyCar[id] = /*Your vehicle ID*/ ... return 1; } it's just a simple exemple, you must to try to make your own commands |
While this will work, it's bad practise. There is a reason why vehicles have an enum, you're offering OP to write un-organized and potentially hard to read code. Not to even mention it won't be possible to save the given key, the key will be reset once the player disconnects which makes the function nearly useless.
|
why you want to give him the keys forever, you can sell his vehicle directly then, the order is just to give him keys from the vehicle for a short period of time, I do not think he needs rescue.
|
enum carData {
carID,
carExists,
carModel,
carOwner,
Float:carPos[4],
carColor1,
carColor2,
carPaintjob,
carLocked,
carMods[14],
carImpounded,
carImpoundPrice,
carFaction,
carSiren,
carWeapons[5],
carAmmo[5],
carVehicle
};
Did I even give the keys "forever"? What you are doing is bad practise as the player might lose connection. If someone sells their vehicle, they won't have access to their vehicle while shared keys let both parties drive the said vehicle.
|