[Include] [INC] Rank/Level System [Version 2.0]
#1

Rank/Level System
What is it:
With this include you can give players ranks.
There are several ways a player can promote.
You can let players have restrictions or permissions depending on their rank.

Ok, so in what ways can a player promote?
PromotionModes:

Promotionmode 0 = Players can only promote with SetPlayerRank(playerid, rankID);
Promotionmode 1 = Players will promote depending on their time (hours) spend online in the server
Promotionmode 2 = Players will promote depending on their number of people they killed.
Promotionmode 3 = Players will promote depending on their amount of cash (in dollars)
Promotionmode 4 = Players will promote depending on their number of visits to your server
Promotionmode 5 = Players will promote depending on their score

How to instal:
- Download Ranks.inc
- Create in your 'scriptfiles'-folder a new folder called 'PlayerFiles' (Note the cApS!!)
- Place on top of your gamemode:
Code:
#include <Ranks>
- Put in your OnPlayerConnect(playerid)-callback the following line:
Code:
S_OnPlayerConnect(playerid);
- Put in your OnPlayerDisconnect(playerid, reason)-callback the following line:
Code:
S_OnPlayerDisconnect(playerid);
- Put in your OnPlayerSpawn(playerid)-callback the following line:
Code:
S_OnPlayerSpawn(playerid);
- Put in your OnPlayerDeath(playerid, killerid, reason)-callback the following line:
Code:
S_OnPlayerDeath(killerid);
Now you can configure some ranks:

Put in your OnGameModeInit-callback the following line:
Code:
SetPromotionMode(0-5);
Use 1 of the 6 diffrent modes.

To add a new rank put in your OnGameModeInit-callback:
Code:
AddRank(rankID, const Name[], Requirement, Startmoney, Float:SpawnHealth, Float:SpawnArmour, SpawnWeapon, SpawnAmmo);
  • rankID: This is the ID of the new rank. Always use a new ID and do not skip an ID!!
  • const Name[]: This will be the name of the new Rank
  • Requirement:
    If your promotionmode is '0', it does't matter what you fill in there.
    If your promotionmode is '1', your have fill in the number of hours the player must play on your server.
    If your promotionmode is '2', your have fill in the number of kills the player must have to promote
    If your promotionmode is '3, your have fill in the amout of dollars the player at least must have
    If your promotionmode is '4', your have fill in the number of visits
    If your promotionmode is '5', your have fill in the score a player must at least must have
  • StartMoney: If the player connects to your server, he/she will recieve this amout of cash
  • SpawnHealth: The player will spawn with this amount of health (1-100)
  • SpawnArmour: The player will spawn with this amount of armour (1-100)
  • SpawnWeapon: When the player spawns, he/she will recieve this weapon (fill in weaponID)
  • SpawnAmmo: The amount of bullets for the SpawnWeapon
Example:
Code:
SetPromotionMode(2);
AddRank(0, "Noob", 0, 5000, 25.0, 0, 0, 0);
AddRank(1, "Newbie", 2, 7500, 50.0, 25.0, 24, 100);
AddRank(2, "Professional", 10, 10000, 75.0, 50.0, 31, 500);
AddRank(3, "Pwner", 20, 15000, 100.0, 100.0, 38, 2000);
Other Functions:
  • GetPlayerRank(playerid); Returns the rank of a player
  • SetPlayerRank(playerid, rankID); Change the players rank
  • GetRankInfo(playerid); Will show ingame info about his/her current Rank
  • GetPlayerStats(playerid); Will show ingame some stats of the player
  • ResetPlayerStats(playerid); Needs no further explanation
For every player a new file will be created. In there some stats will get saved.
You can do an IP-check to prevent people joining on someone elses name and f*uck up their stats.
Risk of IP-check: If the IP of a 'fair' players has been changed, his/hers stats will not get saved anymore!
To toggle this IP-check on/off use:
  • ToggleIpCheck(toggle); (Default = Off)
Commands you can use. (Put these in your gamemode):
Code:
if(strcmp(cmd, "/rankinfo", true) == 0)
{
  GetRankInfo(playerid);
  return 1;
}

if(strcmp(cmd, "/mystats", true) == 0)
{
  GetPlayerStats(playerid);
  return 1;
}
You can also create commands which only players with for example rank 3 can use:
Code:
if(strcmp(cmdtext, "/command", true)==0)
{
  if(GetPlayerRank(playerid) == 3)
  {
    //rest of command
  }
  else
  {
    SendClientMessage(playerid, 0xFF0000AA, "Sorry, this command is only for players with rank 3");
  }
  return 1;
}
Screens:







Update History:
[Version 1.0]:
  • First Release
[Version 2.0]:
  • Added PromotionMode '0' (player can only promote manually with SetPlayerRank)
  • Added SetPlayerRank(playerid, rankID);
Download:

[Version 2.0]:
- Ranks.inc (MediaFire)
- Ranks.inc (SendSpace)
- Ranks.inc (myfreefilehosting.com)

[Version 1.0]:
- Ranks.inc (MediaFire)

You also need dini.inc, dutils.inc and dudb.inc
If you don't have these includes, download this .rar file: (Credits to Dracoblue ofcourse )
- DiniIncludes.rar (Mediafire)

Notes:

- This Include checks only once a minute if a player is ready for promotion!
So if for example a player exeeds the required kills for promotion, he/she might promote 50 seconds later.

- Only use SetPlayerRank when PromotionMode is set to '0'!!!!

