Advertisement
BrinqueDo

Sistema de Moeda Verdes

Oct 15th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.43 KB | None | 0 0
  1. /* Sistema de Moedas Verdes v1.0 - by BrinqueDo
  2.     Primeira versão do sistema de moeda secundária (Moedas Verdes)
  3.     - Salvamento de moedas para cada usuario em DOF2.
  4.     - Primeiro comando de compra com mv's criados para seguirem o exemplo.
  5.     - Comandos Admin: /darmoedasv - /darmoedasvtodos - /setarmoedasv - /setarmoedasvtodos - /resetarmoedasv logado em rcon
  6.     - Sisteminha simples adicionado na compra para verificar se o usuario tem ou não mv's suficientes para efetuar a compra
  7.     e pode ser usado como exemplo para a criação dos outros comandos.
  8.  
  9.     Créditos: A idéia de moeda secundária n faço a minima ideia de quem inventou, só atendi a pedidos e criei esse sisteminha mais completo.
  10.     O nome Moedas Verdes foi criado pelo BPF.
  11.     O code aqui contido foi criado do zero inteiramente por mim. Eu autorizo a cópia e alteração dos codes porém com os devidos créditos originais.
  12.    
  13.     Obs. é necessario ter o plugin sscanf.inc dentro da pasta plugins no diretorio do seu servidor, e adicione tambem a linha "plugins sscanf" ao seu server.cfg
  14.     Obs2. é necessario ter a pasta moedas criada dentro da pasta scriptfiles do diretorio do seu servirdor. (SEUSERVIDOR/scriptfiles/moedas) caso contrario n ira funcionar
  15.     */
  16.  
  17. #include <a_samp>
  18. #include <DOF2>
  19. #include <zcmd>
  20. #include <sscanf2>
  21.  
  22. //Defines
  23. #define amarelo 0xFFFF00FF
  24. #define azul 0x058AFFFF
  25. #define rosa 0xFF05CDFF
  26. #define verde 0x33AA33AA
  27. #define vermelho 0xFFFFFFAA
  28. #define branco 0xFFFFFFFF
  29. #define preto 0x000000FF
  30. #define cinza 0x878787FF
  31. #define azulclaro 0x03F2FFFF
  32. #define verdeclaro 0x03FF35FF
  33. #define roxo 0x7D03FFFF
  34. #define roxoclaro 0x9A03FFFF
  35. #define laranja 0xFF7403FF
  36.  
  37. //enum's
  38. enum info
  39. {
  40.     moedas,
  41. }
  42. // News
  43. new PlayerInfo[MAX_PLAYERS][info];
  44. new MoedasV[MAX_PLAYERS];
  45. new ID;
  46. new PONTOS;
  47. new Text:Moedas;
  48.  
  49. // Forwards
  50. forward Dinheiro(playerid);
  51.  
  52. //Publics
  53. public OnFilterScriptInit()
  54. {
  55.     print("\n--------------------------------------");
  56.     print("Sistema de Moedas Verdes - by BrinqueDo");
  57.     print("--------------------------------------\n");
  58.     SetTimer("Dinheiro",1000, 1); // Fica atualizando o numero de moedas
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerConnect(playerid)
  63. {
  64.    
  65.     new nome[MAX_PLAYER_NAME];
  66.     new arquivo[40];
  67.     GetPlayerName(playerid, nome, 32);
  68.     format(arquivo,sizeof arquivo,"/moedas/%s.txt",GetName(playerid));
  69.     if(DOF2_FileExists(arquivo))
  70.     {
  71.         CarregarConta(playerid);
  72.     }
  73.     else
  74.     {
  75.         CriarConta(playerid);
  76.     }
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.     TextDrawShowForPlayer(playerid, Moedas);
  83. }
  84.  
  85. public Dinheiro(playerid)
  86. {
  87.     TextDrawDestroy(Moedas);
  88.     new str[128];
  89.     format(str, 256, "~g~MV~r~:~w~%d", PlayerInfo[playerid][moedas]);
  90.     Moedas = TextDrawCreate(496.000000, 122.000000,str);
  91.     TextDrawBackgroundColor(Moedas, 255);
  92.     TextDrawFont(Moedas, 2);
  93.     TextDrawLetterSize(Moedas, 0.509999, 2.100000);
  94.     TextDrawColor(Moedas, -1);
  95.     TextDrawSetOutline(Moedas, 1);
  96.     TextDrawSetProportional(Moedas, 0);
  97.  
  98.     for(new i; i < MAX_PLAYERS; i ++)
  99.     {
  100.         if(IsPlayerConnected(i))
  101.         {
  102.             TextDrawHideForPlayer(i, Moedas);
  103.             TextDrawShowForPlayer(i, Moedas);
  104.         }
  105.     }
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerRequestClass(playerid, classid)
  110. {
  111.     SpawnPlayer(playerid); // E depois disso, ele 'Spawnará'
  112.     return 1;
  113. }
  114.  
  115. public OnPlayerDisconnect(playerid, reason)
  116. {
  117.     SalvarConta(playerid);
  118.     return 1;
  119. }
  120.  
  121. public OnFilterScriptExit()
  122. {
  123.     TextDrawHideForAll(Moedas);
  124.     TextDrawDestroy(Moedas);
  125.     DOF2_Exit();
  126.     return 1;
  127. }
  128.  
  129.  
  130. CMD:moedasv(playerid)
  131. {
  132.     SendClientMessage(playerid, azul, "Comandos Admin: /darmoedasv - /darmoedasvtodos - /setarmoedasv - /setarmoedasvtodos - /resetarmoedasv");
  133.     SendClientMessage(playerid, azul, "Comandos Player: /comprardinheiro");
  134.     return 1;
  135. }
  136.  
  137. // Comandos Admin
  138.  
  139. CMD:darmoedasv(playerid,params[])
  140. {
  141.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cinza, "Você não é administrador !");
  142.     if(sscanf(params, "ud", ID, PONTOS)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /darmoedasv [ID][QUANTIDADE]");
  143.     if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, vermelho, "[ERRO] ID invalido");
  144.     PlayerInfo[ID][moedas] = PlayerInfo[ID][moedas] + PONTOS;
  145.     return 1;
  146. }
  147.  
  148. CMD:darmoedasvtodos(playerid,params[])
  149. {
  150.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cinza, "Você não é administrador !");
  151.     if(sscanf(params, "d", PONTOS)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /darmoedasvtodos [QUANTIDADE]");
  152.     for(new i = 0; i < MAX_PLAYERS; i++)
  153.     {
  154.         if(IsPlayerConnected(i))
  155.         {
  156.             PlayerInfo[i][moedas] = PlayerInfo[i][moedas] + PONTOS;
  157.         }
  158.     }
  159.    
  160.     return 1;
  161. }
  162.  
  163. CMD:setarmoedasvtodos(playerid,params[])
  164. {
  165.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cinza, "Você não é administrador !");
  166.     if(sscanf(params, "d", PONTOS)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /setarmoedasvtodos [QUANTIDADE]");
  167.     for(new i = 0; i < MAX_PLAYERS; i++)
  168.     {
  169.         if(IsPlayerConnected(i))
  170.         {
  171.             PlayerInfo[i][moedas] = PONTOS;
  172.         }
  173.     }
  174.  
  175.     return 1;
  176. }
  177.  
  178. CMD:setarmoedasv(playerid,params[])
  179. {
  180.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cinza, "Você não é administrador !");
  181.     if(sscanf(params, "ud", ID, PONTOS)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /setarmoedasv [ID][QUANTIDADE]");
  182.     if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, vermelho, "[ERRO] ID invalido");
  183.     PlayerInfo[ID][moedas] = PONTOS;
  184.     return 1;
  185. }
  186.  
  187. CMD:resetarmoedasv(playerid,params[])
  188. {
  189.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cinza, "Você não é administrador !");
  190.     if(sscanf(params, "u", ID)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /resetarmoedasv [ID]");
  191.     if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, vermelho, "[ERRO] ID invalido");
  192.     PlayerInfo[ID][moedas] = 0;
  193.     return 1;
  194. }
  195.  
  196. // Comandos Player
  197.  
  198. CMD:comprardinheiro(playerid,params[])
  199. {
  200.     new qtd;
  201.     if(sscanf(params, "d", qtd)) return SendClientMessage(playerid, vermelho, "[MOEDAS] Use /comprardinheiro [QUANTIDADE] - 10000 Reais = 10 MV");
  202.     if(qtd < 10000 || qtd > 500000) return SendClientMessage(playerid, vermelho,"Valor mínimo: 10000 Reais - Valor Máximo: 500000 Reais");
  203.     if(qtd/1000 >= PlayerInfo[playerid][moedas]) return SendClientMessage(playerid, vermelho,"Você não tem Moedas Verdes suficientes.");
  204.     PlayerInfo[playerid][moedas] = PlayerInfo[playerid][moedas] - qtd/1000;
  205.     GivePlayerMoney(playerid, qtd);
  206.     return 1;
  207. }
  208.  
  209.  
  210. // Stocks
  211.  
  212. stock GetName(playerid)
  213. {
  214.     new name[24];
  215.     GetPlayerName(playerid,name,24);
  216.     return name;
  217. }
  218.  
  219. stock CriarConta(playerid)
  220. {
  221.     new arquivo[36];
  222.     format(arquivo,sizeof arquivo,"/moedas/%s.txt",GetName(playerid));
  223.     DOF2_CreateFile(arquivo);
  224.     DOF2_SetInt(arquivo, "moedas", 0);
  225.     DOF2_SaveFile();
  226. }
  227.  
  228. stock CarregarConta(playerid)
  229. {
  230.     new arquivo[36];
  231.     format(arquivo,sizeof arquivo,"/moedas/%s.txt",GetName(playerid));
  232.     PlayerInfo[playerid][moedas] = 0;
  233.     PlayerInfo[playerid][moedas] = DOF2_GetInt(arquivo, "moedas");
  234.    
  235.  
  236. }
  237.  
  238. stock SalvarConta(playerid)
  239. {
  240.     new arquivo[36];
  241.     format(arquivo,sizeof arquivo,"/moedas/%s.txt",GetName(playerid));
  242.     DOF2_SetInt(arquivo, "moedas", PlayerInfo[playerid][moedas]);
  243.     DOF2_SaveFile();
  244. }
  245.  
  246. stock GetPlayerMoedasV(playerid)
  247. {
  248.     return MoedasV[playerid];
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement