18.03.2008, 20:26
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>
Code:
S_OnPlayerConnect(playerid);
Code:
S_OnPlayerDisconnect(playerid);
Code:
S_OnPlayerSpawn(playerid);
Code:
S_OnPlayerDeath(killerid);
Put in your OnGameModeInit-callback the following line:
Code:
SetPromotionMode(0-5);
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
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);
- 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
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)
Code:
if(strcmp(cmd, "/rankinfo", true) == 0) { GetRankInfo(playerid); return 1; } if(strcmp(cmd, "/mystats", true) == 0) { GetPlayerStats(playerid); return 1; }
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; }
Update History:
[Version 1.0]:
- First Release
- Added PromotionMode '0' (player can only promote manually with SetPlayerRank)
- Added SetPlayerRank(playerid, rankID);
[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<=