- If you're going to use this in your server, please give me credits.
- If you find any bugs, please report them here.

Have fun with it

=>Sandra<=



Reply
#2

:O i thought it would never come true.... you made another inc which is brilliant!

nice job sandra, keep them coming


DEFINETLY gonna use this
Reply
#3

blewert, it's an include not a filterscript
Reply
#4

Quote:
Originally Posted by Marcel
blewert, it's an include not a filterscript
oops, still good though

PS:edited
Reply
#5

Can you only use 1 promotionmode like SetPromotion(1); or more?
Cuz i want like the visit thing as promotion and kills, that possible?
Reply
#6

Thank you very much

I also added an example how you can make commands for a specific rank only

Example:

Code:
if(strcmp(cmdtext, "/command", true)==0)
{
  if(GetPlayerRank(playerid) == 3)
  {
    //rest of command
  }
  else
  {
    SendClientMessage(playerid, 0xFF0000AA, "Sorry, this command is only for players with rank 3");
  }
  return 1;
}
@ Rks, at the moment only 1 mode at a time
Reply
#7

Quote:
Originally Posted by =>Sandra<=
Thank you very much

I also added an example how you can make commands for a specific rank only

Example:

Code:
if(strcmp(cmdtext, "/command", true)==0)
{
  if(GetPlayerRank(playerid) == 3)
  {
    //rest of command
  }
  else
  {
    SendClientMessage(playerid, 0xFF0000AA, "Sorry, this command is only for players with rank 3");
  }
  return 1;
}
@ Rks, at the moment only 1 mode at a time
Sorry for offtopicness but happy 500th post
Reply
#8

Lol, thanks :P
Reply
#9

Im getting these errors

Code:
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2372) : warning 235: public function lacks forward declaration (symbol "S_OnPlayerConnect")
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2373) : error 021: symbol already defined: "S_OnPlayerConnect"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2594) : warning 235: public function lacks forward declaration (symbol "S_OnPlayerDisconnect")
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2594) : error 025: function heading differs from prototype
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2595) : error 021: symbol already defined: "S_OnPlayerDisconnect"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2746) : warning 235: public function lacks forward declaration (symbol "S_OnPlayerDeath")
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2746) : error 025: function heading differs from prototype
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2747) : error 021: symbol already defined: "S_OnPlayerDeath"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(3260) : warning 235: public function lacks forward declaration (symbol "S_OnPlayerSpawn")
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(3261) : error 021: symbol already defined: "S_OnPlayerSpawn"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6221) : error 047: array sizes do not match, or destination array is too small
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6222) : error 047: array sizes do not match, or destination array is too small
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6689) : error 017: undefined symbol "rankID"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6689) : error 029: invalid expression, assumed zero
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6689) : error 017: undefined symbol "Name"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(6689) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply
#10

Nice Very Usefull , Thanks

Regards,

Rasim
Reply
#11

@Aroma,

You properbly already have functions called
S_OnPlayerConnect
S_OnPlayerDisconnect
S_OnPlayerSpawn
and S_OnPlayerDeath
Reply
#12

nice.
Reply
#13

Quote:
Originally Posted by =>Sandra<=
@Aroma,

You properbly already have functions called
S_OnPlayerConnect
S_OnPlayerDisconnect
S_OnPlayerSpawn
and S_OnPlayerDeath
No i have it called public OnPlayerConnect
Reply
#14

[size=12pt] well =>Sandra<= i can't believe you are doing Such as beatiful [fs] Thx a lot Sandra THX
i have to ask you something are you a GIRL?? becouse you are GREAT on [FS] if yes well i Never seen something Like That
BtW:: Nice work On all th [fs] Keep Up =>Sandra<= be the Best Cya
Reply
#15

wow this is another excellent INC.
Reply
#16

Hey i got a question, i want multiples lvles, this is for my RPG server, also for the beginning, somthing like 30 lvles, how do i do it then?
Reply
#17

I already gave an example in the first post:

Код:
SetPromotionMode(2);
AddRank(0, "Noob", 0, 5000, 25.0, 0, 0, 0);
AddRank(1, "Newbie", 2, 7500, 50.0, 25.0, 24, 100);
AddRank(2, "Professional", 10, 10000, 75.0, 50.0, 31, 500);
AddRank(3, "Pwner", 20, 15000, 100.0, 100.0, 38, 2000);
You can add as many as you want.
Reply
#18

Ok thanks, but do u have a SetPlayerLevel command? also to remove/set a lvl to a player, this is for the admins..
Reply
#19

Sry for so many questions, but heres an other

In my server i have that TAB, shows the players money as score, how can i do that so it shows player rank/lvl?
Reply
#20

I made a new version:

I added:

PromotionMode '0'
With this mode, players can only promote manually with SetPlayerRank(playerid, rankID);

SetPlayerRank(playerid, rankID);
With this function you can promote a player manually

Note: Only use SetPlayerRank when PromotionMode is set to '0'!!!!


Quote:
Originally Posted by Binebik
Sry for so many questions, but heres an other

In my server i have that TAB, shows the players money as score, how can i do that so it shows player rank/lvl?
You can add this in your Gamemode:

@ OnGameModeInit():
Код:
SetTimer("UpdateScores", 10000, 1);
And somewhere else in your script (for example at the bottom of the script):
Код:
forward UpdateScores();
public UpdateScores()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      SetPlayerScore(i, GetPlayerRank(i));
    }
  }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)