WPNiGGa

[FS] Sistema de nivel

Mar 21st, 2014
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.20 KB | None | 0 0
  1.                                         //////////////////////////////////////////////////////////////////////////
  2.                                         //                                      [FilterScript] Sistema de Nivel                                         //
  3.                                         //                                                                      //
  4.                                         //                      http://forum.sa-mp.com/showthread.php?t=502080              //
  5.                                         //////////////////////////////////////////////////////////////////////////
  6.                                         //                          Informações do projeto                      //
  7.                                         //                                                                      //
  8.                                         // - Nome do projeto: Sistema de Nivel                                  //
  9.                                         // - Autor do projeto: WPNiGGa aka n0tt_                                //
  10.                                         // - Versão do projeto: 1.2b                                            //
  11.                                         // - Data de criação: 21/03/2014                                        //
  12.                                         // - Ultima edição: 14/04/2014                                          //
  13.                                         // - Changelog: http://forum.sa-mp.com/showthread.php?t=502080          //
  14.                                         // - Helpers: Wiki SA-MP                                                //
  15.                                         // - Tempo de desenvolvimento da fase 1.0b: 3h.                         //
  16.                                         // - Tempo de desenvolvimento da fase 1.2b: 20m.                        //
  17.                                         // - Tempo de desenvolvimento da fase 2.0: 35m.                        //
  18.                                         // - Razão do projeto: Desenferrujar o meu conhecimento de pawn.        //
  19.                                         //////////////////////////////////////////////////////////////////////////
  20.                                         //                          Notas do autor                              //
  21.                                         //                                                                      //
  22.                                         // - Este projeto já foi testado IN-Game;                                                              //
  23.                                         // - Não foram encontrados quaisquer bugs;                              //
  24.                                         // - Não fazer mirrors do projeto;                                      //
  25.                                         // - Não retirar os créditos;                                                 //
  26.                                         // - Não publicar noutros foruns/sites sem o meu concentimento.         //
  27.                                         //////////////////////////////////////////////////////////////////////////
  28.  
  29. #include    <a_samp>
  30. #include    <zcmd>
  31. #include    <DOF2>
  32. #include    <sscanf2>
  33. #include    <progressbar>
  34. #define COLOR_BLUE      0x1E90FFAA
  35. #define COLOR_ORANGE    0xFF8C00AA
  36.  
  37. #define Nivel_Info "|| %s (id: %d) || Nível: %d & Experiência: %d/%d"
  38.  
  39. #if defined FILTERSCRIPT
  40.  
  41. #else
  42.  
  43. #endif
  44.  
  45. new Exp[MAX_PLAYERS];
  46. new TExp[MAX_PLAYERS];
  47. new Nivel[MAX_PLAYERS];
  48. new Kills[MAX_PLAYERS];
  49. new String[128];
  50. new TOnline[MAX_PLAYERS];
  51. new Online[MAX_PLAYERS];
  52. new TimerPlayerOnline[MAX_PLAYERS];
  53.  
  54. new PlayerText:ExpDraw[9];
  55. new Bar:ExpBar[2][MAX_PLAYERS];
  56.  
  57.  
  58. forward PlayerOnline(playerid);
  59.  
  60. public OnFilterScriptInit()
  61. {
  62.         SetTimer("Atualizar", 1000, true);
  63.         return 1;
  64. }
  65.  
  66. public OnFilterScriptExit()
  67. {
  68.         DOF2_Exit();
  69.         return 1;
  70. }
  71.  
  72. public OnPlayerSpawn(playerid)
  73. {
  74.         LoadConta(playerid);
  75.         LoadPlayerTextDraws(playerid);
  76.        
  77.         for(new i = 0; i < 9; i++)
  78.             PlayerTextDrawShow(playerid, ExpDraw[i]);
  79.         //exp bar total exp percentagem
  80.         ExpBar[playerid][0] = CreateProgressBar(535.00, 125.00, 67.50, 5.19, -7601921, 100.0);
  81.         ShowProgressBarForPlayer(playerid, ExpBar[playerid][0]);
  82.         //ExpBar +1exp
  83.         ExpBar[playerid][1] = CreateProgressBar(498.00, 137.00, 111.50, 10.19, 512819199, 100.0);
  84.         ShowProgressBarForPlayer(playerid, ExpBar[playerid][1]);
  85.        
  86.         TimerPlayerOnline[playerid] = SetTimerEx("PlayerOnline", 1000, true,"i", playerid);
  87.         return 1;
  88. }
  89.  
  90. public OnPlayerDisconnect(playerid, reason)
  91. {
  92.         GuardarConta(playerid);
  93.         return 1;
  94. }
  95. public OnPlayerUpdate(playerid)
  96. {
  97.     format(String, sizeof(String), "%.0f%", (floatdiv(Exp[playerid], TExp[playerid]) * 100.0));
  98.     PlayerTextDrawSetString(playerid, ExpDraw[7], String);
  99.     format(String, sizeof(String), "%.0f%", (floatdiv(Kills[playerid], 13) * 100.0));
  100.     PlayerTextDrawSetString(playerid, ExpDraw[8], String);
  101.     PlayerTextDrawShow(playerid, ExpDraw[7]);
  102.     format(String, sizeof(String), "~w~Nivel: ~y~%d", Nivel[playerid]);
  103.     PlayerTextDrawSetString(playerid, ExpDraw[1], String);
  104.     PlayerTextDrawShow(playerid, ExpDraw[1]);
  105.    
  106.     SetProgressBarValue(ExpBar[playerid][0],(floatdiv(Exp[playerid], TExp[playerid]) * 100.0));
  107.     ShowProgressBarForPlayer(playerid, ExpBar[playerid][0]);
  108.    
  109.     SetProgressBarValue(ExpBar[playerid][1],(floatdiv(Kills[playerid], 13) * 100.0));
  110.     ShowProgressBarForPlayer(playerid, ExpBar[playerid][1]);
  111.     if(Kills[playerid] == 13)
  112.     {
  113.         SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Fizes-te 13 kills e ganhas-te +2EXP !");
  114.         Exp[playerid] = Exp[playerid] + 2;
  115.         Kills[playerid] = 0;
  116.     }
  117.     new H, M, S;
  118.     gettime(H, M, S);
  119.  
  120.     if(M == 00 && S == 00)
  121.     {
  122.         format(String, sizeof(String), "~b~ São ~r~%d ~b~Horas e ~r~%d ~b~Minutos\n ~r~HORA DO PAYDAY!", H, M);
  123.         GameTextForAll(String, 1500, 6);
  124.         if(Online[playerid] != 1) return SendClientMessage(playerid, COLOR_ORANGE, "|| INFO || Não recebeste o payday. Razão: Não estás online á mais de 30minutos.");
  125.         Exp[playerid]+=7;
  126.         if(TExp[playerid] == Exp[playerid] || Exp[playerid] > TExp[playerid])
  127.         {
  128.             Nivel[playerid]++;
  129.             TExp[playerid] = Nivel[playerid]*6;
  130.             Exp[playerid] = 0;
  131.             format(String, sizeof(String), "|| INFO || Parabéns, subiste para nivel %d e tens %d/%d de experiência", Nivel[playerid], Exp[playerid], TExp[playerid]);
  132.             SendClientMessage(playerid, COLOR_BLUE, String);
  133.             GuardarConta(playerid);
  134.         }
  135.     }
  136.     return 1;
  137. }
  138. public OnPlayerDeath(playerid, killerid, reason)
  139. {
  140.     if(killerid != INVALID_PLAYER_ID)
  141.     {
  142.         Kills[playerid]--;
  143.         Kills[killerid]++;
  144.     }
  145.     return 1;
  146. }
  147.  
  148.  
  149. public PlayerOnline(playerid)
  150. {
  151.     TOnline[playerid]++;
  152.     if(60*30 <= TOnline[playerid])
  153.     {
  154.             Online[playerid] = 1;
  155.             KillTimer(TimerPlayerOnline[playerid]);
  156.     }
  157.     return 1;
  158. }
  159. CMD:nivel(playerid, params[])
  160. {
  161.     new id;
  162.     format(String, sizeof(String), Nivel_Info, Name(playerid), playerid, Nivel[playerid], Exp[playerid], TExp[playerid]);
  163.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_BLUE, String);
  164.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ORANGE, "|| ERRO || O player não está conectado.");
  165.     format(String, sizeof(String), Nivel_Info, Name(id), id, Nivel[id], Exp[id], TExp[id]);
  166.     SendClientMessage(playerid, COLOR_BLUE, String);
  167.     return 1;
  168. }
  169.  
  170. stock CriarConta(playerid)
  171. {
  172.     if(DOF2_FileExists(file(playerid)))
  173.         return LoadConta(playerid);
  174.     DOF2_CreateFile(file(playerid));
  175.     DOF2_SetInt(file(playerid), "Nivel", 1);
  176.     DOF2_SetInt(file(playerid), "Exp", 0);
  177.     DOF2_SetInt(file(playerid), "TExp", 6);
  178.     DOF2_SaveFile();
  179.     return LoadConta(playerid);
  180. }
  181. stock GuardarConta(playerid)
  182. {
  183.     if(!DOF2_FileExists(file(playerid)))
  184.         return DOF2_CreateFile(file(playerid));
  185.     DOF2_SetInt(file(playerid), "Nivel", Nivel[playerid]);
  186.     DOF2_SetInt(file(playerid), "Exp", Exp[playerid]);
  187.     DOF2_SetInt(file(playerid), "TExp", TExp[playerid]);
  188.     DOF2_SaveFile();
  189.     return 1;
  190. }
  191.  
  192. stock LoadConta(playerid)
  193. {
  194.     if(!DOF2_FileExists(file(playerid)))
  195.         CriarConta(playerid);
  196.     Nivel[playerid] = DOF2_GetInt(file(playerid), "Nivel");
  197.     Exp[playerid] = DOF2_GetInt(file(playerid), "Exp");
  198.     TExp[playerid] = DOF2_GetInt(file(playerid), "TExp");
  199.     return 1;
  200. }
  201. stock Name(playerid)
  202. {
  203.     new Nick[MAX_PLAYER_NAME];
  204.     GetPlayerName(playerid, Nick, 24);
  205.     return Nick;
  206. }
  207. stock LoadPlayerTextDraws(playerid)
  208. {
  209.     ExpDraw[0] = CreatePlayerTextDraw(playerid,620.000000, 102.000000, "_");
  210.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[0], 255);
  211.     PlayerTextDrawFont(playerid,ExpDraw[0], 1);
  212.     PlayerTextDrawLetterSize(playerid,ExpDraw[0], 0.500000, 5.599999);
  213.     PlayerTextDrawColor(playerid,ExpDraw[0], -1);
  214.     PlayerTextDrawSetOutline(playerid,ExpDraw[0], 0);
  215.     PlayerTextDrawSetProportional(playerid,ExpDraw[0], 1);
  216.     PlayerTextDrawSetShadow(playerid,ExpDraw[0], 1);
  217.     PlayerTextDrawUseBox(playerid,ExpDraw[0], 1);
  218.     PlayerTextDrawBoxColor(playerid,ExpDraw[0], 96);
  219.     PlayerTextDrawTextSize(playerid,ExpDraw[0], 488.000000, -41.000000);
  220.     PlayerTextDrawSetSelectable(playerid,ExpDraw[0], 0);
  221.  
  222.     ExpDraw[1] = CreatePlayerTextDraw(playerid,496.000000, 102.000000, "~w~Nivel: ~y~20");
  223.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[1], 255);
  224.     PlayerTextDrawFont(playerid,ExpDraw[1], 2);
  225.     PlayerTextDrawLetterSize(playerid,ExpDraw[1], 0.310000, 1.600000);
  226.     PlayerTextDrawColor(playerid,ExpDraw[1], -1);
  227.     PlayerTextDrawSetOutline(playerid,ExpDraw[1], 0);
  228.     PlayerTextDrawSetProportional(playerid,ExpDraw[1], 1);
  229.     PlayerTextDrawSetShadow(playerid,ExpDraw[1], 1);
  230.     PlayerTextDrawSetSelectable(playerid,ExpDraw[1], 0);
  231.  
  232.     ExpDraw[2] = CreatePlayerTextDraw(playerid,496.000000, 119.000000, "~w~Exp:");
  233.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[2], 255);
  234.     PlayerTextDrawFont(playerid,ExpDraw[2], 2);
  235.     PlayerTextDrawLetterSize(playerid,ExpDraw[2], 0.310000, 1.600000);
  236.     PlayerTextDrawColor(playerid,ExpDraw[2], -1);
  237.     PlayerTextDrawSetOutline(playerid,ExpDraw[2], 0);
  238.     PlayerTextDrawSetProportional(playerid,ExpDraw[2], 1);
  239.     PlayerTextDrawSetShadow(playerid,ExpDraw[2], 1);
  240.     PlayerTextDrawSetSelectable(playerid,ExpDraw[2], 0);
  241.  
  242.     ExpDraw[3] = CreatePlayerTextDraw(playerid,489.500000, 98.000000, "ld_dual:health");
  243.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[3], 255);
  244.     PlayerTextDrawFont(playerid,ExpDraw[3], 4);
  245.     PlayerTextDrawLetterSize(playerid,ExpDraw[3], 0.500000, 1.000000);
  246.     PlayerTextDrawColor(playerid,ExpDraw[3], -1);
  247.     PlayerTextDrawSetOutline(playerid,ExpDraw[3], 0);
  248.     PlayerTextDrawSetProportional(playerid,ExpDraw[3], 1);
  249.     PlayerTextDrawSetShadow(playerid,ExpDraw[3], 1);
  250.     PlayerTextDrawUseBox(playerid,ExpDraw[3], 1);
  251.     PlayerTextDrawBoxColor(playerid,ExpDraw[3], 255);
  252.     PlayerTextDrawTextSize(playerid,ExpDraw[3], 129.000000, 2.000000);
  253.     PlayerTextDrawSetSelectable(playerid,ExpDraw[3], 0);
  254.  
  255.     ExpDraw[4] = CreatePlayerTextDraw(playerid,489.500000, 153.000000, "ld_dual:health");
  256.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[4], 255);
  257.     PlayerTextDrawFont(playerid,ExpDraw[4], 4);
  258.     PlayerTextDrawLetterSize(playerid,ExpDraw[4], 0.500000, 1.000000);
  259.     PlayerTextDrawColor(playerid,ExpDraw[4], -1);
  260.     PlayerTextDrawSetOutline(playerid,ExpDraw[4], 0);
  261.     PlayerTextDrawSetProportional(playerid,ExpDraw[4], 1);
  262.     PlayerTextDrawSetShadow(playerid,ExpDraw[4], 1);
  263.     PlayerTextDrawUseBox(playerid,ExpDraw[4], 1);
  264.     PlayerTextDrawBoxColor(playerid,ExpDraw[4], 255);
  265.     PlayerTextDrawTextSize(playerid,ExpDraw[4], 129.000000, 2.000000);
  266.     PlayerTextDrawSetSelectable(playerid,ExpDraw[4], 0);
  267.  
  268.     ExpDraw[5] = CreatePlayerTextDraw(playerid,489.000000, 98.000000, "ld_dual:health");
  269.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[5], 255);
  270.     PlayerTextDrawFont(playerid,ExpDraw[5], 4);
  271.     PlayerTextDrawLetterSize(playerid,ExpDraw[5], 0.500000, 1.000000);
  272.     PlayerTextDrawColor(playerid,ExpDraw[5], -1);
  273.     PlayerTextDrawSetOutline(playerid,ExpDraw[5], 0);
  274.     PlayerTextDrawSetProportional(playerid,ExpDraw[5], 1);
  275.     PlayerTextDrawSetShadow(playerid,ExpDraw[5], 1);
  276.     PlayerTextDrawUseBox(playerid,ExpDraw[5], 1);
  277.     PlayerTextDrawBoxColor(playerid,ExpDraw[5], 255);
  278.     PlayerTextDrawTextSize(playerid,ExpDraw[5], 1.000000, 57.000000);
  279.     PlayerTextDrawSetSelectable(playerid,ExpDraw[5], 0);
  280.  
  281.     ExpDraw[6] = CreatePlayerTextDraw(playerid,618.000000, 98.000000, "ld_dual:health");
  282.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[6], 255);
  283.     PlayerTextDrawFont(playerid,ExpDraw[6], 4);
  284.     PlayerTextDrawLetterSize(playerid,ExpDraw[6], 0.500000, 1.000000);
  285.     PlayerTextDrawColor(playerid,ExpDraw[6], -1);
  286.     PlayerTextDrawSetOutline(playerid,ExpDraw[6], 0);
  287.     PlayerTextDrawSetProportional(playerid,ExpDraw[6], 1);
  288.     PlayerTextDrawSetShadow(playerid,ExpDraw[6], 1);
  289.     PlayerTextDrawUseBox(playerid,ExpDraw[6], 1);
  290.     PlayerTextDrawBoxColor(playerid,ExpDraw[6], 255);
  291.     PlayerTextDrawTextSize(playerid,ExpDraw[6], 1.000000, 57.000000);
  292.     PlayerTextDrawSetSelectable(playerid,ExpDraw[6], 0);
  293.  
  294.     ExpDraw[7] = CreatePlayerTextDraw(playerid,568.000000, 122.500000, "100%");
  295.     PlayerTextDrawAlignment(playerid,ExpDraw[7], 2);
  296.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[7], 255);
  297.     PlayerTextDrawFont(playerid,ExpDraw[7], 2);
  298.     PlayerTextDrawLetterSize(playerid,ExpDraw[7], 0.289999, 1.000000);
  299.     PlayerTextDrawColor(playerid,ExpDraw[7], 255);
  300.     PlayerTextDrawSetOutline(playerid,ExpDraw[7], 0);
  301.     PlayerTextDrawSetProportional(playerid,ExpDraw[7], 1);
  302.     PlayerTextDrawSetShadow(playerid,ExpDraw[7], 0);
  303.     PlayerTextDrawSetSelectable(playerid,ExpDraw[7], 0);
  304.  
  305.     ExpDraw[8] = CreatePlayerTextDraw(playerid,553.000000, 137.000000, "100%");
  306.     PlayerTextDrawAlignment(playerid,ExpDraw[8], 2);
  307.     PlayerTextDrawBackgroundColor(playerid,ExpDraw[8], 255);
  308.     PlayerTextDrawFont(playerid,ExpDraw[8], 1);
  309.     PlayerTextDrawLetterSize(playerid,ExpDraw[8], 0.500000, 1.000000);
  310.     PlayerTextDrawColor(playerid,ExpDraw[8], 65535);
  311.     PlayerTextDrawSetOutline(playerid,ExpDraw[8], 0);
  312.     PlayerTextDrawSetProportional(playerid,ExpDraw[8], 1);
  313.     PlayerTextDrawSetShadow(playerid,ExpDraw[8], 0);
  314.     PlayerTextDrawSetSelectable(playerid,ExpDraw[8], 0);
  315.     return 1;
  316. }
  317. stock file(playerid)
  318. {
  319.     new files[11+MAX_PLAYER_NAME];
  320.     format(files, sizeof(files), "Contas/%s.ini", Name(playerid));
  321.     return files;
  322. }
Add Comment
Please, Sign In to add comment