Advertisement
Lontresca

level bar samp

Apr 1st, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.16 KB | None | 0 0
  1. #include <a_samp>
  2. #include <progress2>
  3.  
  4. new PlayerText: TextDrawL;
  5. new PlayerBar: LevelBar;
  6.  
  7. enum iPlayers
  8. {
  9.     exp,
  10.     level
  11. };
  12. new pInfo[MAX_PLAYERS][iPlayers];
  13.  
  14. main()
  15. {
  16.     print("\n----------------------------------");
  17.     print(" Blank Gamemode by your name here");
  18.     print("----------------------------------\n");
  19. }
  20.  
  21. public OnGameModeInit()
  22. {
  23.     // Don't use these lines if it's a filterscript
  24.     SetGameModeText("Blank Script");
  25.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerRequestClass(playerid, classid)
  30. {
  31.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  32.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  33.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerConnect(playerid)
  38. {
  39.     SetPlayerScore(playerid, 1);
  40.    
  41.     // Criando TD =-=-=-=-=-=-=-=-=-=
  42.     TextDrawL = CreatePlayerTextDraw(playerid, 504.476257, 114.053321, "");
  43.     PlayerTextDrawLetterSize(playerid, TextDrawL, 0.308952, 0.951466);
  44.     PlayerTextDrawAlignment(playerid, TextDrawL, 1);
  45.     PlayerTextDrawColor(playerid, TextDrawL, -1);
  46.     PlayerTextDrawSetShadow(playerid, TextDrawL, 1);
  47.     PlayerTextDrawSetOutline(playerid, TextDrawL, 0);
  48.     PlayerTextDrawBackgroundColor(playerid, TextDrawL, 255);
  49.     PlayerTextDrawFont(playerid, TextDrawL, 3);
  50.     PlayerTextDrawSetProportional(playerid, TextDrawL, 1);
  51.     PlayerTextDrawSetShadow(playerid, TextDrawL, 1);
  52.     //
  53.    
  54.     // Bar
  55.     LevelBar = CreatePlayerProgressBar(playerid, 504.00, 127.00, 100.50, 4.50, 12444671, 100.0);
  56.     return 1;
  57. }
  58.  
  59. public OnPlayerSpawn(playerid)
  60. {
  61.     GivePlayerWeapon(playerid, 26, 9999);
  62.    
  63.     pInfo[playerid][exp] = 1;
  64.     pInfo[playerid][level] = GetPlayerScore(playerid);
  65.     AtualizarBar(playerid);
  66.     return 1;
  67. }
  68.  
  69.  
  70. public OnPlayerDisconnect(playerid, reason)
  71. {
  72.     PlayerTextDrawDestroy(playerid, TextDrawL);
  73.     DestroyPlayerProgressBar(playerid, LevelBar);
  74.     return 1;
  75. }
  76.  
  77. // Add exp Por Level
  78. public OnPlayerCommandText(playerid, cmdtext[])
  79. {
  80.     if (strcmp("/addexp", cmdtext, true, 10) == 0)
  81.     {
  82.         pInfo[playerid][exp]++;
  83.         AtualizarBar(playerid);
  84.         return 1;
  85.     }
  86.     return 0;
  87. }
  88.  
  89. // Add exp Por Morte
  90. // pode colocar a quantidade que quiser
  91. // Exemplo : pInfo[killerid][exp]+10;
  92. public OnPlayerDeath(playerid, killerid, reason)
  93. {
  94.     if(killerid != INVALID_PLAYER_ID)
  95.     {
  96.         pInfo[killerid][exp]++; // aqui é mais 1
  97.         AtualizarBar(killerid);
  98.     }
  99.     return 1;
  100. }
  101.  
  102. AtualizarBar(playerid)
  103. {
  104.     new string[64], expAdd;
  105.  
  106.     if(pInfo[playerid][level] <= 4) expAdd = pInfo[playerid][level]*2;
  107.     else if(pInfo[playerid][level] >= 5) expAdd = pInfo[playerid][level]*3;
  108.    
  109.     format(string, sizeof(string), "Level : %d [%d/%d]", pInfo[playerid][level], pInfo[playerid][exp], expAdd);
  110.     PlayerTextDrawSetString(playerid, TextDrawL, string);
  111.     PlayerTextDrawShow(playerid, TextDrawL);
  112.    
  113.     SetPlayerProgressBarMaxValue(playerid, LevelBar, expAdd);
  114.     SetPlayerProgressBarValue(playerid, LevelBar, pInfo[playerid][exp]);
  115.     ShowPlayerProgressBar(playerid, LevelBar);
  116.    
  117.     if(pInfo[playerid][exp] == expAdd)
  118.     {
  119.         pInfo[playerid][exp] = 0;
  120.         pInfo[playerid][level]++;
  121.         SetPlayerScore(playerid, GetPlayerScore(playerid) +1);
  122.     }
  123.     return 1;
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement