Guest User

by Godhimself

a guest
Jul 22nd, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.18 KB | None | 0 0
  1. /*
  2. Example filterscript: How to make a simple neon shop for your server. (Tutorial) - by Godhimself
  3.  
  4. Release date: 22nd of July 2011.
  5.  
  6. Link: http://forum.sa-mp.com/showthread.php?p=1305273#post1305273
  7.  
  8. Credits:
  9.  
  10. - <a_samp> - Credits to the samp dev team for there callbacks/functions.
  11. - <zcmd> - Credits to Zeex for his/her command proccessor.
  12.  
  13. */
  14. #define FILTERSCRIPT
  15. #include <a_samp>//Credits to the samp dev team.
  16. #include <zcmd>//Credits to Zeex.
  17.  
  18. //White Hex(In dialogs)
  19. #define WHITE_HEX {FFFFFF}
  20. //Colour defines(Messages)
  21. #define COLOUR_WHITE 0xFFFFFFAA
  22. #define COLOUR_RED 0xFF0000FF
  23.  
  24. //Dialog id:
  25. #define NEON_DIALOG 0//You may need to change the id.
  26. //The neon prices:
  27. #define BLUE_NEONS_PRICE 10000//You may want to change this.
  28. #define RED_NEONS_PRICE 10000//You may want to change this.
  29. #define GREEN_NEONS_PRICE 10000//You may want to change this.
  30. #define YELLOW_NEONS_PRICE 10000//You may want to change this.
  31. #define PINK_NEONS_PRICE 10000//You may want to change this.
  32.  
  33. CMD:neonshop(playerid, params[])//Rename it to w/e you like..
  34. {
  35. new string[100];//Define our string to use later when we format our neon prices into a string and show it in the dialog..
  36. switch(GetVehicleModel(GetPlayerVehicleID(playerid)))//Get there vehicle model and switch through each vehicle id to check if there in one of our defined vehicles..
  37. {
  38. case 562,565,559,561,560,575,534,567,536,535,576,411,579,602,496,518,527,589,597,419,
  39. 533,526,474,545,517,410,600,436,580,439,549,491,445,604,507,585,587,466,492,546,551,516,
  40. 426,547,405,409,550,566,406,540,421,529,431,438,437,420,525,552,416,433,427,490,528,
  41. 407,544,470,598,596,599,601,428,499,609,524,578,486,573,455,588,403,514,423,
  42. 414,443,515,456,422,482,530,418,572,413,440,543,583,478,554,402,542,603,475,568,504,457,
  43. 483,508,429,541,415,480,434,506,451,555,477,400,404,489,479,442,458,467,558://Switch through these cases and if there in one of these ids..
  44. {
  45. format(string, sizeof(string), "WHITE_HEXBlue Neons: $%d\nRed Neons: $%d\nGreen Neons: $%d\nYellow Neons: $%d\nPink Neons: $%d\nRemove Neons: Free", BLUE_NEONS_PRICE, RED_NEONS_PRICE, GREEN_NEONS_PRICE, YELLOW_NEONS_PRICE, PINK_NEONS_PRICE);//Format the string..
  46. ShowPlayerDialog(playerid, NEON_DIALOG, DIALOG_STYLE_LIST, "WHITE_HEXNeon Shop", string, "Select", "Cancel");//Show the neon dialog with the formatted string..
  47. }
  48. default: return SendClientMessage(playerid,COLOUR_RED,"You cannot tune this vehicle.");//Else there not in a any of our defined vehicle ids..
  49. }
  50. return true;
  51. }
  52.  
  53. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  54. {
  55. switch(dialogid)//Switch through the dialog ids..
  56. {
  57. case NEON_DIALOG://For dialog id NEON_DIALOG..
  58. {
  59. if(response)//If they click something other than cancel..
  60. {
  61. switch(listitem)//Switch the list items..
  62. {
  63. case 0://If they click blue neons..
  64. {
  65. if(GetPlayerMoney(playerid) >= BLUE_NEONS_PRICE)//Check if there there holding amount is more or equal to BLUE_NEONS_PRICE if so..
  66. {
  67. SetPVarInt(playerid, "HasBlueNeons", 1);//Set there status in a player variable..
  68. SetPVarInt(playerid, "BlueNeons1", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
  69. SetPVarInt(playerid, "BlueNeons2", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
  70. AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  71. AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  72. GivePlayerMoney(playerid, - BLUE_NEONS_PRICE);//Remove the BLUE_NEONS_PRICE from the players holding amount..
  73. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
  74. new string[80];//Define our string to use later ti format BLUE_NEONS_PRICE into a string and show it in a message..
  75. format(string, sizeof(string), "You have successfully added blue neons to your vehicle. Cost: $%d", BLUE_NEONS_PRICE);//Format the string..
  76. SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
  77. }
  78. else
  79. {
  80. SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of BLUE_NEONS_PRICE..
  81. }
  82. }
  83. case 1://If they click red neons..
  84. {
  85. if(GetPlayerMoney(playerid) >= RED_NEONS_PRICE)//Check if there there holding amount is more or equal to RED_NEONS_PRICE if so..
  86. {
  87. SetPVarInt(playerid, "HasRedNeons", 1);//Set there status in a player variable..
  88. SetPVarInt(playerid, "RedNeons1", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
  89. SetPVarInt(playerid, "RedNeons2", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
  90. AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  91. AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  92. GivePlayerMoney(playerid, - RED_NEONS_PRICE);//Remove the RED_NEONS_PRICE from the players holding amount..
  93. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
  94. new string[80];//Define our string to use later ti format RED_NEONS_PRICE into a string and show it in a message..
  95. format(string, sizeof(string), "You have successfully added red neons to your vehicle. Cost: $%d", RED_NEONS_PRICE);//Format the string..
  96. SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
  97. }
  98. else
  99. {
  100. SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of RED_NEONS_PRICE..
  101. }
  102. }
  103. case 2://If they click green neons..
  104. {
  105. if(GetPlayerMoney(playerid) >= GREEN_NEONS_PRICE)//Check if there there holding amount is more or equal to GREEN_NEONS_PRICE if so..
  106. {
  107. SetPVarInt(playerid, "HasGreenNeons", 1);//Set there status in a player variable..
  108. SetPVarInt(playerid, "GreenNeons1", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
  109. SetPVarInt(playerid, "GreenNeons2", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
  110. AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  111. AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  112. GivePlayerMoney(playerid, - GREEN_NEONS_PRICE);//Remove the GREEN_NEONS_PRICE from the players holding amount..
  113. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
  114. new string[80];//Define our string to use later ti format GREEN_NEONS_PRICE into a string and show it in a message..
  115. format(string, sizeof(string), "You have successfully added green neons to your vehicle. Cost: $%d", GREEN_NEONS_PRICE);//Format the string..
  116. SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
  117. }
  118. else
  119. {
  120. SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of GREEN_NEONS_PRICE..
  121. }
  122. }
  123. case 3://If they click yellow neons..
  124. {
  125. if(GetPlayerMoney(playerid) >= YELLOW_NEONS_PRICE)//Check if there there holding amount is more or equal to YELLOW_NEONS_PRICE if so..
  126. {
  127. SetPVarInt(playerid, "HasYellowNeons", 1);//Set there status in a player variable..
  128. SetPVarInt(playerid, "YellowNeons1", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
  129. SetPVarInt(playerid, "YellowNeons2", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
  130. AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  131. AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  132. GivePlayerMoney(playerid, - YELLOW_NEONS_PRICE);//Remove the YELLOW_NEONS_PRICE from the players holding amount..
  133. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
  134. new string[80];//Define our string to use later ti format YELLOW_NEONS_PRICE into a string and show it in a message..
  135. format(string, sizeof(string), "You have successfully added yellow neons to your vehicle. Cost: $%d", YELLOW_NEONS_PRICE);//Format the string..
  136. SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
  137. }
  138. else
  139. {
  140. SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of YELLOW_NEONS_PRICE..
  141. }
  142. }
  143. case 4://If they click pink neons..
  144. {
  145. if(GetPlayerMoney(playerid) >= PINK_NEONS_PRICE)//Check if there there holding amount is more or equal to PINK_NEONS_PRICE if so..
  146. {
  147. SetPVarInt(playerid, "HasPinkNeons", 1);//Set there status in a player variable..
  148. SetPVarInt(playerid, "PinkNeons1", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
  149. SetPVarInt(playerid, "PinkNeons2", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
  150. AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  151. AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
  152. GivePlayerMoney(playerid, - PINK_NEONS_PRICE);//Remove the PINK_NEONS_PRICE from the players holding amount..
  153. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
  154. new string[80];//Define our string to use later ti format PINK_NEONS_PRICE into a string and show it in a message..
  155. format(string, sizeof(string), "You have successfully added pink neons to your vehicle. Cost: $%d", PINK_NEONS_PRICE);//Format the string..
  156. SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
  157. }
  158. else
  159. {
  160. SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of PINK_NEONS_PRICE..
  161. }
  162. }
  163. case 5://If they click remove neons..
  164. {
  165. if(GetPVarInt(playerid, "HasBlueNeons") == 1)//If they have blue neons..
  166. {
  167. DeletePVar(playerid, "HasBlueNeons");//Remove there status..
  168. DestroyObject(GetPVarInt(playerid, "BlueNeons1"));//And objects..
  169. DestroyObject(GetPVarInt(playerid, "BlueNeons2"));//And objects..
  170. SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
  171. }
  172. else if(GetPVarInt(playerid, "HasRedNeons") == 1)//If they have red neons..
  173. {
  174. DeletePVar(playerid, "HasRedNeons");//Remove there status..
  175. DestroyObject(GetPVarInt(playerid, "RedNeons1"));//And objects..
  176. DestroyObject(GetPVarInt(playerid, "RedNeons2"));//And objects..
  177. SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
  178. }
  179. else if(GetPVarInt(playerid, "HasGreenNeons") == 1)//If they have green neons..
  180. {
  181. DeletePVar(playerid, "HasGreenNeons");//Remove there status..
  182. DestroyObject(GetPVarInt(playerid, "GreenNeons1"));//And objects..
  183. DestroyObject(GetPVarInt(playerid, "GreenNeons2"));//And objects..
  184. SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
  185. }
  186. else if(GetPVarInt(playerid, "HasYellowNeons") == 1)//If they have yellow neons..
  187. {
  188. DeletePVar(playerid, "HasYellowNeons");//Remove there status..
  189. DestroyObject(GetPVarInt(playerid, "YellowNeons1"));//And objects..
  190. DestroyObject(GetPVarInt(playerid, "YellowNeons2"));//And objects..
  191. SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
  192. }
  193. else if(GetPVarInt(playerid, "HasPinkNeons") == 1)//If they have pink neons..
  194. {
  195. DeletePVar(playerid, "HasPinkNeons");//Remove there status..
  196. DestroyObject(GetPVarInt(playerid, "PinkNeons1"));//And objects..
  197. DestroyObject(GetPVarInt(playerid, "PinkNeons2"));//And objects..
  198. SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
  199. }
  200. else
  201. {
  202. SendClientMessage(playerid, COLOUR_WHITE, "You dont have any neons to remove.");//Else they dont have any neons to remove..
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. return 1;
  210. }
  211.  
  212. public OnVehicleDeath(vehicleid, killerid)
  213. {
  214. new i;//New i which defines our playerid..
  215. for(i = 0; i < MAX_PLAYERS; i ++)// i = 0 and is less than MAX_PLAYERS, increase 0 and loop untill you get to MAX_PLAYERS and return 1..
  216. {
  217. if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid)//If the player id is connected and there vehicle id = the vehicleid that was destroyed..
  218. {
  219. if(GetPVarInt(i, "HasBlueNeons") == 1)//If they have blue neons..
  220. {
  221. DeletePVar(i, "HasBlueNeons");//Remove there status..
  222. DestroyObject(GetPVarInt(i, "BlueNeons1"));//And objects..
  223. DestroyObject(GetPVarInt(i, "BlueNeons2"));//And objects..
  224. }
  225. else if(GetPVarInt(i, "HasRedNeons") == 1)//If they have red neons..
  226. {
  227. DeletePVar(i, "HasRedNeons");//Remove there status..
  228. DestroyObject(GetPVarInt(i, "RedNeons1"));//And objects..
  229. DestroyObject(GetPVarInt(i, "RedNeons2"));//And objects..
  230. }
  231. else if(GetPVarInt(i, "HasGreenNeons") == 1)//If they have green neons..
  232. {
  233. DeletePVar(i, "HasGreenNeons");//Remove there status..
  234. DestroyObject(GetPVarInt(i, "GreenNeons1"));//And objects..
  235. DestroyObject(GetPVarInt(i, "GreenNeons2"));//And objects..
  236. }
  237. else if(GetPVarInt(i, "HasYellowNeons") == 1)//If they have yellow neons..
  238. {
  239. DeletePVar(i, "HasYellowNeons");//Remove there status..
  240. DestroyObject(GetPVarInt(i, "YellowNeons1"));//And objects..
  241. DestroyObject(GetPVarInt(i, "YellowNeons2"));//And objects..
  242. }
  243. else if(GetPVarInt(i, "HasPinkNeons") == 1)//If they have pink neons..
  244. {
  245. DeletePVar(i, "HasPinkNeons");//Remove there status..
  246. DestroyObject(GetPVarInt(i, "PinkNeons1"));//And objects..
  247. DestroyObject(GetPVarInt(i, "PinkNeons2"));//And objects..
  248. }
  249. }
  250. }
  251. return 1;
  252. }
  253.  
  254. /*
  255. Tutorial/Script by Godhimself
  256. */
Advertisement
Add Comment
Please, Sign In to add comment