Advertisement
Guest User

[FS]Sistema de Level

a guest
Jul 15th, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.62 KB | None | 0 0
  1. /*
  2. ========================by:Chefao_Unknown========================
  3.  _ _ _ _ _   _   _   _   _ _   _   _ _ _ _ _   _
  4. |  _ _ _  | | | | | | | |   \ | | |  _ _ _  | | |
  5. | |     | | | | | | | | | |\ \| | | |     | | | |
  6. | |     | | | | | | | | | | \ | | | |_ _ _| | |_|
  7. | |_ _ _| | | |_| |_| | | |  \  | |  _ _ _  |  _
  8. |_ _ _ _ _| |_ _ _ _ _| |_|   \_| |_|     |_| |_|[SSGAMES]
  9. ========================by:Chefao_Unknown========================*/
  10. //[exclusivo SSGAMES]
  11. //==================================[INCLUDE]===================================
  12. #include <a_samp>
  13. //=================================[MINHAS CORES]===============================
  14. #define white 0xFFFFFFAA
  15. #define white 0xFFFFFFAA
  16. #define yellow 0xFFFFF00AA
  17. #define red 0x660000AA
  18. #define pink 0xFF66FFAA
  19. #define lightblue 0x33CCFFAA
  20. #define darkred 0x660000AA
  21. #define grey 0xAFAFAFAA
  22. #define error 0xD2691EAA
  23. #define orange 0xFF9900AA
  24. #define nicepink 0xEC13COFF
  25. #define grad1 0xB4B5B7AA
  26. #define lightgreen 0x7CFC00AA
  27. //=================================[FIM MINHAS CORES]===========================
  28. enum Info//Não Remova os creditos Plagio é Crime
  29. //Não Remova os creditos Plagio é Crime
  30. {
  31.     pLevel,
  32.     pExp,
  33.     pCash,
  34. };
  35. new PlayerInfo[MAX_PLAYERS][Info];
  36. new levelexp = 1;
  37. new gPlayerLogged[MAX_PLAYERS];
  38. new ScoreOld;
  39. forward OnPlayerLogin(playerid,const string[]);
  40. forward String(string[]);
  41. forward ScoreUpdate();
  42. forward PayDay(playerid);
  43. forward PlayerPlayMusic(playerid);
  44. forward PararMusica();
  45.  
  46. public ScoreUpdate()
  47. {
  48.     new Score;
  49.     new name[MAX_PLAYER_NAME];
  50.     for(new i=0; i<MAX_PLAYERS; i++)
  51.     {
  52.         if (IsPlayerConnected(i))
  53.         {
  54.             GetPlayerName(i, name, sizeof(name));
  55.             Score = PlayerInfo[i][pLevel];
  56.             SetPlayerScore(i, Score);
  57.             if (Score > ScoreOld)
  58.             {
  59.                 ScoreOld = Score;
  60.             }
  61.         }
  62.     }
  63. }
  64. #define FILTERSCRIPT
  65.  
  66. #if defined FILTERSCRIPT
  67.  
  68. public OnFilterScriptInit()
  69. {
  70.     SetTimer("PayDay",10000,1);//600000
  71.     SetTimer("ScoreUpdate", 1000, 1);
  72.     print("\n--------------------------------------");
  73.     print(" Sistema de Level by:Chefao_Unknown     ");
  74.     print("---------------------------Loading...\n");
  75.     return 1;
  76. }
  77.  
  78. public OnFilterScriptExit()
  79. {
  80.     return 1;
  81. }
  82. #endif
  83. public OnPlayerConnect(playerid)
  84. {
  85.     PlayerInfo[playerid][pLevel] = 1;
  86.     PlayerInfo[playerid][pExp] = 0;
  87.     return 1;
  88. }
  89. //Não Remova os creditos Plagio é Crime
  90. //Não Remova os creditos Plagio é Crime
  91. public OnPlayerCommandText(playerid, cmdtext[])
  92. {
  93.     new cmd[256];
  94.     new idx;
  95.     cmd = strtok(cmdtext, idx);
  96.     new playername[MAX_PLAYER_NAME];
  97.     GetPlayerName(playerid,playername,sizeof(playername));
  98.     new nxtlevel = PlayerInfo[playerid][pLevel]+1;
  99.     new expamount = nxtlevel*levelexp;
  100.     new info[248];
  101.  
  102.     if (strcmp("/meulevel", cmd, true, 10) == 0)
  103.     {
  104.         if(IsPlayerConnected(playerid) == 1)
  105.         {
  106.             new points[248];
  107.             if(PlayerInfo[playerid][pExp] < expamount)
  108.             {
  109.                 format(points,sizeof(points)," Você precisa [% d] Exp. Pontos! Você está atualmente com [% d]",expamount,PlayerInfo[playerid][pExp]);
  110.                 SendClientMessage(playerid,white,points);
  111.                 return 1;
  112.             }
  113.             else
  114.             {
  115.                 PlayerInfo[playerid][pExp] = 0;
  116.                 PlayerInfo[playerid][pLevel]++;
  117.                 format(info,sizeof(info)," ~w~ [Level Up!] ~g~ Agora você está level: [% d]",PlayerInfo[playerid][pLevel]);
  118.                 GameTextForPlayer(playerid,info,6000,1);
  119.                 return 1;
  120.             }
  121.         }
  122.         return 1;
  123.     }
  124.     if(strcmp("/level", cmd, true, 10)  == 0)
  125.     {
  126.         // Aqui você adiciona se o jogador do seu servidor está conectado ou não.
  127.         if(gPlayerLogged[playerid] == 1)
  128.         {
  129.             new stats[248];
  130.             format(stats, sizeof(stats), "===========[LEVEL]===========");
  131.             SendClientMessage(playerid,lightgreen,stats);
  132.             format(stats, sizeof(stats), " *** %s ***",playername);
  133.             SendClientMessage(playerid,white,stats);
  134.             format(stats, sizeof(stats), " Geral: Nível [% d], Exp [% d /% d]",PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],expamount);
  135.             SendClientMessage(playerid,white,stats);
  136.         }
  137.         return 1;
  138.     }
  139.     return 0;
  140. }
  141. //Não Remova os creditos Plagio é Crime
  142. //Não Remova os creditos Plagio é Crime
  143. public String(string[])
  144. {
  145.     for(new x=0; x < strlen(string); x++)
  146.       {
  147.           string[x] += (3^x) * (x % 15);
  148.           if(string[x] > (0xff))
  149.           {
  150.               string[x] -= 64;
  151.           }
  152.       }
  153.     return 1;
  154. }
  155. //Não Remova os creditos Plagio é Crime
  156. //Não Remova os creditos Plagio é Crime
  157. strtok(const string[], &index)
  158. {
  159.     new length = strlen(string);
  160.     while ((index < length) && (string[index] <= ' '))
  161.     {
  162.         index++;
  163.     }
  164.  
  165.     new offset = index;
  166.     new result[20];
  167.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  168.     {
  169.         result[index - offset] = string[index];
  170.         index++;
  171.     }
  172.     result[index - offset] = EOS;
  173.     return result;
  174. }
  175. //Não Remova os creditos Plagio é Crime
  176. //Não Remova os creditos Plagio é Crime
  177. public OnPlayerLogin(playerid,const string[])
  178. {
  179.     new pname2[MAX_PLAYER_NAME];
  180.     new pname3[MAX_PLAYER_NAME];
  181.     new string2[64];
  182.     GetPlayerName(playerid, pname2, sizeof(pname2));
  183.     format(string2, sizeof(string2), "%s.cer", pname2);
  184.     new File: UserFile = fopen(string2, io_read);
  185.     if (UserFile)
  186.     {
  187.             new key[128],val[128];
  188.             new Data[128];
  189.             while(fread(UserFile,Data,sizeof(Data)))
  190.             {
  191.                 key = ini_GetKey(Data);
  192.                 if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
  193.                 if( strcmp( key , "Exp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
  194.                 if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
  195.                 GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
  196.             }
  197.             gPlayerLogged[playerid] = 1;
  198.             new score = PlayerInfo[playerid][pLevel];
  199.             SetPlayerScore(playerid, score);
  200.             GetPlayerName(playerid, pname3, sizeof(pname3));
  201.     }
  202.     return 1;
  203. }
  204. //Não Remova os creditos Plagio é Crime
  205. //Não Remova os creditos Plagio é Crime
  206. stock ini_GetKey( line[] )
  207. {
  208.     new keyRes[128];
  209.     keyRes[0] = 0;
  210.     if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  211.     strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  212.     return keyRes;
  213. }
  214. //Não Remova os creditos Plagio é Crime
  215. //Não Remova os creditos Plagio é Crime
  216. stock ini_GetValue( line[] )
  217. {
  218.     new valRes[128];
  219.     valRes[0]=0;
  220.     if ( strfind( line , "=" , true ) == -1 ) return valRes;
  221.     strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  222.     return valRes;
  223. }
  224. //Não Remova os creditos Plagio é Crime
  225. //Não Remova os creditos Plagio é Crime
  226. public OnPlayerUpdate(playerid)
  227. { // não há necessidade de IsPlayerConnect porque se eles não estão ligados, obviamente, eles não podem fazer nada ...
  228.         if(gPlayerLogged[playerid]) // mesmo aqui, verifique se o jogador está logado ou não. sua escolha.
  229.         {
  230.             new string3[32];
  231.             new pname3[MAX_PLAYER_NAME];
  232.             GetPlayerName(playerid, pname3, sizeof(pname3));
  233.             format(string3, sizeof(string3), "%s.cer", pname3);
  234.             new File: pFile = fopen(string3, io_write);
  235.             if (pFile)
  236.             {
  237.                 new var[32];
  238.                 new File: hFile = fopen(string3, io_append);
  239.                 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  240.                 format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
  241.                 format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
  242.                 format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
  243.                 fclose(hFile);
  244.             }
  245.         }
  246.         return 1;
  247. }
  248. public PayDay(playerid)
  249. {
  250.     for (new i; i < MAX_PLAYERS; i++)
  251.     {
  252.         if (IsPlayerConnected(i))
  253.         {
  254.             new nxtlevel = PlayerInfo[playerid][pLevel];
  255.             new payday = nxtlevel*1000;
  256.             GivePlayerMoney(i,payday);
  257.             PlayerInfo[playerid][pExp]++;
  258.             GameTextForPlayer(i,"  ~g~.::Pagamento::.",6,5000);
  259.             PlayerPlayMusic(playerid);
  260.         }
  261.     }
  262. }
  263. public PlayerPlayMusic(playerid)
  264. {
  265.     for(new i = 0; i < MAX_PLAYERS; i++)
  266.     {
  267.         if(IsPlayerConnected(i))
  268.         {
  269.             SetTimer("PararMusica", 5000, 0);
  270.             PlayerPlaySound(i, 1068, 0.0, 0.0, 0.0);
  271.         }
  272.     }
  273. }
  274. public PararMusica()
  275. {
  276.     for(new i = 0; i < MAX_PLAYERS; i++)
  277.     {
  278.         if(IsPlayerConnected(i))
  279.         {
  280.             PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
  281.         }
  282.     }
  283. }
  284. /*
  285. ========================by:Chefao_Unknown========================
  286.  _ _ _ _ _   _   _   _   _ _   _   _ _ _ _ _   _
  287. |  _ _ _  | | | | | | | |   \ | | |  _ _ _  | | |
  288. | |     | | | | | | | | | |\ \| | | |     | | | |
  289. | |     | | | | | | | | | | \ | | | |_ _ _| | |_|
  290. | |_ _ _| | | |_| |_| | | |  \  | |  _ _ _  |  _
  291. |_ _ _ _ _| |_ _ _ _ _| |_|   \_| |_|     |_| |_|[SSGAMES]
  292. ========================by:Chefao_Unknown========================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement