CMD:buycar(playerid, params[]) { if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi inainte de a face asta."); if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_GREY,"You need to be on foot."); if(IsPlayerInRangeOfPoint(playerid, 7.0, -1664.1561,1207.6320,7.2546)) { if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You need level 3 to buy a vehicle."); BuyCar[playerid] = -1; ShowPlayerDialog(playerid,DIALOG_CARBUY, DIALOG_STYLE_LIST, "Buy a vehicle", "Cheap\nRegullar\nExpensive\nPremium", "Alege", "Anuleaza"); } else return SCM(playerid,COLOR_WHITE,"Nu esti la dealership."); return 1; }
if(dialogid == DIALOG_CARBUY5) { if(response) { new num = BuyCar[playerid]; if(GetPlayerCash(playerid) >= Stock[num][vPrice]) { if(Stock[num][vStock] > 0) { InsertCar(playerid,num,0); } else { new stringg[MAX_STRING]; format(stringg,sizeof(stringg),"Aceasta masina numai este disponibila in Dealership. Stoc epuizat.\nYou can't buy this vehicle from the dealership. Out of stock."); ShowPlayerDialog(playerid, DIALOG_NOSTOCK, DIALOG_STYLE_MSGBOX, "Stoc epuizat", stringg, "Inchide",""); } } else return SendClientMessage(playerid, COLOR_GREY, "Nu ai destui bani."); } else { BuyCar[playerid] = -1; ShowPlayerDialog(playerid,DIALOG_CARBUY, DIALOG_STYLE_LIST, "Cumpara un vehicul", "Vehicule ieftine\nVehicule normale\nVehicule de lux\nVehicule premium", "Alege", "Anuleaza"); } } if(dialogid == DIALOG_CARBUY2) { if(response) { new num = listitem + 1; BuyCar[playerid] = num; new string33[500], stringtitle[500]; format(stringtitle, sizeof(stringtitle), "%s (%s de lei) - Stoc: %d", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock]); format(string33, sizeof(string33), "Nume: %s\nPret: %s\nStoc: %d\nViteza maxima: %s km/h", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock], FormatNumber(Stock[num][vSpeed])); ShowPlayerDialog(playerid, DIALOG_CARBUY5, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Cumpara", "Inapoi"); } return 1; } if(dialogid == DIALOG_CARBUY3) { if(response) { new cheapcars; for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++) { if(Stock[xf][vPrice] > 0 && Stock[xf][vPrice] <= 15000) { cheapcars = xf; } } new num = listitem + cheapcars + 1; BuyCar[playerid] = num; new string33[256], stringtitle[256]; format(stringtitle, sizeof(stringtitle), "%s (%s de lei) - Stoc: %d", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock]); format(string33, sizeof(string33), "Nume: %s\nPret: %s\nStoc: %d\nViteza maxima: %s km/h", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock], FormatNumber(Stock[num][vSpeed])); ShowPlayerDialog(playerid, DIALOG_CARBUY5, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Cumpara", "Inapoi"); } return 1; } if(dialogid == DIALOG_CARBUY4) { if(response) { new regcheapcars; for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++) { if(Stock[xf][vPrice] >= 6001 && Stock[xf][vPrice] <= 350000) { regcheapcars = xf; } } new num = listitem + regcheapcars + 1; BuyCar[playerid] = num; new string33[256], stringtitle[256]; format(stringtitle, sizeof(stringtitle), "%s (%s de lei) - Stoc: %d", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock]); format(string33, sizeof(string33), "Nume: %s\nPret: %s\nStoc: %d\nViteza maxima: %s km/h", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock], FormatNumber(Stock[num][vSpeed])); ShowPlayerDialog(playerid, DIALOG_CARBUY5, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Cumpara", "Inapoi"); } return 1; } if(dialogid == DIALOG_CARBUY) { if(response) { if(listitem == 0) { new stringzz[5000],stringy[5000]; for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++) { if(Stock[xf][vPrice] > 0 && Stock[xf][vPrice] <= 15000) { format(stringy, sizeof(stringy), "%s (%s de lei) - %d in stoc\n", Stock[xf][vName], FormatNumber(Stock[xf][vPrice]), Stock[xf][vStock]); strcat(stringzz,stringy); } } ShowPlayerDialog(playerid, DIALOG_CARBUY2, DIALOG_STYLE_LIST, "Vehicule", stringzz, "Alege", "Anuleaza"); } if(listitem == 1) { new stringzz[MAX_STRING],stringy[MAX_STRING]; for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++) { if(Stock[xf][vPrice] > 15000 && Stock[xf][vPrice] <= 60000) { format(stringy, sizeof(stringy), "%s (%s de lei) - %d in stoc\n", Stock[xf][vName], FormatNumber(Stock[xf][vPrice]), Stock[xf][vStock]); strcat(stringzz,stringy); } } ShowPlayerDialog(playerid, DIALOG_CARBUY3, DIALOG_STYLE_LIST, "Vehicule", stringzz, "Alege", "Anuleaza"); } if(listitem == 2) { new stringzz[MAX_STRING],stringy[MAX_STRING]; for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++) { if(Stock[xf][vPrice] >= 6001 && Stock[xf][vPrice] < 350000) { format(stringy, sizeof(stringy), "%s (%s de lei) - %d in stoc\n", Stock[xf][vName], FormatNumber(Stock[xf][vPrice]), Stock[xf][vStock]); strcat(stringzz,stringy); } } ShowPlayerDialog(playerid, DIALOG_CARBUY4, DIALOG_STYLE_LIST, "Vehicule", stringzz, "Alege", "Anuleaza"); } if(listitem == 3) { new string2[MAX_STRING]; format(string2,sizeof(string2),"Sparrow - 220 de puncte premium\nHotring Racer B - 250 de puncte premium\nHotring Racer A - 250 de puncte premium\nVortex - 250 de puncte premium\nHotring Racer - 250 de puncte premium\nMaverick - 300 de puncte premium"); ShowPlayerDialog(playerid, DIALOG_CARBUY8, DIALOG_STYLE_LIST, "Vehicule", string2, "Alege", "Anuleaza"); } } return 1; } if(dialogid == DIALOG_CARBUY8) { if(response) { new num = listitem + 98; BuyCar[playerid] = num; new string33[256], stringtitle[256]; format(stringtitle, sizeof(stringtitle), "%s (%s de lei) - Stoc: %d", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock]); format(string33, sizeof(string33), "Nume: %s\nPret: %s\nStoc: %d\nViteza maxima: %s km/h", Stock[num][vName], FormatNumber(Stock[num][vPrice]), Stock[num][vStock], FormatNumber(Stock[num][vSpeed])); ShowPlayerDialog(playerid, DIALOG_CARBUY9, DIALOG_STYLE_MSGBOX, stringtitle, string33, "Buy car", "Back"); } return 1; } if(dialogid == DIALOG_CARBUY9) { if(response) { new num = BuyCar[playerid],price; if(num == 98) price = 220; if(num == 99) price = 250; if(num == 100) price = 250; if(num == 101) price = 250; if(num == 102) price = 250; if(num == 103) price = 300; if(PlayerInfo[playerid][pPremiumPoints] >= price) { if(Stock[num][vStock] > 0) { InsertCar(playerid,num,1); } else { new stringg[MAX_STRING]; format(stringg,sizeof(stringg),"Aceasta masina numai este disponibila in Dealership. Stoc epuizat.\nYou can't buy this vehicle from the dealership. Out of stock."); ShowPlayerDialog(playerid, DIALOG_NOSTOCK, DIALOG_STYLE_MSGBOX, "Out of stock", stringg, "Close",""); } } else return SS(playerid, COLOR_WHITE, "Nu ai suficiente puncte premium. Detalii despre punctele premium pe http://Pear.1to.us", "You don't have enough premium points. Details about premium points here http://pear.1to.us/premium"); } else { BuyCar[playerid] = -1; ShowPlayerDialog(playerid,DIALOG_CARBUY, DIALOG_STYLE_LIST, "Cumpara un vehicul", "Vehicule ieftine\nVehicule normale\nVehicule de lux\nVehicule premium", "Alege", "Anuleaza"); } } if(dialogid == DIALOG_NOSTOCK) { if(response) { hidePlayerDialog(playerid); BuyCar[playerid] = 0; } return 1; }
FormatNumber(number) { new tStr[16]; new number2 = number; if(number < 0) number = number * -1; format(tStr, sizeof(tStr), "%d", number); if(strlen(tStr) < 4) return tStr; new iPos = strlen(tStr), iCount = 1; while(iPos > 0) { if(iCount == 4) { iCount = 0; strins(tStr, ",", iPos, 1); iPos++; } iCount++; iPos--; } if(number2 < 0) format(tStr, sizeof(tStr), "-%s", tStr); return tStr; }
enum vInfo { vID, vStock, vPrice, vModel, vSpeed, vName[255] }; new Stock[106][vInfo];
FormatNumber:
Код:
FormatNumber(number) { new tStr[16]; new number2 = number; if(number < 0) number = number * -1; format(tStr, sizeof(tStr), "%d", number); if(strlen(tStr) < 4) return tStr; new iPos = strlen(tStr), iCount = 1; while(iPos > 0) { if(iCount == 4) { iCount = 0; strins(tStr, ",", iPos, 1); iPos++; } iCount++; iPos--; } if(number2 < 0) format(tStr, sizeof(tStr), "-%s", tStr); return tStr; } Код:
enum vInfo { vID, vStock, vPrice, vModel, vSpeed, vName[255] }; new Stock[106][vInfo]; |