Advertisement
Guest User

Sistema de viagem com tempo

a guest
Oct 4th, 2011
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.15 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define aerols 544 // ID DIALOG
  4. #define aerolstolv 545 // ID DIALOG
  5. #define aerolstosf 546 // ID DIALOG
  6. #define aerolv 547 // ID DIALOG
  7. #define aerolvtols 548 // ID DIALOG
  8. #define aerolvtosf 549 // ID DIALOG
  9. #define aerosf 550 // ID DIALOG
  10. #define aerosftolv 551 // ID DIALOG
  11. #define aerosftols 552 // ID DIALOG
  12. #define COR_VERDE 0x33AA33AA // cor
  13. #define COR_LARANJA 0xFF9933AA // cor
  14. #define COLOR_RED 0xAA3333AA // cor
  15. #define COR_AMARELO 0xFFFF00AA // cor
  16.  
  17. #define passagemlv 500 //preço da passagem para las aventura
  18. #define passagemsf 600 //preço da passagem para sf
  19. #define passagemls 350 //preço passagem para los santos
  20. #define tempo123 20 //tempo da viagem em segundos
  21.  
  22.  
  23. new destino[MAX_PLAYERS];//variavel pra cetar o destino
  24. new tempoviagem[MAX_PLAYERS];//variavel pra definir o tempo
  25. new tempoviagem2[MAX_PLAYERS];//variavel pra definir o tempo
  26. new Text:tempoprachegada[MAX_PLAYERS];//textdraw do tempo
  27. new texto[200];//string
  28. new texto2[128]; //string
  29. forward viagem(playerid);//public
  30.  
  31. ////////////////////////////////////////////////////////////////////////////////
  32. public OnGameModeInit()
  33. {
  34. //Pickups aeroportos
  35. CreatePickup(1239, 1,1642.1678,-2334.5310,13.5469, 0);
  36. Create3DTextLabel("Aeroporto Los Santos\n Digite /menu", COR_VERDE,1642.1678,-2334.5310,13.5469, 40, 0, 0);
  37.  
  38. CreatePickup(1239, 1,1664.0167,1423.1956,10.7898, 0);
  39. Create3DTextLabel("Aeroporto Las Anvetura\n Digite /menu", COR_VERDE,1664.0167,1423.1956,10.7898, 40, 0, 0);
  40.  
  41. CreatePickup(1239, 1,-1421.6619,-287.8079,14.1484, 0);
  42. Create3DTextLabel("Aeroporto San Fierro\n Digite /menu", COR_VERDE,-1421.6619,-287.8079,14.1484, 40, 0, 0);
  43.  
  44. return 1;
  45. }
  46. ////////////////////////////////////////////////////////////////////////////////
  47. public OnPlayerConnect(playerid)
  48. {
  49. tempoprachegada[playerid] = TextDrawCreate(10.0,200.0," ");
  50. SetPlayerMapIcon(playerid, 22, 1663.1836,1423.4958, 10.7959, 5, 1);//Aeroporto Las aventura
  51. SetPlayerMapIcon(playerid, 23, 1642.2249,-2335.2783,13.5469, 5, 1);//Aeroporto Los santos
  52. SetPlayerMapIcon(playerid, 24, -1421.4926,-287.3825,14.1484, 5, 1);//Aeroporto San Fierro
  53. return 1;
  54. }
  55. ////////////////////////////////////////////////////////////////////////////////
  56. public OnPlayerCommandText(playerid, cmdtext[])
  57. {
  58.  
  59. if (strcmp("/menu", cmdtext, true, 10) == 0)
  60. {
  61.  
  62. if(IsPlayerInRangeOfPoint(playerid,3.0,1642.1678,-2334.5310,13.5469))//Aeropoto los santos
  63. {
  64. format(texto, sizeof(texto), "Las Aventura $%d \n San fierro $%d", passagemlv,passagemsf);
  65. ShowPlayerDialog(playerid, aerols, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  66. return 1;
  67. }
  68.  
  69. if(IsPlayerInRangeOfPoint(playerid,3.0,1664.0167,1423.1956,10.7898))//Aeroporto las aventura
  70. {
  71. format(texto, sizeof(texto), "Los Santos $%d \n San fierro $%d", passagemls,passagemsf);
  72. ShowPlayerDialog(playerid, aerolv, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  73. return 1;
  74. }
  75.  
  76. if(IsPlayerInRangeOfPoint(playerid,3.0,-1421.6619,-287.8079,14.1484))//Aeropoto san fierro
  77. {
  78. format(texto, sizeof(texto), "Los Santos $%d \nLas Aventura $%d",passagemls,passagemlv);
  79. ShowPlayerDialog(playerid, aerosf, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  80. return 1;
  81. }
  82.  
  83. return 1;
  84. }
  85.  
  86. return 0;
  87. }
  88. ////////////////////////////////////////////////////////////////////////////////
  89. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  90. {
  91. if(dialogid == aerosf)
  92. {
  93. if(response)// They pressed the first button.
  94. {
  95. switch(listitem)// Checking which listitem was selected
  96. {
  97. case 0:// The first item listed
  98. {
  99. format(texto, sizeof(texto), "Preço $%d",passagemls);
  100. ShowPlayerDialog(playerid, aerosftols, DIALOG_STYLE_MSGBOX, "Destino: Los Santos", texto, "Comfirmar", "Cancelar");
  101. }
  102. case 1: // The second item listed
  103. {
  104. format(texto, sizeof(texto), "Preço $%d",passagemlv);
  105. ShowPlayerDialog(playerid, aerosftolv, DIALOG_STYLE_MSGBOX, "Destino: Las Aventura", texto, "Comfirmar", "Cancelar");
  106. }
  107. }
  108. }
  109. }
  110. //------------------------------------------------------------------------------
  111. if(dialogid == aerosftols)
  112. {
  113. if(response)
  114. {
  115. if(GetPlayerMoney(playerid)>=passagemls)
  116. {
  117. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  118. destino[playerid] =1;
  119. GivePlayerMoney(playerid,passagemls);
  120. //função public viagem
  121. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  122. SetPlayerInterior(playerid,1);
  123. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  124. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  125. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  126. SendClientMessage(playerid, COR_VERDE,texto2);
  127. tempoviagem[playerid] = tempo123;
  128. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  129.  
  130. } else{
  131. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  132. format(texto, sizeof(texto), "Los Santos $%d \nLas Aventura $%d",passagemls,passagemlv);
  133. ShowPlayerDialog(playerid, aerosf, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  134. }
  135. }
  136. else
  137. {
  138. format(texto, sizeof(texto), "Los Santos $%d \nLas Aventura $%d",passagemls,passagemlv);
  139. ShowPlayerDialog(playerid, aerosf, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  140. }
  141. }
  142. //------------------------------------------------------------------------------
  143. if(dialogid == aerosftolv)
  144. {
  145. if(response)
  146. {
  147. if(GetPlayerMoney(playerid)>=passagemlv)
  148. {
  149. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  150. destino[playerid] =2;
  151. GivePlayerMoney(playerid,-passagemlv);
  152. //função public viagem
  153. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  154. SetPlayerInterior(playerid,1);
  155. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  156. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  157. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  158. SendClientMessage(playerid, COR_VERDE,texto2);
  159. tempoviagem[playerid] = tempo123;
  160. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  161. } else{
  162. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  163. format(texto, sizeof(texto), "Los Santos $%d \nLas Aventura $%d",passagemls,passagemlv);
  164. ShowPlayerDialog(playerid, aerosf, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  165. }
  166. }
  167. else
  168. {
  169. format(texto, sizeof(texto), "Los Santos $%d \nLas Aventura $%d",passagemls,passagemlv);
  170. ShowPlayerDialog(playerid, aerosf, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  171. }
  172. }
  173.  
  174. //==============================================================================
  175. if(dialogid == aerolv)
  176. {
  177. if(response)// They pressed the first button.
  178. {
  179. switch(listitem)// Checking which listitem was selected
  180. {
  181. case 0:// The first item listed
  182. {
  183. format(texto, sizeof(texto), "Preço: $%d",passagemls);
  184. ShowPlayerDialog(playerid, aerolvtols, DIALOG_STYLE_MSGBOX, "Destino: Los Santos", texto, "Comfirmar", "Cancelar");
  185. }
  186. case 1: // The second item listed
  187. {
  188. format(texto, sizeof(texto), "Preço: $%d",passagemsf);
  189. ShowPlayerDialog(playerid, aerolvtosf, DIALOG_STYLE_MSGBOX, "Destino: San Fierro", texto, "Comfirmar", "Cancelar");
  190. }
  191. }
  192. }
  193. }
  194. //------------------------------------------------------------------------------
  195. if(dialogid == aerolvtols)
  196. {
  197. if(response)
  198. {
  199. if(GetPlayerMoney(playerid)>=passagemls)
  200. {
  201. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  202. destino[playerid] =1;
  203. GivePlayerMoney(playerid,-passagemls);
  204. //função public viagem
  205. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  206. SetPlayerInterior(playerid,1);
  207. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  208. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  209. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  210. SendClientMessage(playerid, COR_VERDE,texto2);
  211. tempoviagem[playerid] = tempo123;
  212. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  213. } else{
  214. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  215. format(texto, sizeof(texto), "Los Santos $%d \n San fierro $%d", passagemls,passagemsf);
  216. ShowPlayerDialog(playerid, aerolv, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  217. }
  218. }
  219. else
  220. {
  221. format(texto, sizeof(texto), "Los Santos $%d \n San fierro $%d", passagemls,passagemsf);
  222. ShowPlayerDialog(playerid, aerolv, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  223. }
  224. }
  225. //------------------------------------------------------------------------------
  226. if(dialogid == aerolvtosf)
  227. {
  228. if(response)
  229. {
  230. if(GetPlayerMoney(playerid)>=passagemsf)
  231. {
  232. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  233. destino[playerid] =3;
  234. GivePlayerMoney(playerid,-passagemsf);
  235. //função public viagem
  236. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  237. SetPlayerInterior(playerid,1);
  238. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  239. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  240. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  241. SendClientMessage(playerid, COR_VERDE,texto2);
  242. tempoviagem[playerid] = tempo123;
  243. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  244. } else{
  245. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  246. format(texto, sizeof(texto), "Los Santos $%d \n San fierro $%d", passagemls,passagemsf);
  247. ShowPlayerDialog(playerid, aerolv, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  248. }
  249. }
  250. else
  251. {
  252. format(texto, sizeof(texto), "Los Santos $%d \n San fierro $%d", passagemls,passagemsf);
  253. ShowPlayerDialog(playerid, aerolv, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  254. }
  255. }
  256.  
  257. //==============================================================================
  258. if(dialogid == aerols)
  259. {
  260. if(response)// They pressed the first button.
  261. {
  262. switch(listitem)// Checking which listitem was selected
  263. {
  264. case 0:// The first item listed
  265. {
  266. format(texto, sizeof(texto), "Preço $%d",passagemlv);
  267. ShowPlayerDialog(playerid, aerolstolv, DIALOG_STYLE_MSGBOX, "Destino: Las Aventura", texto, "Comfirmar", "Cancelar");
  268. }
  269. case 1: // The second item listed
  270. {
  271. format(texto, sizeof(texto), "Preço $%d",passagemsf);
  272. ShowPlayerDialog(playerid, aerolstosf, DIALOG_STYLE_MSGBOX, "Destino: San Fierro", texto, "Comfirmar", "Cancelar");
  273. }
  274. }
  275. }
  276. }
  277. //------------------------------------------------------------------------------
  278. if(dialogid == aerolstolv)
  279. {
  280. if(response)
  281. {
  282. if(GetPlayerMoney(playerid)>=passagemlv)
  283. {
  284. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  285. destino[playerid] =2;
  286. GivePlayerMoney(playerid,-passagemlv);
  287. //função public viagem
  288. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  289. SetPlayerInterior(playerid,1);
  290. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  291. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  292. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  293. SendClientMessage(playerid, COR_VERDE,texto2);
  294. tempoviagem[playerid] = tempo123;
  295. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  296. } else{
  297. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  298. format(texto, sizeof(texto), "Las Aventura $%d \n San fierro $%d", passagemlv,passagemsf);
  299. ShowPlayerDialog(playerid, aerols, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  300. }
  301. }
  302. else
  303. {
  304. format(texto, sizeof(texto), "Las Aventura $%d \n San fierro $%d", passagemlv,passagemsf);
  305. ShowPlayerDialog(playerid, aerols, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  306. }
  307. }
  308. //------------------------------------------------------------------------------
  309. if(dialogid == aerolstosf)
  310. {
  311. if(response)
  312. {
  313. if(GetPlayerMoney(playerid)>=passagemsf)
  314. {
  315. SendClientMessage(playerid, COR_LARANJA,"Passagem comprada com sucesso.Boa Viagem!");
  316. destino[playerid] =3;
  317. GivePlayerMoney(playerid,-passagemsf);
  318. //função public viagem
  319. SetPlayerPos(playerid,1.808619,32.384357,1199.593750);
  320. SetPlayerInterior(playerid,1);
  321. GameTextForPlayer(playerid, "~b~Viagem", 3000, 1);
  322. SendClientMessage(playerid,COR_AMARELO,"=======================================================");
  323. format(texto2, sizeof(texto2), "Voce acabou de embarcar. Voce cherara em %d segundos. ",tempo123);
  324. SendClientMessage(playerid, COR_VERDE,texto2);
  325. tempoviagem[playerid] = tempo123;
  326. tempoviagem2[playerid] = SetTimerEx("viagem", 1000, true, "i", playerid);
  327. } else{
  328. SendClientMessage(playerid, COLOR_RED,"Voce nao tem dinheiro suficiente.");
  329. format(texto, sizeof(texto), "Las Aventura $%d \n San fierro $%d", passagemlv,passagemsf);
  330. ShowPlayerDialog(playerid, aerols, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  331. }
  332. }
  333. else
  334. {
  335. format(texto, sizeof(texto), "Las Aventura $%d \n San fierro $%d", passagemlv,passagemsf);
  336. ShowPlayerDialog(playerid, aerols, DIALOG_STYLE_LIST, "Escolha seu destino:",texto,"Comprar", "Cancelar");
  337. }
  338. }
  339.  
  340. return 1;
  341. }
  342. ////////////////////////////////////////////////////////////////////////////////
  343. public viagem(playerid)
  344. {
  345. tempoviagem[playerid] --;
  346. new tipico[40];
  347. format(tipico, sizeof(tipico), "Chegada: %d segundos", tempoviagem[playerid]);
  348. TextDrawSetString(tempoprachegada[playerid], tipico);
  349. TextDrawShowForPlayer(playerid, tempoprachegada[playerid]);
  350.  
  351. if(tempoviagem[playerid] == 0)
  352. {
  353. KillTimer(tempoviagem2[playerid]);
  354. SendClientMessage(playerid, 0xFFFFFFAA, "Sua viagem acabou!");
  355. TextDrawHideForPlayer(playerid, tempoprachegada[playerid]);
  356.  
  357. if(destino[playerid] ==1 )//los santos
  358. {
  359. SetPlayerPos(playerid,1640.2815,-2331.0742,13.5469);
  360. SetPlayerInterior(playerid,0);
  361. GameTextForPlayer(playerid, "~b~Los Santos", 3000, 1);
  362. }
  363.  
  364. if(destino[playerid] ==2) //las aventura
  365. {
  366. SetPlayerPos(playerid,1669.4399,1423.8954,10.7817);
  367. SetPlayerInterior(playerid,0);
  368. GameTextForPlayer(playerid, "~b~Las Aventura", 3000, 1);
  369. }
  370.  
  371. if(destino[playerid] ==3)//san fierro
  372. {
  373. SetPlayerPos(playerid,-1424.2064,-289.9511,14.1484);
  374. SetPlayerInterior(playerid,0);
  375. GameTextForPlayer(playerid, "~b~San Fierro", 3000, 1);
  376. }
  377. }
  378.  
  379. return 1;
  380. }
  381.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement