SHARE
TWEET

RankSystemv.1.1

Jakwob-WG Nov 26th, 2014 (edited) 246 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3.        $$$$$\           $$\                               $$\      ™
  4.        \__$$ |          $$ |                              $$ |
  5.           $$ | $$$$$$\  $$ |  $$\ $$\  $$\  $$\  $$$$$$\  $$$$$$$\
  6.           $$ | \____$$\ $$ | $$  |$$ | $$ | $$ |$$  __$$\ $$  __$$\
  7.     $$\   $$ | $$$$$$$ |$$$$$$  / $$ | $$ | $$ |$$ /  $$ |$$ |  $$ |
  8.     $$ |  $$ |$$  __$$ |$$  _$$<  $$ | $$ | $$ |$$ |  $$ |$$ |  $$ |
  9.     \$$$$$$  |\$$$$$$$ |$$ | \$$\ \$$$$$\$$$$  |\$$$$$$  |$$$$$$$  |
  10.      \______/  \_______|\__|  \__| \_____\____/  \______/ \_______/
  11.                                    _____________________________
  12.                                   |      Created By Jakwob™     |
  13.                   |  Do not claim its your own  |
  14.                   |________©2014 Jakwob™________|                             */
  15.  
  16. #define FILTERSCRIPT
  17.  
  18. #include <a_samp>
  19. #include <zcmd>
  20. #include <YSI\y_ini>
  21. #include <sscanf2>
  22.  
  23. #define UserPath "Levels/%s.ini"
  24. #define SCM SendClientMessage
  25. #define DIALOG_RANKHELP 3010
  26. #define DIALOG_MYRANK 3011
  27.  
  28. enum RankInfo
  29. {
  30.         xp,
  31.         level,
  32.     prestige
  33. }
  34. new rInfo[MAX_PLAYERS][RankInfo];
  35.  
  36. public OnFilterScriptInit()
  37. {
  38.         return 1;
  39. }
  40.  
  41. stock Path(playerid)
  42. {
  43.     new str[128],name[MAX_PLAYER_NAME];
  44.     GetPlayerName(playerid,name,sizeof(name));
  45.     format(str,sizeof(str),UserPath,name);
  46.     return str;
  47. }
  48. forward loadaccount_user(playerid, name[], value[]);
  49. public loadaccount_user(playerid, name[], value[])
  50. {
  51.     INI_Int("XP",rInfo[playerid][xp]);
  52.     INI_Int("Level",rInfo[playerid][level]);
  53.     INI_Int("Prestige",rInfo[playerid][prestige]);
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59.         INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
  60.         return 1;
  61. }
  62.  
  63. public OnPlayerDisconnect(playerid, reason)
  64. {
  65.  
  66.         new INI:file = INI_Open(Path(playerid));
  67.         INI_SetTag(file,"Player Levels");
  68.     INI_WriteInt(file,"XP",rInfo[playerid][xp]);
  69.     INI_WriteInt(file,"Level",rInfo[playerid][level]);
  70.     INI_WriteInt(file,"Prestige",rInfo[playerid][prestige]);
  71.     INI_Close(file);
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDeath(playerid, killerid, reason)
  76. {
  77.         rInfo[killerid][xp] += 1;
  78.         return 1;
  79. }
  80.  
  81. public OnPlayerUpdate(playerid)
  82. {
  83.         if(rInfo[playerid][xp] > 100)//Levels
  84.         {
  85.             new str[85];
  86.             rInfo[playerid][level] ++;
  87.             rInfo[playerid][xp] = 0;
  88.             GivePlayerMoney(playerid, 50000);
  89.             format(str, sizeof(str), "~g~Level up~n~~r~Your level: ~w~%d", rInfo[playerid][level]);
  90.             GameTextForPlayer(playerid, str, 8000, 1);
  91.         }
  92.         if(rInfo[playerid][level] > 100)//Prestige levels
  93.         {
  94.             new str[85];
  95.             rInfo[playerid][prestige] ++;
  96.             rInfo[playerid][xp] = 0;
  97.             rInfo[playerid][level] = 0;
  98.             GivePlayerMoney(playerid, 1000000);
  99.             format(str, sizeof(str), "~g~prestiged~n~~r~Prestige level: ~w~%d", rInfo[playerid][prestige]);
  100.             GameTextForPlayer(playerid, str, 8000, 1);
  101.         }
  102.         return 1;
  103. }
  104.  
  105. CMD:myrank(playerid, params[])
  106. {
  107.     new str[300];
  108.     format(str, sizeof(str), "XP: %d\nLevel: %d\nPrestige: %d\n", rInfo[playerid][xp], rInfo[playerid][level],rInfo[playerid][prestige]);
  109.         ShowPlayerDialog(playerid, DIALOG_MYRANK, DIALOG_STYLE_MSGBOX, "Your Rank", str, "Close", "");
  110.         return 1;
  111. }
  112.  
  113. CMD:rankhelp(playerid, params[])
  114. {
  115.         new str[300], str1[1000];
  116.         format(str, sizeof(str), "\n{FFFFFF}** {FF9900}XP {FFFFFF}**\n");
  117.         strcat(str1, str);
  118.         format(str, sizeof(str), "\nXP can be gained by many methods.\nKilling Players - 1 XP\nExample - 4 XP\nExample - 2 XP\n");
  119.         strcat(str1, str);
  120.         format(str, sizeof(str), "\n{FFFFFF}** {FF9900}Leveling up {FFFFFF}**\n");
  121.         strcat(str1, str);
  122.         format(str, sizeof(str), "\nUpon leveling up you will recieve a cash bonus each time you level up.\n");
  123.         strcat(str1, str);
  124.         format(str, sizeof(str), "\n{FFFFFF}** {FF9900}Prestige {FFFFFF}**\n");
  125.         strcat(str1, str);
  126.         format(str, sizeof(str), "\nWhen you reach the maximum level you will Prestige\nYou will recieve a huge cash bonus of $1 million each time you prestige.\n");
  127.         strcat(str1, str);
  128.         ShowPlayerDialog(playerid, DIALOG_RANKHELP, DIALOG_STYLE_MSGBOX, "Rank Help", str1, "Close", "");
  129.         return 1;
  130. }
  131.  
  132. CMD:givexp(playerid, params[])
  133. {
  134.         new ammount, ID, TargetName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128];
  135.         if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "ERROR: You need to be an admin to use this command!");
  136.         if(sscanf(params, "ui", ID, ammount)) return SendClientMessage(playerid, -1, "USAGE: /givexp <playerid> <1-99>");
  137.     if(ammount < 1 || ammount > 99) return SendClientMessage(playerid, -1, "ERROR: Invalid XP ammount. Number must be between 1 and 99.");
  138.     if(!IsPlayerConnected(ID))return SendClientMessage(playerid,-1,"ERROR: Player is not connected.");
  139.     {
  140.         GetPlayerName(ID,TargetName,MAX_PLAYER_NAME);
  141.         GetPlayerName(playerid,PlayerName, MAX_PLAYER_NAME);
  142.                 format(str, sizeof(str), "%s Has given you %d XP", PlayerName, ammount);
  143.         SendClientMessage(ID, -1, str);
  144.                 format(str, sizeof(str), "You have given you %s %d XP", TargetName, ammount);
  145.         SendClientMessage(playerid, -1, str);
  146.                 rInfo[ID][xp] += ammount;
  147.         }
  148.         return 1;
  149. }
  150.  
  151. CMD:givelvl(playerid, params[])
  152. {
  153.         new ammount, ID, TargetName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128];
  154.         if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "ERROR: You need to be an admin to use this command!");
  155.         if(sscanf(params, "ui", ID, ammount)) return SendClientMessage(playerid, -1, "USAGE: /givelevel <playerid> <1-99>");
  156.     if(ammount < 1 || ammount > 99) return SendClientMessage(playerid, -1, "ERROR: Invalid XP ammount. Number must be between 1 and 99.");
  157.     if(!IsPlayerConnected(ID))return SendClientMessage(playerid,-1,"ERROR: Player is not connected.");
  158.     {
  159.         GetPlayerName(ID,TargetName,MAX_PLAYER_NAME);
  160.         GetPlayerName(playerid,PlayerName, MAX_PLAYER_NAME);
  161.                 format(str, sizeof(str), "%s Has given you %d levels", PlayerName, ammount);
  162.         SendClientMessage(ID, -1, str);
  163.                 format(str, sizeof(str), "You have given you %s %d levels", TargetName, ammount);
  164.         SendClientMessage(playerid, -1, str);
  165.                 rInfo[ID][level] += ammount;
  166.         }
  167.         return 1;
  168. }
  169.  
  170. CMD:giveprestige(playerid, params[])
  171. {
  172.         new ammount, ID, TargetName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128];
  173.         if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "ERROR: You need to be an admin to use this command!");
  174.         if(sscanf(params, "ui", ID, ammount)) return SendClientMessage(playerid, -1, "USAGE: /giveprestige <playerid> <1-99>");
  175.     if(ammount < 1 || ammount > 99) return SendClientMessage(playerid, -1, "ERROR: Invalid XP ammount. Number must be between 1 and 99.");
  176.     if(!IsPlayerConnected(ID))return SendClientMessage(playerid,-1,"ERROR: Player is not connected.");
  177.     {
  178.         GetPlayerName(ID,TargetName,MAX_PLAYER_NAME);
  179.         GetPlayerName(playerid,PlayerName, MAX_PLAYER_NAME);
  180.                 format(str, sizeof(str), "%s Has given you %d prestige", PlayerName, ammount);
  181.         SendClientMessage(ID, -1, str);
  182.                 format(str, sizeof(str), "You have given you %s %d prestiges", TargetName, ammount);
  183.         SendClientMessage(playerid, -1, str);
  184.                 rInfo[ID][prestige] += ammount;
  185.         }
  186.         return 1;
  187. }
  188.  
  189. CMD:resetrank(playerid, params[])
  190. {
  191.         new ID, TargetName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128];
  192.         if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "ERROR: You need to be an admin to use this command!");
  193.         if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "USAGE: /resetrank <playerid>");
  194.     if(!IsPlayerConnected(ID))return SendClientMessage(playerid,-1,"ERROR: Player is not connected.");
  195.     {
  196.         GetPlayerName(ID,TargetName,MAX_PLAYER_NAME);
  197.         GetPlayerName(playerid,PlayerName, MAX_PLAYER_NAME);
  198.                 format(str, sizeof(str), "%s Has rest your rank", PlayerName);
  199.         SendClientMessage(ID, -1, str);
  200.                 format(str, sizeof(str), "You have rest %s's Rank", TargetName);
  201.         SendClientMessage(playerid, -1, str);
  202.         rInfo[ID][xp] = 0;
  203.         rInfo[ID][level] = 0;
  204.                 rInfo[ID][prestige] = 0;
  205.         }
  206.         return 1;
  207. }
  208.  
  209. //Example of usages of xp/levels/prestige
  210. CMD:veh(playerid, params[])
  211. {
  212.         if(rInfo[playerid][prestige] < 1) return SendClientMessage(playerid, -1, "You need to be Prestige level 1");
  213.         {
  214.                 new Float:x,Float:y,Float:z, Float:a,veh;
  215.                 GetPlayerPos(playerid,x,y,z);
  216.                 GetPlayerFacingAngle(playerid, a);
  217.                 veh = CreateVehicle(402,x,y,z,a,-1,-1,-1);
  218.                 PutPlayerInVehicle(playerid,veh,0);
  219.         }
  220.         return 1;
  221. }
RAW Paste Data
Top