Guest User

Weap Dealers - Jelly23's

a guest
Jan 5th, 2017
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.80 KB | None | 0 0
  1. /*
  2. Weapon Dealers
  3. Made by Jelly23
  4. */
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. /*Includes*/
  9. #include <a_samp>
  10. #include <izcmd>
  11. #include <a_mysql>
  12. #include <foreach>
  13.  
  14. /*Dialogs*/
  15. #define DIALOG_WEAPONS (0)
  16. #define DIALOG_RCON (1)
  17. #define DIALOG_CRTCR (2)
  18. #define DIALOG_CRTGO (3)
  19. #define DIALOG_CRTET (4)
  20. #define DIALOG_CRTED (5)
  21. #define DIALOG_CRTEY (6)
  22. #define DIALOG_CRTEZ (7)
  23. #define DIALOG_CRTEP (8)
  24.  
  25. /*MySQL*/
  26. #define MYSQL_HOST "localhost"
  27. #define MYSQL_USER "root"
  28. #define MYSQL_DATABASE "your database here"
  29. #define MYSQL_PASSWORD ""
  30.  
  31. /*Configuration*/
  32. #define MAX_DEALERS 500
  33.  
  34. /*Enumerator*/
  35. enum WeapDealers
  36. {
  37. ActorID,
  38. Text3D:Label,
  39. Weapon1,
  40. Weapon2,
  41. Weapon3,
  42. Weapon4,
  43. Weapon5,
  44. Weapon6,
  45. Weapon7,
  46. Weapon8,
  47. Weapon9,
  48. Weapon10,
  49. Cost1,
  50. Cost2,
  51. Cost3,
  52. Cost4,
  53. Cost5,
  54. Cost6,
  55. Cost7,
  56. Cost8,
  57. Cost9,
  58. Cost10,
  59. Ammo1,
  60. Ammo2,
  61. Ammo3,
  62. Ammo4,
  63. Ammo5,
  64. Ammo6,
  65. Ammo7,
  66. Ammo8,
  67. Ammo9,
  68. Ammo10,
  69. dSkin,
  70. Float:dAngle,
  71. Float:dX,
  72. Float:dY,
  73. Float:dZ,
  74. dWorld
  75. };
  76.  
  77. enum playerInfo
  78. {
  79. CurrentDealer,
  80. CurrentItem[10],
  81. CurrentAmmo[10],
  82. CurrentCost[10]
  83. }
  84.  
  85. /*Iterator*/
  86. new Iterator:DealerLoop<MAX_DEALERS>;
  87.  
  88. /*Array(s) & Others*/
  89. new dInfo[MAX_DEALERS][WeapDealers],
  90. pInfo[MAX_PLAYERS][playerInfo],
  91. mysql;
  92.  
  93. #if defined FILTERSCRIPT
  94.  
  95. public OnFilterScriptInit()
  96. {
  97. print("\n--------------------------------------");
  98. print(" Weapon Dealers - Made by Jelly23");
  99. print("--------------------------------------\n");
  100. mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
  101. mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
  102. if(mysql_errno(mysql) != 0)
  103. {
  104. print("Could not connect to the database!");
  105. SendRconCommand("hostname MYSQL| ERROR");
  106. }
  107. else
  108. {
  109. printf("Connected to database: %s", MYSQL_DATABASE);
  110. }
  111. if(!mysql_tquery(mysql, "SELECT * FROM `dealers`", "LoadDealers", ""))
  112. {
  113. printf("[MySQL | ERROR]: Couldn't load the information");
  114. }
  115. return 1;
  116. }
  117.  
  118. public OnFilterScriptExit()
  119. {
  120. return 1;
  121. }
  122.  
  123. #else
  124.  
  125. main()
  126. {
  127. print("\n----------------------------------");
  128. print(" Weapon Dealers - Made by Jelly23");
  129. print("----------------------------------\n");
  130. }
  131.  
  132. #endif
  133.  
  134. /*Callbacks*/
  135. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  136. {
  137. if(dialogid == DIALOG_WEAPONS)
  138. {
  139. if(response)
  140. {
  141. if(GetPlayerMoney(playerid) < pInfo[playerid][CurrentCost][listitem]) return SendClientMessage(playerid,-1,"{FF0000}[!]{FFFFFF} You haven't enough money.");
  142. GivePlayerWeapon(playerid,pInfo[playerid][CurrentItem][listitem],pInfo[playerid][CurrentAmmo][listitem]);
  143. GivePlayerMoney(playerid,-pInfo[playerid][CurrentCost][listitem]);
  144. }
  145. }
  146. if(dialogid == DIALOG_RCON)
  147. {
  148. if(response)
  149. {
  150. switch(listitem)
  151. {
  152. case 0:
  153. {
  154. foreach(new i: DealerLoop)
  155. {
  156. RemoveDealer(i);
  157. }
  158. SendClientMessageToAll(-1,"{FFFF00}[!] {FFFFFF} All weapon dealers were removed by an admin.");
  159. }
  160. case 1:
  161. {
  162. new count = -1;
  163. foreach(new i: DealerLoop)
  164. {
  165. if(IsPlayerInRangeOfPoint(playerid, 1.5, dInfo[i][dX], dInfo[i][dY], dInfo[i][dZ]))
  166. {
  167. count = i;
  168. }
  169. }
  170. if(count == -1) return SendClientMessage(playerid,-1,"{FFFF00}[!] {FFFFFF}You are not next to any weapon dealer");
  171. RemoveDealer(count);
  172. }
  173. case 2:
  174. {
  175. new count = -1;
  176. foreach(new i: DealerLoop)
  177. {
  178. if(IsPlayerInRangeOfPoint(playerid, 1.5, dInfo[i][dX], dInfo[i][dY], dInfo[i][dZ]))
  179. {
  180. count = i;
  181. }
  182. }
  183. if(count == -1) return SendClientMessage(playerid,-1,"{FFFF00}[!] {FFFFFF}You are not next to any weapon crate");
  184. dInfo[count][Weapon1] = dInfo[count][Weapon2] = dInfo[count][Weapon3] = dInfo[count][Weapon4] = dInfo[count][Weapon5] = dInfo[count][Weapon6] =
  185. dInfo[count][Weapon7] = dInfo[count][Weapon8] = dInfo[count][Weapon9] = dInfo[count][Weapon10] = -1;
  186. UpdateDealers(pInfo[playerid][CurrentDealer],0);
  187. }
  188. case 3:
  189. {
  190. ShowPlayerDialog(playerid,DIALOG_CRTCR, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Create Dealer", "Enter the skin id below:", "Create", "Cancel");
  191. }
  192. case 4:
  193. {
  194. ShowPlayerDialog(playerid,DIALOG_CRTGO, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Goto Dealer", "Enter the dealer id below:", "Go", "Cancel");
  195. }
  196. case 5:
  197. {
  198. ShowPlayerDialog(playerid,DIALOG_CRTET, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Edit Dealer", "Enter the dealer id below:", "Edit", "Cancel");
  199. }
  200. }
  201. }
  202. }
  203. if(dialogid == DIALOG_CRTCR)
  204. {
  205. if(response)
  206. {
  207. new Float:X,Float:Y,Float:Z,Float:F;
  208. GetPlayerPos(playerid,X,Y,Z);
  209. GetPlayerFacingAngle(playerid,F);
  210. CreateDealer(strval(inputtext), X, Y, Z, F, GetPlayerVirtualWorld(playerid));
  211. SetPlayerPos(playerid,X+2,Y,Z+1);
  212. }
  213. }
  214. if(dialogid == DIALOG_CRTGO)
  215. {
  216. if(response)
  217. {
  218. if (!Iter_Contains(DealerLoop, strval(inputtext))) return SendClientMessage(playerid,-1,"{FFFF00}[!] {FFFFFF} There is no such dealer id.");
  219. SetPlayerPos(playerid,dInfo[strval(inputtext)][dX]+2,dInfo[strval(inputtext)][dY],dInfo[strval(inputtext)][dZ]+1);
  220. }
  221. }
  222. if(dialogid == DIALOG_CRTET)
  223. {
  224. if(response)
  225. {
  226. if (!Iter_Contains(DealerLoop, strval(inputtext))) return SendClientMessage(playerid,-1,"{FFFF00}[!] {FFFFFF} There is no such dealer id.");
  227. pInfo[playerid][CurrentDealer] = strval(inputtext);
  228. ShowPlayerDialog(playerid,DIALOG_CRTED, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Edit Dealer", "Enter the weapon slot id below\nWeapon Slots are between: 1-10", "Edit", "Cancel");
  229. }
  230. }
  231. if(dialogid == DIALOG_CRTED)
  232. {
  233. if(response)
  234. {
  235. if( 1 < strval(inputtext) > 10) return SendClientMessage(playerid,-1,"{FFFF00}[!]{FFFFFF}Invalid slot id");
  236. pInfo[playerid][CurrentItem][0] = strval(inputtext);
  237. ShowPlayerDialog(playerid,DIALOG_CRTEY, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Edit Dealer", "Enter the weapon id below\nTo erase a weapon use '-1' as weapon id", "Edit", "Cancel");
  238. }
  239. }
  240. if(dialogid == DIALOG_CRTEY)
  241. {
  242. if(response)
  243. {
  244. switch(pInfo[playerid][CurrentItem][0])
  245. {
  246. case 1: dInfo[pInfo[playerid][CurrentDealer]][Weapon1] = strval(inputtext);
  247. case 2: dInfo[pInfo[playerid][CurrentDealer]][Weapon2] = strval(inputtext);
  248. case 3: dInfo[pInfo[playerid][CurrentDealer]][Weapon3] = strval(inputtext);
  249. case 4: dInfo[pInfo[playerid][CurrentDealer]][Weapon4] = strval(inputtext);
  250. case 5: dInfo[pInfo[playerid][CurrentDealer]][Weapon5] = strval(inputtext);
  251. case 6: dInfo[pInfo[playerid][CurrentDealer]][Weapon6] = strval(inputtext);
  252. case 7: dInfo[pInfo[playerid][CurrentDealer]][Weapon7] = strval(inputtext);
  253. case 8: dInfo[pInfo[playerid][CurrentDealer]][Weapon8] = strval(inputtext);
  254. case 9: dInfo[pInfo[playerid][CurrentDealer]][Weapon9] = strval(inputtext);
  255. case 10: dInfo[pInfo[playerid][CurrentDealer]][Weapon10] = strval(inputtext);
  256. }
  257. UpdateDealers(pInfo[playerid][CurrentDealer],0);
  258. if(strval(inputtext) == -1) return SendClientMessage(playerid,-1,"{FFFF00}[!]{FFFFFF} Weapon removed");
  259. ShowPlayerDialog(playerid,DIALOG_CRTEZ, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Edit Dealer", "Enter the ammo amount\n9999 Is the max amount of ammo.", "Edit", "Cancel");
  260. }
  261. }
  262. if(dialogid == DIALOG_CRTEZ)
  263. {
  264. if(response)
  265. {
  266. switch(pInfo[playerid][CurrentItem][0])
  267. {
  268. case 1: dInfo[pInfo[playerid][CurrentDealer]][Ammo1] = strval(inputtext);
  269. case 2: dInfo[pInfo[playerid][CurrentDealer]][Ammo2] = strval(inputtext);
  270. case 3: dInfo[pInfo[playerid][CurrentDealer]][Ammo3] = strval(inputtext);
  271. case 4: dInfo[pInfo[playerid][CurrentDealer]][Ammo4] = strval(inputtext);
  272. case 5: dInfo[pInfo[playerid][CurrentDealer]][Ammo5] = strval(inputtext);
  273. case 6: dInfo[pInfo[playerid][CurrentDealer]][Ammo6] = strval(inputtext);
  274. case 7: dInfo[pInfo[playerid][CurrentDealer]][Ammo7] = strval(inputtext);
  275. case 8: dInfo[pInfo[playerid][CurrentDealer]][Ammo8] = strval(inputtext);
  276. case 9: dInfo[pInfo[playerid][CurrentDealer]][Ammo9] = strval(inputtext);
  277. case 10: dInfo[pInfo[playerid][CurrentDealer]][Ammo10] = strval(inputtext);
  278. }
  279. UpdateDealers(pInfo[playerid][CurrentDealer],1);
  280. ShowPlayerDialog(playerid,DIALOG_CRTEP, DIALOG_STYLE_INPUT, "Weapon Dealers Menu »{FFFFFF} Edit Dealer", "Enter the weapon cost\nPut anything as the weapon cost.", "Edit", "Cancel");
  281. }
  282. }
  283. if(dialogid == DIALOG_CRTEP)
  284. {
  285. if(response)
  286. {
  287. switch(pInfo[playerid][CurrentItem][0])
  288. {
  289. case 1: dInfo[pInfo[playerid][CurrentDealer]][Cost1] = strval(inputtext);
  290. case 2: dInfo[pInfo[playerid][CurrentDealer]][Cost2] = strval(inputtext);
  291. case 3: dInfo[pInfo[playerid][CurrentDealer]][Cost3] = strval(inputtext);
  292. case 4: dInfo[pInfo[playerid][CurrentDealer]][Cost4] = strval(inputtext);
  293. case 5: dInfo[pInfo[playerid][CurrentDealer]][Cost5] = strval(inputtext);
  294. case 6: dInfo[pInfo[playerid][CurrentDealer]][Cost6] = strval(inputtext);
  295. case 7: dInfo[pInfo[playerid][CurrentDealer]][Cost7] = strval(inputtext);
  296. case 8: dInfo[pInfo[playerid][CurrentDealer]][Cost8] = strval(inputtext);
  297. case 9: dInfo[pInfo[playerid][CurrentDealer]][Cost9] = strval(inputtext);
  298. case 10: dInfo[pInfo[playerid][CurrentDealer]][Cost10] = strval(inputtext);
  299. }
  300. UpdateDealers(pInfo[playerid][CurrentDealer],2);
  301. SendClientMessage(playerid,-1,"{FF0000}[!]{FFFFFF} Weapon slot succesfuly edited.");
  302. }
  303. }
  304. return 1;
  305. }
  306.  
  307. forward LoadDealers();
  308. public LoadDealers()
  309. {
  310. new t,string[55];
  311. for(new i = 0; i < cache_get_row_count(); i++)
  312. {
  313. t = cache_get_field_content_int(i,"ID");
  314. Iter_Add(DealerLoop,t);
  315.  
  316. dInfo[t][dSkin] = cache_get_field_content_int(i,"dSkin");
  317.  
  318. dInfo[t][dX] = cache_get_field_content_float(i, "dX");
  319. dInfo[t][dY] = cache_get_field_content_float(i, "dY");
  320. dInfo[t][dZ] = cache_get_field_content_float(i, "dZ");
  321.  
  322. dInfo[t][dAngle] = cache_get_field_content_float(i, "dAngle");
  323.  
  324. format(string,sizeof(string),"{FF0000}Weapon Dealer (%i)\n\n{FFFFFF}Use {00FF00}/weaps",t);
  325. dInfo[t][ActorID] = CreateActor(dInfo[t][dSkin], dInfo[t][dX], dInfo[t][dY], dInfo[t][dZ], dInfo[t][dAngle]);
  326. dInfo[t][Label] = Create3DTextLabel(string, -1,dInfo[t][dX],dInfo[t][dY],dInfo[t][dZ]+0.4, 5.0,0, 0);
  327.  
  328. dInfo[t][Weapon1] = cache_get_field_content_int(i,"Weapon1");
  329. dInfo[t][Weapon2] = cache_get_field_content_int(i,"Weapon2");
  330. dInfo[t][Weapon3] = cache_get_field_content_int(i,"Weapon3");
  331. dInfo[t][Weapon4] = cache_get_field_content_int(i,"Weapon4");
  332. dInfo[t][Weapon5] = cache_get_field_content_int(i,"Weapon5");
  333. dInfo[t][Weapon6] = cache_get_field_content_int(i,"Weapon6");
  334. dInfo[t][Weapon7] = cache_get_field_content_int(i,"Weapon7");
  335. dInfo[t][Weapon8] = cache_get_field_content_int(i,"Weapon8");
  336. dInfo[t][Weapon9] = cache_get_field_content_int(i,"Weapon9");
  337. dInfo[t][Weapon10] = cache_get_field_content_int(i,"Weapon10");
  338.  
  339. dInfo[t][Cost1] = cache_get_field_content_int(i,"Cost1");
  340. dInfo[t][Cost2] = cache_get_field_content_int(i,"Cost2");
  341. dInfo[t][Cost3] = cache_get_field_content_int(i,"Cost3");
  342. dInfo[t][Cost4] = cache_get_field_content_int(i,"Cost4");
  343. dInfo[t][Cost5] = cache_get_field_content_int(i,"Cost5");
  344. dInfo[t][Cost6] = cache_get_field_content_int(i,"Cost6");
  345. dInfo[t][Cost7] = cache_get_field_content_int(i,"Cost7");
  346. dInfo[t][Cost8] = cache_get_field_content_int(i,"Cost8");
  347. dInfo[t][Cost9] = cache_get_field_content_int(i,"Cost9");
  348. dInfo[t][Cost10] = cache_get_field_content_int(i,"Cost10");
  349.  
  350. dInfo[t][Ammo1] = cache_get_field_content_int(i,"Ammo1");
  351. dInfo[t][Ammo2] = cache_get_field_content_int(i,"Ammo2");
  352. dInfo[t][Ammo3] = cache_get_field_content_int(i,"Ammo3");
  353. dInfo[t][Ammo4] = cache_get_field_content_int(i,"Ammo4");
  354. dInfo[t][Ammo5] = cache_get_field_content_int(i,"Ammo5");
  355. dInfo[t][Ammo6] = cache_get_field_content_int(i,"Ammo6");
  356. dInfo[t][Ammo7] = cache_get_field_content_int(i,"Ammo7");
  357. dInfo[t][Ammo8] = cache_get_field_content_int(i,"Ammo8");
  358. dInfo[t][Ammo9] = cache_get_field_content_int(i,"Ammo9");
  359. dInfo[t][Ammo10] = cache_get_field_content_int(i,"Ammo10");
  360. }
  361. printf("\n=======================================\n");
  362. printf(" Weapon Dealers loaded!\n");
  363. printf(" A total of %d dealers out of %d loaded\n", cache_get_row_count(), MAX_DEALERS);
  364. printf("\n=======================================\n");
  365. }
  366.  
  367. /*Functions*/
  368. CreateDealer(Skin, Float:X, Float:Y, Float:Z, Float:Angle, World)
  369. {
  370. new FreeID = Iter_Free(DealerLoop),string[55],query[621];
  371. format(string,sizeof(string),"{FF0000}Weapon Dealer (%i)\n\nUse {00FF00}/weaps",FreeID);
  372. Iter_Add(DealerLoop, FreeID);
  373. dInfo[FreeID][dAngle] = Angle;
  374. dInfo[FreeID][dWorld] = World;
  375. dInfo[FreeID][dSkin] = Skin;
  376. dInfo[FreeID][dX] = X,dInfo[FreeID][dY] = Y,dInfo[FreeID][dZ] = Z;
  377. dInfo[FreeID][Weapon1] = dInfo[FreeID][Weapon2] = dInfo[FreeID][Weapon3] = dInfo[FreeID][Weapon4] = dInfo[FreeID][Weapon5] =
  378. dInfo[FreeID][Weapon6] = dInfo[FreeID][Weapon7] = dInfo[FreeID][Weapon8] = dInfo[FreeID][Weapon9] = dInfo[FreeID][Weapon10] = -1;
  379. dInfo[FreeID][ActorID] = CreateActor(Skin, X, Y, Z, Angle);
  380. SetActorVirtualWorld(dInfo[FreeID][ActorID], World);
  381. dInfo[FreeID][Label] = Create3DTextLabel(string, -1,dInfo[FreeID][dX],dInfo[FreeID][dY],dInfo[FreeID][dZ]+0.4, 5.0,0, 0);
  382. mysql_format(mysql, query, sizeof(query), "INSERT INTO `dealers` (`ID`, `dSkin`, `dX`, `dY`, `dZ`, `dAngle`, `Weapon1`, `Weapon2` , `Weapon3`, `Weapon4`, `Weapon5`, `Weapon6`, `Weapon7`, `Weapon8`, `Weapon9`, `Weapon10`) VALUES ('%i', '%i', '%f', '%f', \
  383. '%f', '%f', '%i', '%i', '%i','%i', '%i', '%i', '%i', '%i', '%i', '%i')",
  384. FreeID,dInfo[FreeID][dSkin],dInfo[FreeID][dX],dInfo[FreeID][dY],dInfo[FreeID][dZ],dInfo[FreeID][dAngle],dInfo[FreeID][Weapon1],dInfo[FreeID][Weapon2],dInfo[FreeID][Weapon3],dInfo[FreeID][Weapon4],dInfo[FreeID][Weapon5],dInfo[FreeID][Weapon6],dInfo[FreeID][Weapon7],dInfo[FreeID][Weapon8],dInfo[FreeID][Weapon9],dInfo[FreeID][Weapon10]);
  385. mysql_tquery(mysql, query, "","");
  386. }
  387.  
  388. RemoveDealer(dealerid)
  389. {
  390. new query[43];
  391. Iter_Remove(DealerLoop, dealerid);
  392. DestroyActor(dInfo[dealerid][ActorID]);
  393. Delete3DTextLabel(dInfo[dealerid][Label]);
  394. dInfo[dealerid][Weapon1] = dInfo[dealerid][Weapon2] = dInfo[dealerid][Weapon3] = dInfo[dealerid][Weapon4] = dInfo[dealerid][Weapon5] =
  395. dInfo[dealerid][Weapon6] = dInfo[dealerid][Weapon7] = dInfo[dealerid][Weapon8] = dInfo[dealerid][Weapon9] = dInfo[dealerid][Weapon10] = -1;
  396. mysql_format(mysql,query,sizeof(query),"DELETE FROM `dealers` WHERE `ID` ='%i'",dealerid);
  397. mysql_tquery(mysql,query,"","");
  398. }
  399.  
  400. UpdateDealers(i,updateid)
  401. {
  402. new query[352];
  403. switch(updateid)
  404. {
  405. case 0:
  406. {
  407. mysql_format(mysql, query, sizeof(query), "UPDATE `dealers` SET `Weapon1` ='%i' , `Weapon2` ='%i' , `Weapon3` ='%i' , `Weapon4` ='%i', `Weapon5` = '%i', `Weapon6` ='%i', `Weapon7` ='%i', `Weapon8` ='%i', `Weapon9` ='%i', `Weapon10` ='%i' WHERE `ID` = '%i'",
  408. dInfo[i][Weapon1],dInfo[i][Weapon2],dInfo[i][Weapon3],dInfo[i][Weapon4],dInfo[i][Weapon5],dInfo[i][Weapon6],dInfo[i][Weapon7],dInfo[i][Weapon8],dInfo[i][Weapon9],dInfo[i][Weapon10],i);
  409. mysql_tquery(mysql,query,"","");
  410. }
  411. case 1:
  412. {
  413. mysql_format(mysql, query, sizeof(query), "UPDATE `dealers` SET `Ammo1` ='%i' , `Ammo2` ='%i' , `Ammo3` ='%i' , `Ammo4` ='%i', `Ammo5` = '%i', `Ammo6` ='%i', `Ammo7` ='%i', `Ammo8` ='%i', `Ammo9` ='%i', `Ammo10` ='%i' WHERE `ID` = '%i'",
  414. dInfo[i][Ammo1],dInfo[i][Ammo2],dInfo[i][Ammo3],dInfo[i][Ammo4],dInfo[i][Ammo5],dInfo[i][Ammo6],dInfo[i][Ammo7],dInfo[i][Ammo8],dInfo[i][Ammo9],dInfo[i][Ammo10],i);
  415. mysql_tquery(mysql,query,"","");
  416. }
  417. case 2:
  418. {
  419. mysql_format(mysql, query, sizeof(query), "UPDATE `dealers` SET `Cost1` ='%i' , `Cost2` ='%i' , `Cost3` ='%i' , `Cost4` ='%i', `Cost5` = '%i', `Cost6` ='%i', `Cost7` ='%i', `Cost8` ='%i', `Cost9` ='%i', `Cost10` ='%i' WHERE `ID` = '%i'",
  420. dInfo[i][Cost1],dInfo[i][Cost2],dInfo[i][Cost3],dInfo[i][Cost4],dInfo[i][Cost5],dInfo[i][Cost6],dInfo[i][Cost7],dInfo[i][Cost8],dInfo[i][Cost9],dInfo[i][Cost10],i);
  421. mysql_tquery(mysql,query,"","");
  422. }
  423. }
  424. }
  425.  
  426. ShowWeaps(playerid,dealerid)
  427. {
  428. new i[1043],z,x,y;
  429. format(i,sizeof(i),"Weapon\tPrice\tAmmo\n");
  430. for(new p = 2; p < 12; p++)
  431. {
  432. if(dInfo[dealerid][WeapDealers:p] != -1)
  433. {
  434. z = p+10;
  435. x = p+20;
  436. pInfo[playerid][CurrentCost][y] = dInfo[dealerid][WeapDealers:z];
  437. pInfo[playerid][CurrentAmmo][y] = dInfo[dealerid][WeapDealers:x];
  438. pInfo[playerid][CurrentItem][y] = dInfo[dealerid][WeapDealers:p];
  439. format(i,sizeof(i),"%s{FFFFFF}%s\t{00FF00}$%i\t{FFFFFF}%i\n",i,GetWeaponNameEx(dInfo[dealerid][WeapDealers:p]),dInfo[dealerid][WeapDealers:z],dInfo[dealerid][WeapDealers:x]);
  440. y++;
  441. }
  442. }
  443. if(y == 0) return SendClientMessage(playerid,-1,"{FFFF00}[!]{FFFFFF}This weapon dealer has no weapons.");
  444. ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_TABLIST_HEADERS, "Buy Weapon",i,"Select","Cancel");
  445. return 1;
  446. }
  447.  
  448. GetWeaponNameEx(weaponid)
  449. {
  450. new weaponna[32];
  451. switch(weaponid)
  452. {
  453. case 18: weaponna = "Molotov Cocktail";
  454. case 44: weaponna = "Night Vision Goggles";
  455. case 45: weaponna = "Thermal Goggles";
  456. default: GetWeaponName(weaponid, weaponna, sizeof(weaponna));
  457. }
  458. return weaponna;
  459. }
  460.  
  461.  
  462. /*Commands*/
  463. CMD:weaps(playerid)
  464. {
  465. new count;
  466. foreach(new i: DealerLoop)
  467. {
  468. if(IsPlayerInRangeOfPoint(playerid, 1.5, dInfo[i][dX], dInfo[i][dY], dInfo[i][dZ]))
  469. {
  470. pInfo[playerid][CurrentDealer] = i;
  471. count++;
  472. }
  473. }
  474. if(count == 0) return SendClientMessage(playerid,-1,"{FFFF00}[!] {FFFFFF}You are not next to any weapon dealer.");
  475. ShowWeaps(playerid,pInfo[playerid][CurrentDealer]);
  476. return 1;
  477. }
  478.  
  479. CMD:dmenu(playerid)
  480. {
  481. if(IsPlayerAdmin(playerid))
  482. {
  483. new count,string[134];
  484. foreach(new c: DealerLoop)
  485. {
  486. count++;
  487. }
  488. format(string,sizeof(string),"%s» Destroy all dealers {FF0000}(%i)\n{FFFFFF}» Destroy closest dealer\n» Reset closest dealer\n» Create dealer\n» Goto dealer\n» Edit dealer",string,count);
  489. ShowPlayerDialog(playerid, DIALOG_RCON, DIALOG_STYLE_LIST, "Weapon Dealers Menu",string, "Select", "Cancel");
  490. }
  491. return 1;
  492. }
  493.  
  494. CMD:test(playerid)
  495. {
  496. if(IsPlayerAdmin(playerid))
  497. {
  498. GivePlayerMoney(playerid,10000);
  499. }
  500. return 1;
  501. }
Advertisement
Add Comment
Please, Sign In to add comment