Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fun>
- #include <vault>
- #define MAXCLASSES 5
- new PlayerXP[33]
- new PlayerLevel[33]
- new msgtext
- new const LEVELS[6] = {
- 100,
- 200,
- 400,
- 800,
- 1600,
- 3200
- }
- public plugin_init()
- {
- register_plugin("Animal Mod", "1.0", "Invalid")
- register_cvar("sv_animalmod", "1")
- register_event("DeathMsg", "DeathMsg", "a")
- register_cvar("xp_per_kill", "20")
- register_cvar("SaveXP", "1")
- register_event("ResetHUD", "ResetHud", "b")
- msgtext = get_user_msgid("statusText")
- register_clcmd ("say /ps", "ShowHUD")
- }
- public SaveXP(id)
- {
- new authid[32];
- get_user_authid(id,authid,31);
- new vaultkey[64], vaultdata[64];
- //Save their XP
- format(vaultkey,63,"ANIMAL-%s-xp",authid);
- format(vaultdata,63,"%d",PlayerXP[id]);
- set_vaultdata(vaultkey,vaultdata);
- //Save their level
- format(vaultkey,63,"ANIMAL-%s-level",authid);
- format(vaultdata,63,"%d",PlayerLevel[id]);
- set_vaultdata(vaultkey,vaultdata);
- }
- public LoadXP(id)
- {
- new authid[32];
- get_user_authid(id,authid,31);
- new vaultkey[64], vaultdata[64];
- //Load their XP
- format(vaultkey,63,"ANIMAL-%s-xp",authid);
- get_vaultdata(vaultkey,vaultdata,63);
- PlayerXP[id] = str_to_num(vaultdata);
- //Load their level
- format(vaultkey,63,"ANIMAL-%s-level",authid);
- get_vaultdata(vaultkey,vaultdata,63);
- PlayerLevel[id] = str_to_num(vaultdata);
- }
- public client_connect(id)
- {
- //Only load their XP if our SaveXP cvar is 1.
- if(get_cvar_num("SaveXP") == 1) {
- LoadXP(id)
- //Add a message if you want....
- client_print(id, print_chat, "[Animal Mod] XP Loaded!")
- client_print(id, print_chat, "[Animal Mod] You are level %s and %s XP", PlayerLevel[id], PlayerXP[id])
- }
- }
- public client_disconnect(id)
- {
- //Only save their XP if our SaveXP cvar is 1.
- if(get_cvar_num("SaveXP") == 1) {
- SaveXP(id)
- }
- }
- public DeathMsg() //Note that i only had (), and not (id)
- {
- //Lets check if "sv_animalmod" is on. If its off, we'll stop the function.
- if(get_cvar_num("sv_animalmod") == 0) {
- return PLUGIN_HANDLED
- }
- //Now we create a "attacker" varriable. So the XP will be given to the killer, and not all players on the server.
- new attacker = read_data(1)
- //Now the plugin will check if the attacker doesnt have a class, and if he doesnt, the function will stop.
- //Now lets see if the attacker allready has level 6, and doesnt need more XP, and if he is, stop the function.
- //You can remove this if you want, and let the player get as much XP he want. But we wont get more than level 6 anyway.
- if(PlayerLevel[attacker] == 6) {
- return PLUGIN_HANDLED
- }
- //Now we can add XP to the attacker.
- PlayerXP[attacker] += get_cvar_num("XP_per_kill") //Add the amout of XP you have on the "XP_per_kill" cvar.
- //Now we check if the attacker has enough XP for a new level. And if he has, we add it.
- if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
- //Add his level...
- PlayerLevel[attacker] += 1
- //Now you can make a "congratualtions" message if you want...
- client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])
- //Lets save his XP every time he gets a level incase the server crashes or something. So they wont loose it all.
- if(get_cvar_num("SaveXP") == 1) {
- SaveXP(attacker)
- }
- //Show His New Level on the HUD message.
- //Ill get back to this later...
- ShowHUD(attacker)
- }
- //Show new HUD if you didnt get level too. (To show the new XP)
- //Ill get back to this later...
- ShowHUD(attacker)
- return PLUGIN_CONTINUE
- }
- public ShowHUD(id)
- {
- new HUD[51]
- //This is the stuff that will actually show in game.
- format(HUD, 50, "Level: %i XP: %i", PlayerLevel[id], PlayerXP[id])
- message_begin(MSG_ONE, msgtext, {0,0,0}, id)
- write_byte(0)
- write_string(HUD)
- message_end()
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement