09.07.2013, 21:20
Hello guys
i am needing a little help here well i have a car engine lights hood & trunk system but its all in a dialog i will post the code below now what i want is a vehicle health limit ones the vehicle is damaged such as vehicle health at 300 or something like that. i just want it so the cars dont blow up cos i really hate it
i am needing a little help here well i have a car engine lights hood & trunk system but its all in a dialog i will post the code below now what i want is a vehicle health limit ones the vehicle is damaged such as vehicle health at 300 or something like that. i just want it so the cars dont blow up cos i really hate it
Код:
if(dialogid == DIALOG_VEHICLE)
{
if(response)
{
switch(listitem)
{
case 0:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0 && Fuel[vehicleid] <= 0)
{
ShowErrorDialog(playerid, "This vehicle is out of fuel!");
return 1;
}
if(engine == 1) { engine = 0; lights = 0; }
else { engine = 1; lights = 1; }
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 1:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights == 1) lights = 0; else lights = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 2:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(bonnet == 1) bonnet = 0; else bonnet = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 3:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == 1) boot = 0; else boot = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 4:
{
if(!GetPVarInt(playerid, "GasCan"))
{
ShowErrorDialog(playerid, "You don't have a gas can!");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(Fuel[vehicleid] < 80.0) Fuel[vehicleid] += 20.0;
else Fuel[vehicleid] = 100.0;
SetPVarInt(playerid, "GasCan", 0);
SendClientMessage(playerid, COLOR_WHITE, "You have filled the fuel tank with 20 fuel");
}
case 5:
{
new id = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerVehicleAccess(playerid, id) < 2)
{
ShowErrorDialog(playerid, "You are not the owner of this vehicle!");
return 1;
}
new msg[128];
VehicleCreated[id] = 0;
new money = VehicleValue[id]/2;
GivePlayerMoney(playerid, money);
format(msg, sizeof(msg), "You have sold your vehicle for $%d", money);
SendClientMessage(playerid, COLOR_WHITE, msg);
RemovePlayerFromVehicle(playerid);
DestroyVehicle(VehicleID[id]);
SaveVehicle(id);
}
case 6:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerVehicleAccess(playerid, vehicleid) < 2)
{
ShowErrorDialog(playerid, "You are not the owner of this vehicle!");
return 1;
}
GetVehiclePos(VehicleID[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1], VehiclePos[vehicleid][2]);
GetVehicleZAngle(VehicleID[vehicleid], VehiclePos[vehicleid][3]);
VehicleInterior[vehicleid] = GetPlayerInterior(playerid);
VehicleWorld[vehicleid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have parked this vehicle here");
UpdateVehicle(vehicleid, 1);
PutPlayerInVehicle(playerid, VehicleID[vehicleid], 0);
SaveVehicle(vehicleid);
}
case 7:
{
ShowDialog(playerid, DIALOG_VEHICLE_PLATE);
}
}
}
return 1;
}
Код:
ShowDialog(playerid, dialogid)
{
switch(dialogid)
{
case DIALOG_VEHICLE:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Vehicle ID %d", vehicleid);
strcat(info, "Engine\nLights\nHood\nTrunk", sizeof(info));
strcat(info, "\nFill Tank", sizeof(info));
if(GetPlayerVehicleAccess(playerid, vehicleid) >= 2)
{
new value = VehicleValue[vehicleid]/2;
format(info, sizeof(info), "%s\nSell Vehicle ($%d)\nPark Vehicle\nEdit License Plate", info, value);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, info, "Select", "Cancel");
}
case DIALOG_VEHICLE_BUY:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Vehicle ID %d", vehicleid);
format(info, sizeof(info), "This vehicle is for sale ($%d)\nWould you like to buy it?", VehicleValue[vehicleid]);
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, info, "Yes", "No");
}
case DIALOG_VEHICLE_SELL:
{
new targetid = GetPVarInt(playerid, "DialogValue1");
new id = GetPVarInt(playerid, "DialogValue2");
new price = GetPVarInt(playerid, "DialogValue3");
new info[256];
format(info, sizeof(info), "%s (%d) wants to sell you a %s for $%d.", PlayerName(targetid), targetid,
VehicleNames[VehicleModel[id]-400], price);
strcat(info, "\n\nWould you like to buy?", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Buy Vehicle", info, "Yes", "No");
}
case DIALOG_TRUNK:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new name[32], info[256];
for(new i=0; i < sizeof(VehicleTrunk[]); i++)
{
if(VehicleTrunk[vehicleid][i][1] > 0)
{
GetWeaponName(VehicleTrunk[vehicleid][i][0], name, sizeof(name));
format(info, sizeof(info), "%s%d. %s (%d)\n", info, i+1, name, VehicleTrunk[vehicleid][i][1]);
}
else
{
format(info, sizeof(info), "%s%d. Empty\n", info, i+1);
}
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Trunk", info, "Select", "Cancel");
}
case DIALOG_TRUNK_ACTION:
{
new info[128];
strcat(info, "Put Into Trunk\nTake From Trunk", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Trunk", info, "Select", "Cancel");
}
case DIALOG_VEHICLE_PLATE:
{
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Edit License Plate", "Enter new license plate:", "Change", "Back");
}
case DIALOG_FUEL:
{
new info[128];
strcat(info, "Refuel Vehicle ($" #FUEL_PRICE ")\nBuy Gas Can ($" #GAS_CAN_PRICE ")", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Fuel Station", info, "OK", "Cancel");
}
case DIALOG_EDITVEHICLE:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Edit Vehicle ID %d", vehicleid);
format(info, sizeof(info), "1. Value: [$%d]\n2. Model: [%d (%s)]\n3. Colors: [%d] [%d]\n4. License Plate: [%s]",
VehicleValue[vehicleid], VehicleModel[vehicleid], VehicleNames[VehicleModel[vehicleid]-400],
VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], VehicleNumberPlate[vehicleid]);
strcat(info, "\n5. Delete Vehicle\n6. Park Vehicle\n7. Go To Vehicle", sizeof(info));
strcat(info, "\n\nEnter: [nr] [value1] [value2]", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, caption, info, "OK", "Cancel");
}
}
return 1;
}


