Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <colorchat>
- #include <nvault>
- #include <cstrike>
- #include <hamsandwich>
- #include <fakemeta>
- #include <engine>
- #include <time>
- #include <fun>
- #include <experience-system>
- #define PLUGIN "Experience System"
- #define VERSION "1.0"
- #define AUTHOR "Some Bastard"
- #define MAX_EXPERIENCE 45
- #define MAX_PLAYERS 32
- #define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
- #define nvault_clear(%1) nvault_prune(%1, 0, get_systime() + 1)
- new g_iDamage[ MAX_PLAYERS +1 ][ MAX_PLAYERS +1 ]
- const ASSIST_MINIMUM_DAMAGE = 50
- new const szExperience[MAX_EXPERIENCE] = {
- 0,
- 100,
- 250,
- 450,
- 600,
- 850,
- 1150,
- 1400,
- 1750,
- 2000,
- 2250,
- 2500,
- 2800,
- 3100,
- 3500,
- 3900,
- 4250,
- 4600,
- 5000,
- 5500,
- 6000,
- 6500,
- 7000,
- 7500,
- 8000,
- 8500,
- 9000,
- 9500,
- 10000,
- 11000,
- 12000,
- 13000,
- 14000,
- 15000,
- 16000,
- 17500,
- 19000,
- 20500,
- 22000,
- 23500,
- 25000,
- 27500,
- 30000,
- 35000,
- 40000
- }
- new const Prefix[MAX_EXPERIENCE][] = {
- "Newbie",
- "Rookie",
- "Player",
- "Small Timer",
- "Lower Grade",
- "Medium Grade",
- "Upper Grade",
- "Jumper",
- "Knifer",
- "Machine",
- "Fine",
- "Good",
- "Nice",
- "Pro",
- "God",
- "Head Buster",
- "Freak",
- "Psycho",
- "Backstabber",
- "Respected Skills",
- "Confiremd Gamer",
- "Trapped",
- "Monster",
- "Untouchable",
- "Unstoppable",
- "Incredible",
- "Everlasting",
- "Elusive",
- "No Way Out",
- "Master",
- "Experienced",
- "Specialist",
- "Proffesional",
- "Awesome",
- "Skills",
- "Tricker",
- "Respected",
- "Fantastic",
- "Commander",
- "Amazing",
- "Sensational",
- "Dictator",
- "Royal Executor",
- "TheOneAndOnly",
- "Playmaker"
- }
- new iPlayerLevel[33]
- new iPlayerXP[33]
- new szPrefix[33]
- new g_ConnectTime[MAX_PLAYERS + 1 ]
- new g_Entity
- new pKill
- new pHeadShot
- new pSurvive
- new pSuicide
- new pLadder
- new pAirshot
- new pWater
- new pNinja
- new pStealth
- new pWin
- new pAssist
- new pPrefix
- new gVault
- new SayText
- new g_szSteamId[MAX_PLAYERS+1][32]
- new g_iLastPlayedTime[MAX_PLAYERS+1]
- get_user_total_playtime( id )
- {
- return g_iLastPlayedTime[id] + get_user_time(id)
- }
- public plugin_natives()
- {
- register_library("experience-system")
- register_native("give_user_experience", "native_give_user_xp")
- }
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("say", "HandleSay")
- register_clcmd("say_team", "HandleSayTeam")
- register_forward(FM_ClientKill,"KillCommand")
- pKill = register_cvar("xp_kill", "4")
- pHeadShot = register_cvar("xp_headshot", "6")
- pSurvive = register_cvar("xp_survive", "2")
- pSuicide = register_cvar("xp_suicide", "8")
- pLadder = register_cvar("xp_ladder", "3")
- pAirshot = register_cvar("xp_airshot", "5")
- pWater = register_cvar("xp_water", "5")
- pNinja = register_cvar("xp_ninja", "7")
- pStealth = register_cvar("xp_stealth", "2")
- pAssist = register_cvar("xp_assist", "1")
- pWin = register_cvar("xp_win", "2")
- pPrefix = register_cvar("xp_prefix", "Prefix")
- register_event("DeathMsg", "eDeath", "a")
- register_message(get_user_msgid("TextMsg"), "msgTextMsg");
- RegisterHam( Ham_Spawn, "player", "CPlayer__Spawn_Post", .Post = 1 );
- RegisterHam( Ham_Killed, "player", "CPlayer__Killed_Post", .Post = 1 );
- RegisterHam( Ham_TakeDamage, "player", "CPlayer__TakeDamage_Pre", .Post = 0 );
- g_Entity = create_entity("info_target");
- entity_set_string(g_Entity, EV_SZ_classname, "ThinkingEnt");
- register_think("ThinkingEnt", "EntityThink");
- entity_set_float(g_Entity, EV_FL_nextthink, (get_gametime() + 1.0));
- get_pcvar_string(pPrefix, szPrefix, charsmax(szPrefix))
- nvault_open("experience-system")
- SayText = get_user_msgid ("SayText")
- register_message(SayText, "MsgDuplicate")
- register_dictionary("time.txt")
- }
- //////////////
- //PLAYTIME////
- //////////////
- public EntityThink(iEntity)
- {
- new iCurrentTime = get_systime();
- new iPlayers[MAX_PLAYERS] , iNum;
- get_players(iPlayers, iNum);
- for(new i = 0, id; i < iNum; i++)
- {
- id = iPlayers[i];
- if((iCurrentTime - g_ConnectTime[id]) == 300)
- {
- iPlayerXP[id] += 2
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 5^x03 minutes and gained^x04 2^x03 experience!", szPrefix);
- }
- if((iCurrentTime - g_ConnectTime[id]) == 600)
- {
- iPlayerXP[id] += 5
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 10^x03 minutes and gained^x04 5^x03 experience!", szPrefix);
- }
- if((iCurrentTime - g_ConnectTime[id]) == 1200)
- {
- iPlayerXP[id] += 10
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 20^x03 minutes and gained^x04 10^x03 experience!", szPrefix);
- }
- if((iCurrentTime - g_ConnectTime[id]) == 3600)
- {
- iPlayerXP[id] += 30
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 1^x03 hour and gained^x04 30^x03 experience!", szPrefix);
- }
- }
- entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
- }
- //////////////
- //ASSIST//////
- //////////////
- public CPlayer__Spawn_Post( iPlayer )
- {
- if( !is_user_alive( iPlayer ) )
- return;
- for( new pPlayer = 1; pPlayer <= MAX_PLAYERS; pPlayer++ )
- g_iDamage[ iPlayer ][ pPlayer ] = 0;
- }
- public CPlayer__Killed_Post( iVictim, iAttacker, iGib )
- {
- if( iVictim == iAttacker || !is_user_connected( iVictim ) || !is_user_connected( iAttacker ) )
- return;
- new iAssistPlayer = 0;
- new iAssistDamage = 0;
- for( new pPlayer = 1; pPlayer <= MAX_PLAYERS; pPlayer++ )
- {
- if( pPlayer != iAttacker && g_iDamage[ pPlayer ][ iVictim ] >= ASSIST_MINIMUM_DAMAGE && g_iDamage[ pPlayer ][ iVictim ] > iAssistDamage )
- {
- iAssistPlayer = pPlayer;
- iAssistDamage = g_iDamage[ pPlayer ][ iVictim ];
- }
- g_iDamage[ pPlayer ][ iVictim ] = 0;
- }
- if( iAssistPlayer > 0 && iAssistDamage > ASSIST_MINIMUM_DAMAGE )
- {
- static name[32];
- get_user_name(iVictim, name, 31)
- if(is_user_in_party(iAssistPlayer))
- {
- iPlayerXP[iAssistPlayer] += get_pcvar_num(pAssist) * 1.5
- ColorChat(iAssistPlayer, NORMAL, "[^x04%s^x01] ^x03You assisted for killing ^x04%s^x03 and earned ^x04%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, name, get_pcvar_num(pAssist), get_pcvar_num(pAssist) * 0.5)
- } else {
- iPlayerXP[iAssistPlayer] += get_pcvar_num(pAssist)
- ColorChat(iAssistPlayer, NORMAL, "[^x04%s^x01] ^x03You assisted for killing ^x04%s^x03 and earned ^x04%i^x03 experience!", szPrefix, name, get_pcvar_num(pAssist))
- }
- }
- }
- public CPlayer__TakeDamage_Pre( iVictim, iInflictor, iAttacker, Float: flDamage )
- {
- if( iVictim == iAttacker || !is_user_connected( iAttacker ) || !is_user_connected( iVictim ) )
- return;
- g_iDamage[ iAttacker ][ iVictim ] += floatround( flDamage );
- }
- //////////////
- //ASSIST//////
- //////////////
- public msgTextMsg()
- {
- static textmsg[22]
- get_msg_arg_string(2, textmsg, 21)
- //T Win
- if(equal(textmsg, "#Terrorists_Win"))
- {
- for(new id = 1; id <= get_maxplayers(); id++)
- {
- if(is_user_connected(id) && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
- {
- if(is_user_in_party(id))
- {
- iPlayerXP[id] += get_pcvar_num(pSurvive) * 1.5;
- ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You survived and earned ^x04%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pSurvive), get_pcvar_num(pSurvive) * 0.5)
- } else {
- iPlayerXP[id] += get_pcvar_num(pSurvive);
- ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You survived and earned ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pSurvive))
- }
- }
- }
- }else if(equal(textmsg, "#CTs_Win"))
- {
- for(new id = 1; id <= get_maxplayers(); id++)
- {
- if(is_user_connected(id) && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
- {
- if(is_user_in_party(id))
- {
- iPlayerXP[id] += get_pcvar_num(pWin) * 1.5
- ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You won the round and earned ^x04%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pWin), get_pcvar_num(pWin) * 0.5)
- } else {
- iPlayerXP[id] += get_pcvar_num(pWin)
- ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You won the round and earned ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pWin))
- }
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public MsgDuplicate(id)
- {
- return PLUGIN_HANDLED
- }
- public HandleSay(id) {
- new arg[192], szName[32], target[32]
- static argv[36]
- read_args(arg, charsmax(arg))
- read_argv(1, argv, charsmax(argv))
- get_user_name(id, szName, charsmax(szName))
- parse(argv, argv, charsmax(argv), target, charsmax(target))
- remove_quotes(arg)
- if(equali(argv, "/time")) {
- if(!target[0]) {
- Cmd_ShowPlayTime(id)
- } else {
- new targetName = cmd_target(id, target, 2)
- if(targetName) {
- displayPlayTime(id, targetName)
- } else {
- ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03There is no player with that name OR multiple players with that name: '^x04 %s^x03 '", szPrefix, target)
- }
- }
- return PLUGIN_HANDLED
- }
- if(equali(argv, "/xp"))
- {
- if(!target[0])
- {
- ExperienceMenu(id)
- } else {
- new targetName = cmd_target(id, target, 2)
- if(targetName) {
- displayExperience(id, targetName)
- } else {
- ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03There is no player with that name OR multiple players with that name: '^x04 %s^x03 '", szPrefix, target)
- }
- }
- }
- if(cs_get_user_team(id) == CS_TEAM_T && is_user_admin(id))
- {
- ColorChat(0, NORMAL, "^x01[^x04 Hiders ^x01] [^x04%s^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_CT && is_user_admin(id))
- {
- ColorChat(0, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR && is_user_admin(id))
- {
- ColorChat(0, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_T)
- {
- ColorChat(0, NORMAL, "^x01[^x04 Hiders ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_CT)
- {
- ColorChat(0, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- {
- ColorChat(0, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }
- return PLUGIN_CONTINUE
- }
- public HandleSayTeam(id) {
- new arg[192], szName[32], target[32]
- static argv[36]
- read_args(arg, charsmax(arg))
- read_argv(1, argv, charsmax(argv))
- get_user_name(id, szName, charsmax(szName))
- parse(argv, argv, charsmax(argv), target, charsmax(target))
- remove_quotes(arg)
- for(new iPlayer = 1; iPlayer < get_maxplayers(); iPlayer++)
- {
- if(is_user_connected(iPlayer))
- {
- if(cs_get_user_team(iPlayer) == cs_get_user_team(id))
- {
- if(cs_get_user_team(id) == CS_TEAM_T && is_user_admin(id))
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Hiders ^x01] [^x04%s^x01] [^x04 Admin ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_CT && is_user_admin(id))
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR && is_user_admin(id))
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_T)
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Hiders ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_CT)
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- {
- ColorChat(iPlayer, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
- }
- } else {
- return PLUGIN_HANDLED
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public Cmd_ShowPlayTime(id) {
- new szTime[128], cszTime[128]
- new iCurrentTime = get_systime();
- get_time_length(id, get_user_total_playtime(id), timeunit_seconds, szTime, charsmax(szTime))
- get_time_length(id, iCurrentTime - g_ConnectTime[id], timeunit_seconds, cszTime, charsmax(cszTime))
- ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03Your current session^x01:^x04 %s", szPrefix, cszTime)
- ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03Total played time on the server^x01:^x04 %s", szPrefix, szTime)
- }
- public displayPlayTime(id, target) {
- new name[32], szTime[128], cszTime[128]
- new iCurrentTime = get_systime();
- get_user_name(target, name, sizeof(name) - 1);
- get_time_length(target, get_user_total_playtime(target), timeunit_seconds, szTime, charsmax(szTime))
- get_time_length(target, iCurrentTime - g_ConnectTime[target], timeunit_seconds, cszTime, charsmax(cszTime))
- ColorChat(id, GREEN, "^x01[^x04%s^x01]^x01 Current session of^x03 %s^x01:^x04 %s", szPrefix, name, cszTime)
- ColorChat(id, GREEN, "^x01[^x04%s^x01]^x01 Total played time on the server of^x03 %s^x01:^x04 %s", szPrefix, name, szTime)
- }
- public displayExperience(id, target)
- {
- new szName[32]
- get_user_name(target, szName, charsmax(szName))
- ColorChat(id, GREEN, "^x01[^x04%s^x01]^x04 %s^x03 has^x04 %i^x03 experience and is level ^x04%i^x03!", szPrefix, szName, iPlayerXP[target], iPlayerLevel[target])
- }
- public ExperienceMenu(id)
- {
- new szTemp[2500], szName[33]; get_user_name(id, szName, charsmax(szName))
- new szTime[128], cszTime[128]
- new iCurrentTime = get_systime();
- get_time_length(id, get_user_total_playtime(id), timeunit_seconds, szTime, charsmax(szTime))
- get_time_length(id, iCurrentTime - g_ConnectTime[id], timeunit_seconds, cszTime, charsmax(cszTime))
- if(iPlayerLevel[id] != MAX_EXPERIENCE - 1) {
- formatex(szTemp, charsmax(szTemp), "Experience \y[ \w%i\w / \r%i\w / Left: \d%i\y ]^n\wLevel: [ \y%i\w / \r%i\w ]^n\wYour Rank: \r%s^n^nNickname: \d%s^n\wThis session playtime: \y%s^n\wTotal played time: \y%s^n^n\wParty: \r%s^n\wExperience Multiplier:\r %s^n%s^n", iPlayerXP[id], szExperience[iPlayerLevel[id] + 1], szExperience[iPlayerLevel[id] + 1] - iPlayerXP[id], iPlayerLevel[id], MAX_EXPERIENCE - 1, Prefix[iPlayerLevel[id]], szName, cszTime, szTime, is_user_in_party(id) ? "Yes" : "No", is_user_in_party(id) ? "1.5" : "1.0", is_user_in_party(id) ? "\wParty Members \y[ \r get_party_members(id) \w/ get_cvar_num(^"party_max_players^")\y ]" : "")
- } else {
- formatex(szTemp, charsmax(szTemp), "Experience \y[ \w%i\y ]^n\wLevel: \y[ \rMAX \y]^n\wYour Rank: \r%s^n^nNickname: \d%s^n\wThis session playtime: \y%s^n\wTotal played time: \y%s^n^n\wParty: \r%s^n\wExperience Multiplier:\r %s^n%s", iPlayerXP[id], Prefix[iPlayerLevel[id]], szName, cszTime, szTime, is_user_in_party(id) ? "Yes" : "No", is_user_in_party(id) ? "1.5" : "1.0", is_user_in_party(id) ? "\wParty Members \y[ \r get_party_members(id) \w/ get_cvar_num(^"party_max_players^")\y ]" : "")
- }
- new menu = menu_create(szTemp, "menu_handler")
- menu_additem(menu, "", "1")
- menu_display(id, menu)
- }
- public menu_handler(id, menu, item) {
- if(item == MENU_EXIT) {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- switch(item) {
- case 0:
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- }
- return PLUGIN_CONTINUE
- }
- public eDeath()
- {
- new Attacker = read_data(1)
- new Victim = read_data(2)
- new Headshot = read_data(3)
- new Killer[32]
- new buttons, velocity
- read_data(4, Killer, 31)
- if(equal(Killer, "worldspawn"))
- {
- if(iPlayerXP[Victim] - get_pcvar_num(pSuicide) < 0)
- {
- ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You cannot lose more experience!", szPrefix)
- }else
- {
- iPlayerXP[Victim] -= get_pcvar_num(pSuicide)
- if(iPlayerXP[Victim] < szExperience[iPlayerLevel[Victim]])
- {
- iPlayerLevel[Victim]--
- ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04-%i^x03 experience and fell ^x04one^x03 level!", szPrefix, get_pcvar_num(pSuicide))
- }else
- ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04-%i^x03 experience!", szPrefix, get_pcvar_num(pSuicide))
- }
- }
- if(Attacker == 0)
- return PLUGIN_HANDLED
- if(Victim == 0)
- return PLUGIN_HANDLED
- if(Headshot) {
- if(is_user_in_party(id))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pHeadShot) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player with headshot and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pHeadShot), get_pcvar_num(pHeadShot) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pHeadShot)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player with headshot and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pHeadShot));
- }
- }
- if(IsOnLadder(Victim) && IsOnLadder(Attacker)) {
- if(is_user_in_party(id))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pLadder) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player on ladder and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pLadder), get_pcvar_num(pLadder) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pLadder)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player on ladder and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pLadder));
- }
- }
- if ((!(pev(Attacker, pev_flags) & FL_ONGROUND) && !(pev(Victim, pev_flags) & FL_ONGROUND)) && ( !IsOnLadder(Victim) && !IsOnLadder(Attacker) ) && (distance_to_ground(Attacker) > 70.0 && distance_to_ground(Victim) > 70.0))
- {
- if(is_user_in_party(id))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pAirshot) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player in air and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pAirshot), get_pcvar_num(pAirshot) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pAirshot)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player in air and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pAirshot));
- }
- }
- if((pev(Attacker, pev_flags) & FL_INWATER) && (pev(Victim, pev_flags) & FL_INWATER))
- {
- if(is_user_in_party(id))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pWater) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player in air and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pWater), get_pcvar_num(pWater) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pWater)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player in air and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pWater));
- }
- }
- if((!(pev(Attacker, pev_flags) & FL_ONGROUND) && !IsOnLadder(Attacker)) && (!IsOnLadder(Victim) && (pev(Victim, pev_flags) & FL_ONGROUND)) && (distance_to_ground(Attacker) > 70.0))
- {
- if(is_user_in_party(Attacker))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pNinja) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player like a ninja and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pNinja), get_pcvar_num(pNinja) * 0.5;
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pNinja)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player like a ninja and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pNinja));
- }
- }
- buttons = pev(Attacker, pev_button)
- pev(Attacker, pev_velocity, velocity)
- if((buttons&IN_RUN || buttons&IN_DUCK) && ((pev(Attacker, pev_flags) & FL_ONGROUND) && (pev(Victim, pev_flags) & FL_ONGROUND)))
- {
- if(is_user_in_party(Attacker))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pStealth) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player silently and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pStealth), get_pcvar_num(pStealth) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pStealth)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player silently and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pStealth), get_pcvar_num(pStealth));
- }
- }
- if(!Headshot)
- {
- if(is_user_in_party(Attacker))
- {
- iPlayerXP[Attacker] += get_pcvar_num(pKill) * 1.5
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player and earned ^x04+%i^x03 experience! ^x04(Party bonus: ^x03 %i^x04)", szPrefix, get_pcvar_num(pKill), get_pcvar_num(pKill) * 0.5);
- } else {
- iPlayerXP[Attacker] += get_pcvar_num(pKill)
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pKill));
- }
- }
- if(iPlayerLevel[Attacker] != 44)
- {
- while(iPlayerXP[Attacker] >= szExperience[iPlayerLevel[Attacker] + 1]) {
- iPlayerLevel[Attacker]++
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 Congratulations! You are now level ^x04%i ^x03with ^x04%i^x03 experience.", szPrefix, iPlayerLevel[Attacker], iPlayerXP[Attacker]);
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 The experience left until the next level is ^x04%i", szPrefix, szExperience[iPlayerLevel[Attacker] + 1] - iPlayerXP[Attacker])
- }
- }else {
- ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 Congratulations! You have reached the^x04 maximum^x03 level.", szPrefix);
- }
- SaveData(Attacker)
- return PLUGIN_CONTINUE
- }
- public KillCommand(id)
- {
- if(iPlayerXP[id] - get_pcvar_num(pSuicide) < 0)
- {
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You cannot lose more experience!", szPrefix)
- }else
- {
- iPlayerXP[id] -= get_pcvar_num(pSuicide)
- if(iPlayerXP[id] < szExperience[iPlayerLevel[id]])
- {
- iPlayerLevel[id]--
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04%i^x03 experience and fell ^x04one^x03 level!", szPrefix, get_pcvar_num(pSuicide))
- }else
- ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pSuicide))
- }
- return FMRES_SUPERCEDE
- }
- public client_disconnect(id)
- {
- SaveData(id)
- new szTime[32]
- formatex(szTime, charsmax(szTime), "%d", get_user_total_playtime( id ))
- nvault_set(gVault, g_szSteamId[id], szTime)
- }
- public client_connect(id)
- {
- LoadData(id)
- }
- public SaveData(id)
- {
- new SteamID[32]
- get_user_authid(id, SteamID, charsmax(SteamID))
- new vaultkey[64], vaultdata[256]
- format(vaultkey, charsmax(vaultkey), "%s-experiencesystem", SteamID)
- format(vaultdata, charsmax(vaultdata), "%i#%i#", iPlayerXP[id], iPlayerLevel[id])
- nvault_set(gVault, vaultkey, vaultdata)
- return PLUGIN_CONTINUE
- }
- public LoadData(id)
- {
- new SteamID[32]
- get_user_authid(id, SteamID, charsmax(SteamID))
- new vaultkey[64], vaultdata[256]
- format(vaultkey, charsmax(vaultkey), "%s-experiencesystem", SteamID)
- format(vaultdata, charsmax(vaultdata), "%i#%i#", iPlayerXP[id], iPlayerLevel[id])
- nvault_get(gVault, vaultkey, vaultdata, charsmax(vaultdata))
- replace_all(vaultdata, charsmax(vaultdata), "#", " ")
- new xp[32], level[32]
- parse(vaultdata, xp, charsmax(xp), level, charsmax(level))
- iPlayerXP[id] = str_to_num(xp)
- iPlayerLevel[id] = str_to_num(level)
- return PLUGIN_CONTINUE
- }
- public client_authorized(id)
- {
- get_user_authid(id, g_szSteamId[id], charsmax(g_szSteamId[]))
- new szTime[32]
- nvault_get(gVault, g_szSteamId[id], szTime, charsmax(szTime))
- g_iLastPlayedTime[id] = str_to_num(szTime)
- g_ConnectTime[id] = get_systime();
- }
- public native_give_user_xp(iPlugins, iParams)
- {
- if(iParams != 1)
- return PLUGIN_CONTINUE
- new id = get_param(1)
- if(!id)
- return PLUGIN_HANDLED
- new amount = get_param(2)
- is_user_in_party(id) ? iPlayerXP[id] += amount * 1.5 : iPlayerXP[id] += amount
- return PLUGIN_CONTINUE
- }
- stock Float:distance_to_ground( id )
- {
- new Float:start[3], Float:end[3];
- entity_get_vector(id, EV_VEC_origin, start);
- if( entity_get_int(id, EV_INT_flags) & FL_DUCKING )
- {
- start[2] += 18.0;
- }
- end[0] = start[0];
- end[1] = start[1];
- end[2] = start[2] - 9999.0;
- new ptr = create_tr2();
- engfunc(EngFunc_TraceHull, start, end, IGNORE_MONSTERS, HULL_HUMAN, id, ptr);
- new Float:fraction;
- get_tr2(ptr, TR_flFraction, fraction);
- free_tr2(ptr);
- return fraction * 9999.0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement