Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public InsertCar(playerid,stockid,premium)
- {
- new string[256],sendername[25],total,idcar,premiump=0;
- new model = Stock[stockid][vModel];
- new value = Stock[stockid][vPrice];
- GetPlayerName(playerid,sendername,sizeof(sendername));
- BuyCar[playerid] = -1;
- if(GetPlayerCash(playerid) < value && premium == 0) return SCM(playerid,COLOR_GREY,"You don't have enough money to purchase this vehicle.");
- for(new v; v < MAX_PERSONAL_VEHICLES; v++)
- {
- if(PlayerInfo[playerid][pCar][v] != -1) total++;
- }
- if(total+1 > PlayerInfo[playerid][pCarSlots])
- {
- SendClientMessage(playerid, COLOR_GREY, "You can't buy any more cars. Sell one of your cars if you want to buy a new one. Normal players can own 2 cars. Premium players can own 4 cars.");
- return 1;
- }
- for(new v; v < MAX_PERSONAL_VEHICLES; v++)
- {
- if(PlayerInfo[playerid][pCar][v] == -1)
- {
- idcar = v;
- break;
- }
- }
- mysql_format(SQL, string, sizeof(string),"INSERT INTO cars (Model) VALUES (%d)", model);
- new Cache:ids = mysql_query(SQL,string);
- new idd = cache_insert_id();
- cache_delete(ids);
- PlayerInfo[playerid][pCar][idcar] = idd;
- if(model == 469 || model == 487 || model == 522 || model == 521 || model == 461 || model == 581 || model == 468 || model == 463 || model == 586 || model == 471 || model == 510 || model == 481 || model == 462 || model == 509)
- {
- PlayerInfo[playerid][pCarLocX][idcar] = 388.5440;
- PlayerInfo[playerid][pCarLocY][idcar] = -1522.2147;
- PlayerInfo[playerid][pCarLocZ][idcar] = 32.1853;
- PlayerInfo[playerid][pCarAngle][idcar] = 45.0;
- PlayerInfo[playerid][pCarLLocX][idcar] = 388.5440;
- PlayerInfo[playerid][pCarLLocY][idcar] = -1522.2147;
- PlayerInfo[playerid][pCarLLocZ][idcar] = 32.1853;
- PlayerInfo[playerid][pCarAngle2][idcar] = 45.0;
- }
- else
- {
- PlayerInfo[playerid][pCarLocX][idcar] = 284.5032;
- PlayerInfo[playerid][pCarLocY][idcar] = -1526.4036;
- PlayerInfo[playerid][pCarLocZ][idcar] = 24.3208;
- PlayerInfo[playerid][pCarAngle][idcar] = 45.0;
- PlayerInfo[playerid][pCarLLocX][idcar] = 284.5032;
- PlayerInfo[playerid][pCarLLocY][idcar] = -1526.4036;
- PlayerInfo[playerid][pCarLLocZ][idcar] = 24.3208;
- PlayerInfo[playerid][pCarAngle2][idcar] = 45.0;
- }
- if(premium == 0)
- {
- GivePlayerCash(playerid,-value);
- Update(playerid,pCashx);
- mysql_format(SQL, string, sizeof(string), "UPDATE `stock` SET `Stock`='%d' WHERE `ID`='%d'", Stock[stockid][vStock],stockid);
- mysql_pquery(SQL,string,"","");
- }
- PlayerInfo[playerid][pCarModel][idcar] = model;
- PlayerInfo[playerid][pCarColor1][idcar] = 1;
- PlayerInfo[playerid][pCarColor2][idcar] = 1;
- format(string,sizeof(string),"{FA5778}%d",(100000000 + random(9999999999)));
- CarVipName[playerid][idcar] = "";
- strmid(CarPlate[playerid][idcar], string, 0, 20, 255);
- strmid(CarOwner[playerid][idcar], PlayerInfo[playerid][pNormalName], 0, 50, 255);
- PlayerInfo[playerid][pCarLock][idcar] = 0;
- PlayerInfo[playerid][pCarInsPrice][idcar] = 5000;
- PlayerInfo[playerid][pCarIns][idcar] = 10;
- PlayerInfo[playerid][pCarKM][idcar] = 0.0;
- PlayerInfo[playerid][pCarKMLast][idcar] = 0;
- PlayerInfo[playerid][pCarVIP][idcar] = 0;
- PlayerInfo[playerid][pCarVipColors][idcar] = 0;
- PlayerInfo[playerid][pCarHP][idcar] = 1000.0;
- PlayerInfo[playerid][pCarDamage1][idcar] = 0;
- PlayerInfo[playerid][pCarDamage2][idcar] = 0;
- PlayerInfo[playerid][pCarDamage3][idcar] = 0;
- PlayerInfo[playerid][pCarDamage4][idcar] = 0;
- PlayerInfo[playerid][pCarGas][idcar] = 200;
- PlayerInfo[playerid][pCarPaintJ][idcar] = 6;
- PlayerInfo[playerid][pCarBlock][idcar] = 0;
- for(new s; s < 17; s++)
- {
- CarMod[playerid][idcar][s] = 0;
- }
- PlayerInfo[playerid][pCarBuyTime][idcar] = gettime();
- cUpdate(playerid, idcar, cModsx);
- cUpdate(playerid, idcar, cPaintJx);
- cUpdate(playerid, idcar, cLocationxx);
- cUpdate(playerid, idcar, cLocationyx);
- cUpdate(playerid, idcar, cLocationzx);
- cUpdate(playerid, idcar, cAnglex);
- cUpdate(playerid, idcar, cLocationx2x);
- cUpdate(playerid, idcar, cLocationy2x);
- cUpdate(playerid, idcar, cLocationz2x);
- cUpdate(playerid, idcar, cAngle2x);
- cUpdate(playerid, idcar, cColorOnex);
- cUpdate(playerid, idcar, cColorTwox);
- cUpdate(playerid, idcar, cValuex);
- cUpdate(playerid, idcar, cLicensex);
- cUpdate(playerid, idcar, cLockx);
- cUpdate(playerid, idcar, cInscarpricex);
- cUpdate(playerid, idcar, cInsurancecarx);
- cUpdate(playerid, idcar, cKMx);
- cUpdate(playerid, idcar, cDaysx);
- cUpdate(playerid, idcar, cHPx);
- cUpdate(playerid, idcar, cKMLastx);
- cUpdate(playerid, idcar, cDamage1x);
- cUpdate(playerid, idcar, cDamage2x);
- cUpdate(playerid, idcar, cDamage3x);
- cUpdate(playerid, idcar, cDamage4x);
- cUpdate(playerid, idcar, cGasx);
- cUpdate(playerid, idcar, cOwnerx);
- PlayerInfo[playerid][pCarID][idcar] = CreateVehicle(PlayerInfo[playerid][pCarModel][idcar],PlayerInfo[playerid][pCarLocX][idcar],PlayerInfo[playerid][pCarLocY][idcar],PlayerInfo[playerid][pCarLocZ][idcar],PlayerInfo[playerid][pCarAngle][idcar],1,1,-1);
- SetVehicleNumberPlate(PlayerInfo[playerid][pCarID][idcar],CarPlate[playerid][idcar]);
- Gas[PlayerInfo[playerid][pCarID][idcar]] = 200;
- LocateCar(PlayerInfo[playerid][pCarID][idcar], playerid);
- new disp[184],stringsss[256],numele[30];
- if(premium == 1)
- {
- if(model == 469) premiump = 220;
- if(model == 487) premiump = 300;
- if(model == 494 || model == 502 || model == 503 || model == 539) premiump = 250;
- format(disp,sizeof(disp),"You purchased a %s for %d premium points.",aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],premiump);
- SCM(playerid,COLOR_RED,disp);
- PlayerInfo[playerid][pPremiumPoints] -= premiump;
- Update(playerid, pPremiumPointsx);
- SendClientMessage(playerid, COLOR_GREEN3, "Inselatoriile (tepele) nu sunt permise pe server. Pentru orice incercare de a insela un player cu bunuri/bani puteti primi ban PERMANENT.");
- SendClientMessage(playerid, COLOR_GREY, "Your car has been respawned.");
- }
- else if(premium == 0)
- {
- format(disp,sizeof(disp),"(-) Congratulations! You purchased a %s for $%s.",aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],FormatNumber(value));
- SCM(playerid,COLOR_GREEN,disp);
- SendClientMessage(playerid, COLOR_GREEN3, "Inselatoriile (tepele) nu sunt permise pe server. Pentru orice incercare de a insela un player cu bunuri/bani puteti primi ban PERMANENT.");
- SendClientMessage(playerid, COLOR_GREY, "Your car has been respawned.");
- }
- GetPlayerName(playerid, numele, sizeof(numele));
- if(premium == 1)
- {
- format(stringsss,sizeof(stringsss),"%s [user:%d] bought a %s [car:%d] for %d premium points.",numele,PlayerInfo[playerid][pSQLID],aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],PlayerInfo[playerid][pCar][idcar],premiump);
- }
- else if(premium == 0)
- {
- format(stringsss,sizeof(stringsss),"%s [user:%d] bought a %s [car:%d] for $%s.",numele,PlayerInfo[playerid][pSQLID],aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],PlayerInfo[playerid][pCar][idcar],FormatNumber(value));
- }
- ABroadCast(COLOR_YELLOW,stringsss,1);
- new var100[256],string2[256];
- mysql_real_escape_string(stringsss, string2);
- mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`) VALUES ('%d','0','%s')", PlayerInfo[playerid][pSQLID],string2);
- mysql_pquery(SQL,var100,"","");
- if(premium == 3)
- {
- PlayerInfo[playerid][pCarBlock][idcar] = 720;
- mysql_format(SQL, var100, sizeof(var100), "UPDATE `cars` SET `Event`='1', `Block`='720' WHERE `ID`='%d'", PlayerInfo[playerid][pCar][idcar]);
- mysql_pquery(SQL, var100, "", "");
- }
- masini++;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement