Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. public InsertCar(playerid,stockid,premium)
  2. {
  3. new string[256],sendername[25],total,idcar,premiump=0;
  4. new model = Stock[stockid][vModel];
  5. new value = Stock[stockid][vPrice];
  6. GetPlayerName(playerid,sendername,sizeof(sendername));
  7. BuyCar[playerid] = -1;
  8. if(GetPlayerCash(playerid) < value && premium == 0) return SCM(playerid,COLOR_GREY,"You don't have enough money to purchase this vehicle.");
  9. for(new v; v < MAX_PERSONAL_VEHICLES; v++)
  10. {
  11. if(PlayerInfo[playerid][pCar][v] != -1) total++;
  12. }
  13. if(total+1 > PlayerInfo[playerid][pCarSlots])
  14. {
  15. 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.");
  16. return 1;
  17. }
  18. for(new v; v < MAX_PERSONAL_VEHICLES; v++)
  19. {
  20. if(PlayerInfo[playerid][pCar][v] == -1)
  21. {
  22. idcar = v;
  23. break;
  24. }
  25. }
  26.  
  27. mysql_format(SQL, string, sizeof(string),"INSERT INTO cars (Model) VALUES (%d)", model);
  28. new Cache:ids = mysql_query(SQL,string);
  29. new idd = cache_insert_id();
  30. cache_delete(ids);
  31.  
  32. PlayerInfo[playerid][pCar][idcar] = idd;
  33.  
  34. 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)
  35. {
  36. PlayerInfo[playerid][pCarLocX][idcar] = 388.5440;
  37. PlayerInfo[playerid][pCarLocY][idcar] = -1522.2147;
  38. PlayerInfo[playerid][pCarLocZ][idcar] = 32.1853;
  39. PlayerInfo[playerid][pCarAngle][idcar] = 45.0;
  40. PlayerInfo[playerid][pCarLLocX][idcar] = 388.5440;
  41. PlayerInfo[playerid][pCarLLocY][idcar] = -1522.2147;
  42. PlayerInfo[playerid][pCarLLocZ][idcar] = 32.1853;
  43. PlayerInfo[playerid][pCarAngle2][idcar] = 45.0;
  44. }
  45. else
  46. {
  47. PlayerInfo[playerid][pCarLocX][idcar] = 284.5032;
  48. PlayerInfo[playerid][pCarLocY][idcar] = -1526.4036;
  49. PlayerInfo[playerid][pCarLocZ][idcar] = 24.3208;
  50. PlayerInfo[playerid][pCarAngle][idcar] = 45.0;
  51. PlayerInfo[playerid][pCarLLocX][idcar] = 284.5032;
  52. PlayerInfo[playerid][pCarLLocY][idcar] = -1526.4036;
  53. PlayerInfo[playerid][pCarLLocZ][idcar] = 24.3208;
  54. PlayerInfo[playerid][pCarAngle2][idcar] = 45.0;
  55. }
  56. if(premium == 0)
  57. {
  58. GivePlayerCash(playerid,-value);
  59. Update(playerid,pCashx);
  60.  
  61. mysql_format(SQL, string, sizeof(string), "UPDATE `stock` SET `Stock`='%d' WHERE `ID`='%d'", Stock[stockid][vStock],stockid);
  62. mysql_pquery(SQL,string,"","");
  63. }
  64. PlayerInfo[playerid][pCarModel][idcar] = model;
  65. PlayerInfo[playerid][pCarColor1][idcar] = 1;
  66. PlayerInfo[playerid][pCarColor2][idcar] = 1;
  67. format(string,sizeof(string),"{FA5778}%d",(100000000 + random(9999999999)));
  68. CarVipName[playerid][idcar] = "";
  69. strmid(CarPlate[playerid][idcar], string, 0, 20, 255);
  70. strmid(CarOwner[playerid][idcar], PlayerInfo[playerid][pNormalName], 0, 50, 255);
  71. PlayerInfo[playerid][pCarLock][idcar] = 0;
  72. PlayerInfo[playerid][pCarInsPrice][idcar] = 5000;
  73. PlayerInfo[playerid][pCarIns][idcar] = 10;
  74. PlayerInfo[playerid][pCarKM][idcar] = 0.0;
  75. PlayerInfo[playerid][pCarKMLast][idcar] = 0;
  76. PlayerInfo[playerid][pCarVIP][idcar] = 0;
  77. PlayerInfo[playerid][pCarVipColors][idcar] = 0;
  78. PlayerInfo[playerid][pCarHP][idcar] = 1000.0;
  79. PlayerInfo[playerid][pCarDamage1][idcar] = 0;
  80. PlayerInfo[playerid][pCarDamage2][idcar] = 0;
  81. PlayerInfo[playerid][pCarDamage3][idcar] = 0;
  82. PlayerInfo[playerid][pCarDamage4][idcar] = 0;
  83. PlayerInfo[playerid][pCarGas][idcar] = 200;
  84. PlayerInfo[playerid][pCarPaintJ][idcar] = 6;
  85. PlayerInfo[playerid][pCarBlock][idcar] = 0;
  86. for(new s; s < 17; s++)
  87. {
  88. CarMod[playerid][idcar][s] = 0;
  89. }
  90. PlayerInfo[playerid][pCarBuyTime][idcar] = gettime();
  91.  
  92. cUpdate(playerid, idcar, cModsx);
  93. cUpdate(playerid, idcar, cPaintJx);
  94. cUpdate(playerid, idcar, cLocationxx);
  95. cUpdate(playerid, idcar, cLocationyx);
  96. cUpdate(playerid, idcar, cLocationzx);
  97. cUpdate(playerid, idcar, cAnglex);
  98. cUpdate(playerid, idcar, cLocationx2x);
  99. cUpdate(playerid, idcar, cLocationy2x);
  100. cUpdate(playerid, idcar, cLocationz2x);
  101. cUpdate(playerid, idcar, cAngle2x);
  102. cUpdate(playerid, idcar, cColorOnex);
  103. cUpdate(playerid, idcar, cColorTwox);
  104. cUpdate(playerid, idcar, cValuex);
  105. cUpdate(playerid, idcar, cLicensex);
  106. cUpdate(playerid, idcar, cLockx);
  107. cUpdate(playerid, idcar, cInscarpricex);
  108. cUpdate(playerid, idcar, cInsurancecarx);
  109. cUpdate(playerid, idcar, cKMx);
  110. cUpdate(playerid, idcar, cDaysx);
  111. cUpdate(playerid, idcar, cHPx);
  112. cUpdate(playerid, idcar, cKMLastx);
  113. cUpdate(playerid, idcar, cDamage1x);
  114. cUpdate(playerid, idcar, cDamage2x);
  115. cUpdate(playerid, idcar, cDamage3x);
  116. cUpdate(playerid, idcar, cDamage4x);
  117. cUpdate(playerid, idcar, cGasx);
  118. cUpdate(playerid, idcar, cOwnerx);
  119.  
  120. 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);
  121. SetVehicleNumberPlate(PlayerInfo[playerid][pCarID][idcar],CarPlate[playerid][idcar]);
  122. Gas[PlayerInfo[playerid][pCarID][idcar]] = 200;
  123.  
  124. LocateCar(PlayerInfo[playerid][pCarID][idcar], playerid);
  125.  
  126. new disp[184],stringsss[256],numele[30];
  127. if(premium == 1)
  128. {
  129. if(model == 469) premiump = 220;
  130. if(model == 487) premiump = 300;
  131. if(model == 494 || model == 502 || model == 503 || model == 539) premiump = 250;
  132. format(disp,sizeof(disp),"You purchased a %s for %d premium points.",aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],premiump);
  133. SCM(playerid,COLOR_RED,disp);
  134. PlayerInfo[playerid][pPremiumPoints] -= premiump;
  135. Update(playerid, pPremiumPointsx);
  136. 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.");
  137. SendClientMessage(playerid, COLOR_GREY, "Your car has been respawned.");
  138. }
  139. else if(premium == 0)
  140. {
  141. format(disp,sizeof(disp),"(-) Congratulations! You purchased a %s for $%s.",aVehicleNames[PlayerInfo[playerid][pCarModel][idcar] - 400],FormatNumber(value));
  142. SCM(playerid,COLOR_GREEN,disp);
  143. 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.");
  144. SendClientMessage(playerid, COLOR_GREY, "Your car has been respawned.");
  145. }
  146. GetPlayerName(playerid, numele, sizeof(numele));
  147. if(premium == 1)
  148. {
  149. 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);
  150. }
  151. else if(premium == 0)
  152. {
  153. 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));
  154. }
  155. ABroadCast(COLOR_YELLOW,stringsss,1);
  156. new var100[256],string2[256];
  157. mysql_real_escape_string(stringsss, string2);
  158. mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`) VALUES ('%d','0','%s')", PlayerInfo[playerid][pSQLID],string2);
  159. mysql_pquery(SQL,var100,"","");
  160. if(premium == 3)
  161. {
  162. PlayerInfo[playerid][pCarBlock][idcar] = 720;
  163. mysql_format(SQL, var100, sizeof(var100), "UPDATE `cars` SET `Event`='1', `Block`='720' WHERE `ID`='%d'", PlayerInfo[playerid][pCar][idcar]);
  164. mysql_pquery(SQL, var100, "", "");
  165. }
  166. masini++;
  167. return 1;
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement