2021-05-01, 11:57 AM
Code:
#define MAX_SALON_SLOT (1)
#define SPORT_VEHICLES (0)
enum dealerInfo
{
carModel,
carPrice,
carSlot,
Float: carPos[4],
carID
}
new SalonData[][dealerInfo] =
{
{451, 50000, SPORT_VEHICLES, {2507.0300, 2499.5908, 21.5469, -90.0000}},
{411, 50000, SPORT_VEHICLES, {2507.2168, 2494.1467, 21.5469, -90.0000}},
};
public OnGameModeInit() {
for (new s; s < MAX_SALON_SLOT; s) {
SalonData[s][carID] = CreateVehicle(SalonData[s][carModel], SalonData[s][carPos][0], SalonData[s][carPos][1], SalonData[s][carPos][2], SalonData[s][carPos][3], -1, -1, -1);
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (!ispassenger) {
new salon_slot=GetPVarInt(playerid,"SalonSlot");
for (new s; s < MAX_SALON_SLOT; s) {
if ( salon_slot == SalonData[s][carSlot] ) {
if ( vehicleid == SalonData[s][carID] ) {
new st[160];
format(st,sizeof(st),"Anda yakin ingin membeli nomor tansport %i?\n\nModel: %s\nBiaya: $%i",s,NameCars(SalonData[s][carModel]),SalonData[s][carPrice]);
ShowPlayerDialog(playerid,64, DIALOG_STYLE_MSGBOX, "Pasar mobil", st, "Untuk membeli", "Keluarlah");
break;
}
}
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
if ( dialogid == 64 ) {
if (!response)
return 1;
new salon_slot=GetPVarInt(playerid,"SalonSlot");
for (new s; s < MAX_SALON_SLOT; s) {
if ( salon_slot == SalonData[s][carSlot] ) {
if ( GetPlayerVehicleID(playerid) == SalonData[s][carID] ) {
if (GetPlayerMoney(playerid) < SalonData[s][carPrice])
return SendClientMessage(playerid, -1, "You don't have enough money."), RemovePlayerFromVehicle(playerid);
GivePlayerMoney(playerid, -SalonData[s][carPrice]);
new st[160];
format(st,sizeof(st),"You bought car : %s\nPrice: $%i",NameCars(SalonData[s][carModel]),SalonData[s][carPrice]);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Delaer", st, "Okay", "");
//other stuffs...
break;
}
}
}
return 1;
}
return 1;
}