Guest User

Untitled

a guest
Feb 22nd, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.55 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #undef MAX_PLAYERS
  4. #define MAX_PLAYERS 32
  5.  
  6. new pRank[MAX_PLAYERS];
  7. new pScore[MAX_PLAYERS];
  8.  
  9. new gRankScore[] = {
  10. 100, // Rank 2
  11. 250, // Rank 3
  12. 500, // Rank 4
  13. 1000 // Rank 5
  14. };
  15.  
  16. #define GetMaxLevel sizeof(gRankScore)
  17.  
  18. main() {}
  19.  
  20. stock GivePlayerScore(playerid, score=1)
  21. {
  22.     //SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
  23.     pScore[playerid] += score;
  24.     if(pRank[playerid] == GetMaxLevel)
  25.     {
  26.         print("MAX LEVEL REACHED");
  27.         return 1; // Max level, stop.
  28.     }
  29.     while(pScore[playerid] >= gRankScore[pRank[playerid]])
  30.     {
  31.         print("RANK UP");
  32.         pRank[playerid]++;
  33.         new szString[128], pName[MAX_PLAYER_NAME] = "Mike";
  34.         format(szString, sizeof(szString), "%s (%i) levelled up! Level: %i", pName, playerid, pRank[playerid]+1);
  35.         SendClientMessageToAllBut(playerid, -1, szString);
  36.         print(szString);
  37.         printf("LEVEL: %i/%i", pRank[playerid], GetMaxLevel);
  38.         if(pRank[playerid] == GetMaxLevel)
  39.         {
  40.             print("MAX LEVEL");
  41.             format(szString, sizeof(szString), "You reached the max level (%i)!", GetMaxLevel);
  42.             return SendClientMessage(playerid, -1, szString);
  43.         }
  44.     }
  45.     if(pRank[playerid] != GetMaxLevel) printf("Score needed for level %i: %i", pRank[playerid]+2, gRankScore[pRank[playerid]]-pScore[playerid]);
  46.     return 1;
  47. }
  48.  
  49. stock SendClientMessageToAllBut(playerid, color, msg[])
  50. {
  51.     for(new i=0; i<MAX_PLAYERS; i++)
  52.     {
  53.         if(i != playerid) SendClientMessage(i, color, msg);
  54.     }
  55.     return 1;
  56. }
  57.  
  58. public OnRconCommand(cmd[])
  59. {
  60.     GivePlayerScore(0, strval(cmd));
  61.     return 1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment