29.07.2018, 10:22
(
Последний раз редактировалось Varg; 29.07.2018 в 11:42.
)
Hi,
How can i add givekey/takekey for vehicles? And i wanna if user havent key, cant engine. Sorry for my bad English. Im not a pawn coder, im trying to be. So i need examples.
CarData enum;
/engine cmd;
/lock cmd;
How can i add givekey/takekey for vehicles? And i wanna if user havent key, cant engine. Sorry for my bad English. Im not a pawn coder, im trying to be. So i need examples.
CarData enum;
PHP код:
enum carData {
carID,
carExists,
carModel,
carOwner,
Float:carPos[4],
carColor1,
carColor2,
carPaintjob,
carLocked,
carMods[14],
carImpounded,
carImpoundPrice,
carFaction,
carSiren,
carWeapons[5],
carAmmo[5],
carVehicle
};
PHP код:
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;
}
PHP код:
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;
}