FStralioti1

[FS] - SISTEMA DE MOEDA SECUNDÁRIA

Apr 13th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.83 KB | Gaming | 0 0
  1. // Filterscript desenvolvido por Fábio Stralioti
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf>
  6. #include <dof2>
  7.  
  8. #define DIALOG_CASH   1
  9. #define DIALOG_MENU   2
  10. #define DIALOG_LOJA   3
  11. #define DIALOG_ARMAS  4
  12. #define DIALOG_CARROS 5
  13. #define DIALOG_TESTE  6
  14. #define COR_VERMELHO  0xFF0000FF
  15. #define MAX_ARMAS     5
  16. #define MAX_CARROS    4
  17.  
  18. enum pInfo
  19. {
  20.     Cash,
  21.     Arma,
  22.     Veiculo
  23. }
  24. new Player[MAX_PLAYERS][pInfo];
  25. new Float:X, Float:Y, Float:Z, Float: Angle;
  26. new Text:TextCash;
  27.  
  28. enum veiculos
  29. {
  30.     nomev[20],
  31.     idv,
  32.     valorv
  33. }
  34.  
  35. new veiculo[MAX_CARROS][veiculos] =
  36. {
  37.     {"Sultan", 560, 150},
  38.     {"Infernus", 411, 200},
  39.     {"NRG-500", 522, 250},
  40.     {"Super-GT", 506, 300}
  41. };
  42.  
  43. enum armas
  44. {
  45.     nomea[20],
  46.     ida,
  47.     muna,
  48.     valora
  49. }
  50. new arma[MAX_ARMAS][armas] =
  51. {
  52.     {"Shotgun", 25, 999, 25},
  53.     {"MP5", 29, 999, 50},
  54.     {"M4-A1", 31, 999, 100},
  55.     {"AK-47", 30, 999, 200},
  56.     {"Sniper", 34, 999, 300}
  57. };
  58.  
  59. #if defined FILTERSCRIPT
  60. #define FILTERSCRIPT
  61. #endif
  62.  
  63. public OnFilterScriptInit()
  64. {
  65.     print("Filterscript feito por: Fábio Stralioti");
  66.     print("Sistema de cash iniciado!");
  67.    
  68.     SetTimer("atualizacash", 1000, true);
  69.    
  70.     TextCash = TextDrawCreate(548.000000, 82.000000, "");
  71.     TextDrawBackgroundColor(TextCash, 255);
  72.     TextDrawFont(TextCash, 2);
  73.     TextDrawLetterSize(TextCash, 0.320000, 1.500000);
  74.     TextDrawColor(TextCash, -16776961);
  75.     TextDrawSetOutline(TextCash, 0);
  76.     TextDrawSetProportional(TextCash, 1);
  77.     TextDrawSetShadow(TextCash, 2);
  78.     TextDrawSetSelectable(TextCash, 0);
  79.     return 1;
  80. }
  81.  
  82. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  83. {
  84.     if(dialogid == DIALOG_MENU)
  85.     {
  86.         if(response)
  87.         {
  88.             if(listitem == 0)
  89.             {
  90.                
  91.             }
  92.             if(listitem == 1)
  93.             {
  94.                 ShowPlayerDialog(playerid, DIALOG_LOJA, DIALOG_STYLE_LIST, "LOJA", "Armas\nCarros", "Escolher", "Sair");
  95.             }
  96.             if(listitem == 2)
  97.             {
  98.            
  99.             }
  100.         }
  101.     }
  102.    
  103.     if(dialogid == DIALOG_LOJA)
  104.     {
  105.         if(response)
  106.         {
  107.             if(listitem == 0)
  108.             {
  109.                 new string[128];
  110.                 for(new i = 0; i < MAX_ARMAS; i ++)
  111.                 {
  112.                     format(string, sizeof(string),"%s%s {ff0000}%d\n", string, arma[i][nomea], arma[i][valora]);
  113.                 }
  114.                 ShowPlayerDialog(playerid, DIALOG_ARMAS, DIALOG_STYLE_LIST, "ARMAS", string, "Escolher", "Sair");
  115.             }
  116.             if(listitem == 1)
  117.             {
  118.                 new string[128];
  119.                 for(new i = 0; i < MAX_CARROS; i ++)
  120.                 {
  121.                     format(string, sizeof(string),"%s%s {ff0000}%d\n", string, veiculo[i][nomev], veiculo[i][valorv]);
  122.                 }
  123.                 ShowPlayerDialog(playerid, DIALOG_CARROS, DIALOG_STYLE_LIST, "CARROS", string, "Escolher", "Sair");
  124.             }
  125.         }
  126.     }
  127.    
  128.     if(dialogid == DIALOG_ARMAS)
  129.     {
  130.         if(response)
  131.         {
  132.             new each = -1;
  133.             for(new i = 0; i < MAX_ARMAS; i ++)
  134.             {
  135.                 each += 1;
  136.                 if(each == listitem)
  137.                 {
  138.                     if(Player[playerid][Cash] < arma[i][valora])
  139.                     {
  140.                         SendClientMessage(playerid, COR_VERMELHO,"Você não tem essa quantidade de cash");
  141.                         return 1;
  142.                     }
  143.                    
  144.                     new string[50];
  145.                     format(string, sizeof(string), "Você comprou uma %s", arma[i][nomea]);
  146.                     SendClientMessage(playerid, -1, string);
  147.                     Player[playerid][Arma] = GivePlayerWeapon(playerid, arma[i][ida], arma[i][muna]);
  148.                     Player[playerid][Cash] -= arma[i][valora];
  149.                 }
  150.             }
  151.         }
  152.     }
  153.    
  154.     if(dialogid == DIALOG_CARROS)
  155.     {
  156.         if(response)
  157.         {
  158.             new each = -1;
  159.             for(new i = 0; i < MAX_CARROS; i ++)
  160.             {
  161.                 each += 1;
  162.                 if(each == listitem)
  163.                 {
  164.                     if(Player[playerid][Cash] < veiculo[i][valorv])
  165.                     {
  166.                         SendClientMessage(playerid, COR_VERMELHO,"Você não tem essa quantidade de cash");
  167.                         return 1;
  168.                     }
  169.  
  170.                     new string[50];
  171.                     format(string, sizeof(string), "Você comprou um %s", veiculo[i][nomev]);
  172.                     SendClientMessage(playerid, -1, string);
  173.                    
  174.                     GetPlayerPos(playerid, X, Y, Z);
  175.                     GetPlayerFacingAngle(playerid, Angle);
  176.                     Player[playerid][Veiculo] = CreateVehicle(veiculo[i][idv], X+5, Y, Z+1, Angle, random(100), random(100), -1);
  177.                     Player[playerid][Cash] -= veiculo[i][valorv];
  178.                 }
  179.             }
  180.         }
  181.     }
  182.  
  183.     return 1;
  184. }
  185.  
  186. public OnPlayerConnect(playerid)
  187. {
  188.     new string[128];
  189.     format(string, sizeof(string), "Cash/%s.ini", PlayerNome(playerid));
  190.     if(!DOF2_FileExists(string)) DOF2_CreateFile(string);
  191.    
  192.     Carregar(playerid);
  193.    
  194.     SendClientMessage(playerid, -1,"Esse servidor utiliza o FilterScript de Cash");
  195.     SendClientMessage(playerid, -1,"Use /comandosfs e veja todos os comandos do FS");
  196.    
  197.     TextDrawShowForPlayer(playerid, TextCash);
  198.     return 1;
  199. }
  200.  
  201. public OnPlayerDisconnect(playerid, reason)
  202. {
  203.     TextDrawHideForPlayer(playerid, TextCash);
  204.     Salvar(playerid);
  205.     return 1;
  206. }
  207.  
  208. public OnFilterScriptExit()
  209. {
  210.     DOF2_Exit();
  211.     return 1;
  212. }
  213.  
  214. CMD:cash(playerid, params[])
  215. {
  216.     new string[120];
  217.     format(string, sizeof(string), "Cash disponível: {ff0000}%d\nLoja\nSair", Player[playerid][Cash]);
  218.     ShowPlayerDialog(playerid, DIALOG_MENU, DIALOG_STYLE_LIST, "LOJA DE CASH", string, "Escolher", "Sair");
  219.     return 1;
  220. }
  221.  
  222. CMD:setcash(playerid, params[])
  223. {
  224.     new id, qntd, string[50], string2[50];
  225.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERMELHO,"Você não é administador");
  226.     if(sscanf(params, "ud", id, qntd)) return SendClientMessage(playerid, COR_VERMELHO,"Use: /setcash [id] [qntd]");
  227.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COR_VERMELHO,"Jogador não conectado");
  228.     format(string, sizeof(string),"Você enviou %d de Cash para o %s", qntd, PlayerNome(id));
  229.     SendClientMessage(playerid, -1, string);
  230.     format(string2, sizeof(string2),"Você recebeu %d de Cash do Administrador %s", qntd, PlayerNome(playerid));
  231.     SendClientMessage(id, -1, string2);
  232.     Player[id][Cash] += qntd;
  233.     return 1;
  234. }
  235.  
  236. CMD:creditosfs(playerid)
  237. {
  238.     SendClientMessage(playerid, -1,"Criado por: Fábio Stralioti");
  239.     return 1;
  240. }
  241.  
  242. CMD:comandosfs(playerid)
  243. {
  244.     SendClientMessage(playerid, -1,"/cash, /setcash(administrador), /comandosfs, /creditosfs");
  245.     return 1;
  246. }
  247.  
  248. Salvar(playerid)
  249. {
  250.     new string[128];
  251.     format(string, sizeof(string), "Cash/%s.ini", PlayerNome(playerid));
  252.     if(DOF2_FileExists(string))
  253.     {
  254.         DOF2_SetInt(string,"Cash", Player[playerid][Cash]);
  255.         DOF2_SetInt(string,"Veiculo", veiculo[playerid][idv]);
  256.        
  257.         new armasv[13][2], each[50];
  258.         for (new i = 0; i <= 12; i++) {
  259.         GetPlayerWeaponData(playerid, i, armasv[i][0], armasv[i][1]);
  260.  
  261.         format(each, sizeof(each), "Arma%d", i);
  262.         DOF2_SetInt(string, each, armasv[i][0]);
  263.  
  264.         format(each, sizeof(each), "Municao%d", i);
  265.         DOF2_SetInt(string, each, armasv[i][1]);
  266.     }
  267.  
  268.         DOF2_SaveFile();
  269.     }
  270.     return 1;
  271. }
  272.  
  273.  
  274. Carregar(playerid)
  275. {
  276.     new string[128];
  277.     format(string, sizeof(string), "Cash/%s.ini", PlayerNome(playerid));
  278.     Player[playerid][Cash] = DOF2_GetInt(string, "Cash");
  279.     veiculo[playerid][idv] = DOF2_GetInt(string, "Veiculo");
  280.    
  281.     new each[50], eacht[50];
  282.     for (new i = 0; i <= 12; i++) {
  283.         format(each, sizeof(each), "Arma%d", i), format(eacht, sizeof(eacht), "Municao%d", i);
  284.         GivePlayerWeapon(playerid, DOF2_GetInt(string, eacht), DOF2_GetInt(PlayerNome(playerid), eacht));
  285.     }
  286.    
  287.     DOF2_SaveFile();
  288.     return 1;
  289. }
  290.  
  291. PlayerNome(playerid)
  292. {
  293.     new nomeplayer[MAX_PLAYER_NAME];
  294.     GetPlayerName(playerid, nomeplayer, sizeof(nomeplayer));
  295.     return nomeplayer;
  296. }
  297.  
  298. forward atualizacash(playerid);
  299. public atualizacash(playerid)
  300. {
  301.     new string[128];
  302.     format(string,sizeof(string),"C$%d",Player[playerid][Cash]);
  303.     TextDrawSetString(TextCash, string);
  304. }
  305.  
Add Comment
Please, Sign In to add comment