Advertisement
Guest User

RichList

a guest
Jun 26th, 2019
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. enum e_top_richlist
  2. {
  3. E_playerid,
  4. E_money
  5. };
  6. //---------//
  7. CMD:listabogatih(playerid, params[])
  8. {
  9. new richlist[MAX_PLAYERS][e_top_richlist],
  10. finstring[2048] = "#\tIgrac\tUkupna svota\n",
  11. tmpstring[68];
  12.  
  13. for(new i = 0; i < MAX_PLAYERS; i++) //Mozete i foreach/GetPlayerPoolSize....
  14. {
  15. if (IsLoggedIn[i] == 1) //Stavite vasu provjeru za provjeru jeli je igrac logiran
  16. {
  17. richlist[i][E_playerid] = i;
  18. richlist[i][E_money] = GetPlayerCash(i);
  19. }
  20. else
  21. {
  22. richlist[i][E_playerid] = -1;
  23. richlist[i][E_money] = -1;
  24. }
  25. }
  26.  
  27. SortDeepArray(richlist, E_money, .order = SORT_DESC);
  28.  
  29. for(new i = 0; i < 20; i++)
  30. {
  31. if(richlist[i][E_money] != -1)
  32. format(tmpstring, sizeof(tmpstring), "%i.\t%s\t$%s\n", i + 1, GetName(richlist[i][E_playerid]), number_format(richlist[i][E_money]));
  33. else
  34. format(tmpstring, sizeof(tmpstring), "%i. N/A\n", i + 1);
  35.  
  36. strcat(finstring, tmpstring);
  37. }
  38.  
  39. ShowPlayerDialog(playerid, RICHLIST_DIALOG, DIALOG_STYLE_TABLIST_HEADERS, "Najbogatiji Igraci (Online)", finstring, "OK", "");
  40. return 1;
  41. }
  42. //---------//
  43. number_format(num)
  44. {
  45. new szStr[16];
  46. format(szStr, sizeof(szStr), "%i", num);
  47.  
  48. for(new iLen = strlen(szStr) - (num < 0 ? 4 : 3); iLen > 0; iLen -= 3)
  49. {
  50. strins(szStr, ",", iLen);
  51. }
  52. return szStr;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement