Guest User

mCoins 3.0 System

a guest
Dec 15th, 2017
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.68 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <zcmd>
  4. #include DOF2
  5. #include sscanf
  6. //Dialogs & Defines
  7. #define tr1 222
  8. #define tr2 223
  9. #define REGISTRO 1
  10. #define LOGIN 2
  11. #define CONTAS "Players/%s.ini"
  12. #define function
  13. //Variaveis
  14. new mCoins[MAX_PLAYERS],EditGive[MAX_PLAYERS],Logou[MAX_PLAYERS],EscolhaV[MAX_PLAYERS],MEGAString[3200],attcoins[MAX_PLAYERS],stringglobal[70];
  15. new PlayerText:Textdraw0[MAX_PLAYERS];
  16. #if defined FILTERSCRIPT
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. return 1;
  21. }
  22. public OnFilterScriptExit()
  23. {
  24. return 1;
  25. }
  26.  
  27. #else
  28.  
  29. main()
  30. {
  31. }
  32.  
  33. #endif
  34. public OnPlayerRequestClass(playerid, classid)
  35. {
  36. new Nome[MAX_PLAYER_NAME];
  37. GetPlayerName(playerid, Nome, sizeof(Nome));
  38. new String[100];
  39. format(String, sizeof(String), CONTAS, Nome);
  40. if(!DOF2_FileExists(String))
  41. {
  42. format(String, sizeof(String), "{FF6347}Olá %s {9C9C9C}Você Ainda Não Tem Uma Conta, Digite Uma Senha Para Continuar", Nome);
  43. ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_PASSWORD, "Registro", String, "Registrar", "Cancelar");
  44. }
  45. else
  46. {
  47. format(String, sizeof(String), "{FF6347}Olá %s {9C9C9C}Você Já Tem Uma Conta, Digite Sua Senha Para Logar-Se", Nome);
  48. ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", String, "Logar", "Cancelar");
  49. }
  50. return 1;
  51. }
  52.  
  53. public OnPlayerConnect(playerid)
  54. {
  55. CarregarPlayer(playerid);
  56. Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 60.000000, 327.039978, "Coins ~r~ 0");
  57. PlayerTextDrawLetterSize(playerid, Textdraw0[playerid], 0.423599, 1.308799);
  58. PlayerTextDrawAlignment(playerid, Textdraw0[playerid], 1);
  59. PlayerTextDrawColor(playerid, Textdraw0[playerid], -1);
  60. PlayerTextDrawSetShadow(playerid, Textdraw0[playerid], 0);
  61. PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 1);
  62. PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], 51);
  63. PlayerTextDrawFont(playerid, Textdraw0[playerid], 1);
  64. PlayerTextDrawSetProportional(playerid, Textdraw0[playerid], 1);
  65. return 1;
  66. }
  67.  
  68. public OnPlayerDisconnect(playerid, reason)
  69. {
  70. SalvarPlayer(playerid);
  71. return 1;
  72. }
  73.  
  74. public OnPlayerSpawn(playerid)
  75. {
  76. SendClientMessage(playerid, -1, "{00FFFF} » {FFFFFF}Sistema Criado por Media_Wallker");
  77. SendClientMessage(playerid, -1, "{00FFFF} » {FFFFFF}Para ver os Comandos use /ajuda");
  78. PlayerTextDrawShow(playerid, Textdraw0[playerid]);
  79. return 1;
  80. }
  81. forward atualizartxd(playerid);
  82. public atualizartxd(playerid)
  83. {
  84. format(stringglobal,sizeof(stringglobal),"Coins ~b~%d",mCoins[playerid]);
  85. PlayerTextDrawSetString(playerid, Textdraw0[playerid], stringglobal);
  86. return 1;
  87. }
  88.  
  89. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  90. {
  91. if(dialogid == REGISTRO)
  92. {
  93. if(response)
  94. {
  95. if(!strlen(inputtext))
  96. {
  97. new Nome[MAX_PLAYER_NAME];
  98. GetPlayerName(playerid, Nome, sizeof(Nome));
  99. new String[100];
  100. format(String, sizeof(String), "{FF6347}Olá %s {9C9C9C}Você Ainda Não Tem Uma Conta, Digite Uma Senha Para Continuar", Nome);
  101. ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_PASSWORD, "{FF6347}Registro", String, "Registrar", "Cancelar");
  102. SendClientMessage(playerid,0x1E90FFAA,"{9C9C9C}Senha invalida, digite uma senha válida");
  103. return 1;
  104. }
  105. new Nome[MAX_PLAYER_NAME];
  106. GetPlayerName(playerid, Nome, sizeof(Nome));
  107. new String[100];
  108. format(String, sizeof(String), CONTAS, Nome);
  109. DOF2_CreateFile(String);
  110. DOF2_SetString(String,"Senha",inputtext);
  111. DOF2_SetInt(String,"Dinheiro",0);
  112. DOF2_SetInt(String,"Vida", 100);
  113. DOF2_SetInt(String,"Colete", 100);
  114. DOF2_SetInt(String,"Logou",0);
  115. DOF2_SetInt(String,"Coising",0);
  116. ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{FF6347}Login", "{9C9C9C}Pronto você se registrou agora digite Sua Senha Para Logar-Se", "Logar", "Cancelar");
  117. return 1;
  118. }
  119. else
  120. {
  121. SendClientMessage(playerid, 0xFF0000AA, "{9C9C9C}Você não quis se registrar, por este motivo sera Kickado");
  122. Kick(playerid);
  123. return 1;
  124. }
  125. }
  126. if(dialogid == LOGIN)
  127. {
  128. if(response)
  129. {
  130. if(!strlen(inputtext))
  131. {
  132. new Nome[MAX_PLAYER_NAME];
  133. GetPlayerName(playerid, Nome, sizeof(Nome));
  134. new String[100];
  135. format(String, sizeof(String), "{FF6347}Olá %s {9C9C9C}Você Já Tem Uma Conta, Digite Sua Senha Para Logar-Se", Nome);
  136. ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", String, "Logar", "Cancelar");
  137. SendClientMessage(playerid,0x1E90FFAA,"OBS:Senha incorreta tente novamente");
  138. return 1;
  139. }
  140. new Nome[MAX_PLAYER_NAME];
  141. GetPlayerName(playerid, Nome, sizeof(Nome));
  142. new String[100];
  143. format(String, sizeof(String), CONTAS, Nome);
  144. if(!strcmp(inputtext,DOF2_GetString(String,"Senha"),false))
  145. {
  146. CarregarPlayer(playerid);
  147. Logou[playerid]++;
  148. SendClientMessage(playerid,0x00FF00AA,"Conectado com Sucesso");
  149. SpawnPlayer(playerid);
  150. return 1;
  151. }
  152. else
  153. {
  154. SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente");
  155. format(String, sizeof(String), "Olá %s você já tem uma conta, digite sua senha para logar-se", Nome);
  156. ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", String, "Logar", "Cancelar");
  157. }
  158. return 1;
  159. }
  160. else
  161. {
  162. SendClientMessage(playerid, 0xFF0000AA, "Você não quis se logar, por este motivo será Kickado");
  163. Kick(playerid);
  164. return 1;
  165. }
  166. }
  167. if(dialogid == 2316)
  168. {
  169. if(response)
  170. {
  171. new Float:pp;
  172. new Float:ppp;
  173. new Float:pppp;
  174. new Float:ppppp;
  175. if(listitem == 0)
  176. {
  177. if(mCoins[playerid] < 1000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  178. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma Sanchez por 1.000 Coins");
  179. GetPlayerPos(playerid, pp,ppp,pppp);
  180. GetPlayerFacingAngle(playerid, ppppp);
  181. CreateVehicle(468, pp,ppp,pppp,ppppp, -1, -1, -1);
  182. mCoins[playerid] -= 1000;
  183. }
  184. if(listitem == 1)
  185. {
  186. if(mCoins[playerid] < 5000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  187. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma NRG-500 por 5000 Coins");
  188. GetPlayerPos(playerid, pp,ppp,pppp);
  189. GetPlayerFacingAngle(playerid, ppppp);
  190. CreateVehicle(522, pp,ppp,pppp,ppppp, -1, -1, -1);
  191. mCoins[playerid] -= 5000;
  192. }
  193. if(listitem == 2)
  194. {
  195. if(mCoins[playerid] < 5000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  196. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou um Buffalo por 5000 Coins");
  197. GetPlayerPos(playerid, pp,ppp,pppp);
  198. GetPlayerFacingAngle(playerid, ppppp);
  199. CreateVehicle(402, pp,ppp,pppp,ppppp, -1, -1, -1);
  200. mCoins[playerid] -= 5000;
  201. }
  202. if(listitem == 3)
  203. {
  204. if(mCoins[playerid] < 10000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  205. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou um Super-GT por 10000 Coins");
  206. GetPlayerPos(playerid, pp,ppp,pppp);
  207. GetPlayerFacingAngle(playerid, ppppp);
  208. CreateVehicle(506, pp,ppp,pppp,ppppp, -1, -1, -1);
  209. mCoins[playerid] -= 10000;
  210. }
  211. if(listitem == 4)
  212. {
  213. if(mCoins[playerid] < 9000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  214. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou um Turismo por 9000 Coins");
  215. GetPlayerPos(playerid, pp,ppp,pppp);
  216. GetPlayerFacingAngle(playerid, ppppp);
  217. CreateVehicle(451, pp,ppp,pppp,ppppp, -1, -1, -1);
  218. mCoins[playerid] -= 9000;
  219. }
  220. if(listitem == 5)
  221. {
  222. if(mCoins[playerid] < 15000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  223. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou um Jetpack por 15000 Coins");
  224. SetPlayerSpecialAction(playerid, 2);
  225. mCoins[playerid] -= 15000;
  226. }
  227. }
  228. }
  229. if(dialogid == 2318)
  230. {
  231. if(response)
  232. {
  233. if(listitem == 0)
  234. {
  235. ShowPlayerDialog(playerid, 2316, 5, "Comprar Veiculos",
  236. "Veiculo\tPreço(Coins)\n\
  237. Sanchez\t{33AA33}€{FFFFFF}1.000 Coins\n\
  238. NRG-500\t{33AA33}€{FFFFFF}5.000 Coins\n\
  239. Buffalo\t{33AA33}€{FFFFFF}5.000 Coins\n\
  240. Super-GT\t{33AA33}€{FFFFFF}10.000 Coins\n\
  241. Turismo\t{33AA33}€{FFFFFF}9.000 Coins\n\
  242. Jetpack\t{33AA33}€{FFFFFF}15.000 Coins", "Selecionar", "Sair");
  243. }
  244. if(listitem == 1)
  245. {
  246. ShowPlayerDialog(playerid, 2317, 5, "Comprar Armas",
  247. "Arma\tBalas\tPreço(Coins)\n\
  248. Deagle\t150\t{33AA33}€{FFFFFF}1.000 Coins\n\
  249. ShotGun\t160\t{33AA33}€{FFFFFF}2.000 Coins\n\
  250. MP5\t300\t{33AA33}€{FFFFFF}3.000 Coins\n\
  251. Ak-47\t450\t{33AA33}€{FFFFFF}4.000 Coins\n\
  252. Soco Ingês\t{FF0000}N/A\t{33AA33}€{FFFFFF}2.000 Coins", "Selecionar", "Sair");
  253. }
  254. if(listitem == 2)
  255. {
  256. ShowPlayerDialog(playerid, tr1, DIALOG_STYLE_INPUT, "[x] Transferencia", "» Digite abaixo o ID Do Player que você deseja transferir os coins", "Confirmar", "Cancelar");
  257. return 1;
  258. }
  259. }
  260. return 1;
  261. }
  262. if(dialogid == tr1)
  263. {
  264. if(response)
  265. {
  266. new ele = strval(inputtext);
  267. EditGive[playerid] = ele;
  268. if(IsPlayerConnected(ele))
  269. {
  270. if(ele != INVALID_PLAYER_ID)
  271. {
  272. ShowPlayerDialog(playerid, tr2, DIALOG_STYLE_INPUT,"[x] Transferencia","» Digite abaixo o Valor que você deseja transferir","Confirmar","Cancelar");
  273. }
  274. }
  275. else
  276. {
  277. SendClientMessage(playerid, -1, "ERRO:Jogador Offline");
  278. ShowPlayerDialog(playerid, tr1, DIALOG_STYLE_INPUT, "[x] Transferencia", "» Digite abaixo o ID Do Player que você deseja transferir os coins", "Confirmar", "Cancelar");
  279. }
  280. }
  281. return 1;
  282. }
  283. if(dialogid == tr2)
  284. {
  285. if(response)
  286. {
  287. new quantidade = strval(inputtext);
  288. new entregar = EditGive[playerid];
  289. if(quantidade > mCoins[playerid])
  290. {
  291. SendClientMessage(playerid, -1, "Você não tem coins suficiente para está Transferência ! ");
  292. EscolhaV[playerid] = 0;
  293. return 1;
  294. }
  295. if(quantidade <= 0)
  296. {
  297. EscolhaV[playerid] = 0;
  298. return 1;
  299. }
  300. MEGAString[0] = EOS;
  301. new string[256];
  302. TakeCoins(playerid,quantidade);
  303. GiveCoins(entregar,quantidade);
  304. format(string, sizeof string, "(-- Você Recebeu uma transferência no total de %d Coins do Jogador [ID:%d]%s--)", quantidade,playerid,PlayerName(playerid));
  305. SendClientMessage(entregar, -1, string);
  306. SendClientMessage(entregar, -1, "(----OBS:Tire uma ScreenShot Apertando a Tecla F8 Se For Preciso Provar Algo----)");
  307. format(string, sizeof string, "(-- Você Transferiu %d Coins para o Jogador [ID:%d]%s!--)", quantidade,entregar,PlayerName(entregar));
  308. SendClientMessage(playerid, -1, string);
  309. SendClientMessage(playerid, -1, "(----OBS:Tire uma ScreenShot Apertando a Tecla F8 Se For Preciso Provar Algo----)");
  310. format(string, sizeof(string), "(-- O Jogador %s Transferiu %d Coins para o Jogador %s.--)",PlayerName(playerid),quantidade,PlayerName(entregar));
  311. EditGive[playerid] = 0;
  312. }
  313. return 1;
  314. }
  315. if(dialogid == 2317)
  316. {
  317. if(response)
  318. {
  319. if(listitem == 0)
  320. {
  321. if(mCoins[playerid] < 1000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  322. GivePlayerWeapon(playerid, 24, 150);
  323. mCoins[playerid] -= 1000;
  324. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma Deagle com 150 Balas");
  325. }
  326. if(listitem == 1)
  327. {
  328. if(mCoins[playerid] < 2000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  329. GivePlayerWeapon(playerid, 25, 160);
  330. mCoins[playerid] -= 2000;
  331. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma ShotGun com 160 Balas");
  332. }
  333. if(listitem == 2)
  334. {
  335. if(mCoins[playerid] < 3000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  336. GivePlayerWeapon(playerid, 29, 300);
  337. mCoins[playerid] -= 3000;
  338. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma MP5 com 300 Balas");
  339. }
  340. if(listitem == 3)
  341. {
  342. if(mCoins[playerid] < 4000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  343. GivePlayerWeapon(playerid, 30, 450);
  344. mCoins[playerid] -= 4000;
  345. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou uma AK47 com 450 Balas");
  346. }
  347. if(listitem == 4)
  348. {
  349. if(mCoins[playerid] < 2000) return SendClientMessage(playerid, -1, "Você não possui coins o suficiente");
  350. GivePlayerWeapon(playerid, 1, 1);
  351. mCoins[playerid] -= 2000;
  352. SendClientMessage(playerid, -1, "{FF6347}Comprado:{9C9C9C}Você comprou um Soco Inglês");
  353. }
  354. }
  355. }
  356. return 1;
  357. }
  358.  
  359. function GiveCoins(playerid,valor)
  360. {
  361. new antes = mCoins[playerid];
  362. mCoins[playerid] = antes+valor;
  363. return true;
  364. }
  365. function TakeCoins(playerid,valor)
  366. {
  367. new antes = mCoins[playerid];
  368. mCoins[playerid] = antes-valor;
  369. return true;
  370. }
  371. CMD:darcoins(playerid, params[])
  372. {
  373. new para1, level, giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
  374. if(sscanf(params, "ud", para1, level))
  375. {
  376. SendClientMessage(playerid, -1, "{FF6347}USE:{9C9C9C} /darcoins [id] [quantia]");
  377. return 1;
  378. }
  379. GetPlayerName(para1, giveplayer, sizeof(giveplayer));
  380. GetPlayerName(playerid, sendername, sizeof(sendername));
  381. if(IsPlayerConnected(para1))
  382. {
  383. if(IsPlayerAdmin(playerid))
  384. {
  385. if(para1 != INVALID_PLAYER_ID)
  386. {
  387. new string[128];
  388. format(string, sizeof string, "Você deu R$%d para %s", level, giveplayer);
  389. SendClientMessage(playerid, -1, string);
  390. format(string, sizeof string, "O Admin %s te deu R$%d", sendername, level);
  391. SendClientMessage(para1, -1, string);
  392. GiveCoins(para1, level);
  393. }
  394. }
  395. }
  396. return 1;
  397. }
  398. function CarregarPlayer(playerid){
  399.  
  400. new Arquivo[70];
  401. attcoins[playerid] = SetTimerEx("atualizartxd", 1000, true, "i", playerid);
  402. format(Arquivo, sizeof(Arquivo), CONTAS, PlayerName(playerid));
  403.  
  404. if(DOF2_FileExists(Arquivo))
  405. {
  406. for(new i = 0; i != MAX_PLAYERS; ++i){
  407.  
  408. mCoins[playerid] = DOF2_GetInt(Arquivo,"Coins");
  409. GivePlayerMoney(playerid, DOF2_GetInt(Arquivo,"Dinheiro"));
  410. SetPlayerHealth(playerid, DOF2_GetInt(Arquivo,"Vida"));
  411. SetPlayerArmour(playerid, DOF2_GetInt(Arquivo,"Colete"));
  412. Logou[playerid] = DOF2_GetInt(Arquivo, "Logou");
  413. }
  414. }
  415. return 1;
  416. }
  417. function SalvarPlayer(playerid){
  418.  
  419. new Arquivo[70];
  420. new Float:Vida;
  421. new Float:Colete;
  422. GetPlayerHealth(playerid, Vida);
  423. GetPlayerArmour(playerid, Colete);
  424. format(Arquivo, sizeof(Arquivo), CONTAS, PlayerName(playerid));
  425. for(new i = 0; i != MAX_PLAYERS; i++)
  426. {
  427. DOF2_SetInt(Arquivo,"Coins",mCoins[playerid]);
  428. DOF2_SetFloat(Arquivo,"Vida", Vida);
  429. DOF2_SetFloat(Arquivo,"Colete", Colete);
  430. DOF2_SetInt(Arquivo,"Dinheiro", GetPlayerMoney(playerid));
  431. DOF2_SetInt(Arquivo,"Logou", Logou[playerid]);
  432. }
  433. DOF2_SaveFile();
  434. return 1;
  435. }
  436. function PlayerName(playerid)
  437. {
  438. new Name[MAX_PLAYER_NAME];
  439. GetPlayerName(playerid, Name, sizeof Name);
  440. return Name;
  441. }
  442. CMD:comprar(playerid)
  443. {
  444. new string[1024];
  445. format(string, sizeof string, "{00FFFF} » {FFFFFF}Comprar Veículos\n{00FFFF} » {FFFFFF}Comprar Armas\n{00FFFF} » {FFFFFF}Transferir Coins");
  446. ShowPlayerDialog(playerid, 2318, DIALOG_STYLE_LIST, "Menu Coins",string,"Selecionar", "Sair");
  447. return 1;
  448. }
  449. CMD:ajuda(playerid) return SendClientMessage(playerid, -1, "{00FFFF} » {FFFFFF}/comprar,/darcoins");
Advertisement
Add Comment
Please, Sign In to add comment