Advertisement
Garey

asdfxp

Apr 14th, 2019
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 27.74 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <colorchat>
  4. #include <nvault>
  5. #include <cstrike>
  6. #include <hamsandwich>
  7. #include <fakemeta>
  8. #include <engine>
  9. #include <time>
  10. #include <fun>
  11. #include <experience-system>
  12.  
  13. #define PLUGIN "Experience System"
  14. #define VERSION "1.0"
  15. #define AUTHOR "Some Bastard"
  16.  
  17. #define MAX_EXPERIENCE 45
  18. #define MAX_PLAYERS 32
  19. #define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
  20.  
  21. #define nvault_clear(%1) nvault_prune(%1, 0, get_systime() + 1)
  22.  
  23. new g_iDamage[ MAX_PLAYERS +1 ][ MAX_PLAYERS +1 ]
  24.  
  25. const ASSIST_MINIMUM_DAMAGE = 50
  26.  
  27. new const szExperience[MAX_EXPERIENCE] = {
  28.     0,
  29.     100,
  30.     250,
  31.     450,
  32.     600,
  33.     850,
  34.     1150,
  35.     1400,
  36.     1750,
  37.     2000,
  38.     2250,
  39.     2500,
  40.     2800,
  41.     3100,
  42.     3500,
  43.     3900,
  44.     4250,
  45.     4600,
  46.     5000,
  47.     5500,
  48.     6000,
  49.     6500,
  50.     7000,
  51.     7500,
  52.     8000,
  53.     8500,
  54.     9000,
  55.     9500,
  56.     10000,
  57.     11000,
  58.     12000,
  59.     13000,
  60.     14000,
  61.     15000,
  62.     16000,
  63.     17500,
  64.     19000,
  65.     20500,
  66.     22000,
  67.     23500,
  68.     25000,
  69.     27500,
  70.     30000,
  71.     35000,
  72.     40000
  73. }
  74.  
  75.  
  76. new const Prefix[MAX_EXPERIENCE][] = {
  77.     "Newbie",
  78.     "Rookie",
  79.     "Player",
  80.     "Small Timer",
  81.     "Lower Grade",
  82.     "Medium Grade",
  83.     "Upper Grade",
  84.     "Jumper",
  85.     "Knifer",
  86.     "Machine",
  87.     "Fine",
  88.     "Good",
  89.     "Nice",
  90.     "Pro",
  91.     "God",
  92.     "Head Buster",
  93.     "Freak",
  94.     "Psycho",
  95.     "Backstabber",
  96.     "Respected Skills",
  97.     "Confiremd Gamer",
  98.     "Trapped",
  99.     "Monster",
  100.     "Untouchable",
  101.     "Unstoppable",
  102.     "Incredible",
  103.     "Everlasting",
  104.     "Elusive",
  105.     "No Way Out",
  106.     "Master",
  107.     "Experienced",
  108.     "Specialist",
  109.     "Proffesional",
  110.     "Awesome",
  111.     "Skills",
  112.     "Tricker",
  113.     "Respected",
  114.     "Fantastic",
  115.     "Commander",
  116.     "Amazing",
  117.     "Sensational",
  118.     "Dictator",
  119.     "Royal Executor",
  120.     "TheOneAndOnly",
  121.     "Playmaker"
  122. }
  123.  
  124. new iPlayerLevel[33]
  125. new iPlayerXP[33]
  126. new szPrefix[33]
  127. new g_ConnectTime[MAX_PLAYERS + 1 ]
  128. new g_Entity
  129.  
  130. new pKill
  131. new pHeadShot
  132. new pSurvive
  133. new pSuicide
  134. new pLadder
  135. new pAirshot
  136. new pWater
  137. new pNinja
  138. new pStealth
  139. new pWin
  140. new pAssist
  141. new pPrefix
  142. new gVault
  143. new SayText
  144.  
  145. new g_szSteamId[MAX_PLAYERS+1][32]
  146. new g_iLastPlayedTime[MAX_PLAYERS+1]
  147.  
  148. get_user_total_playtime( id )
  149. {
  150.     return g_iLastPlayedTime[id] + get_user_time(id)
  151. }
  152.  
  153. public plugin_natives()
  154. {
  155.     register_library("experience-system")
  156.     register_native("give_user_experience", "native_give_user_xp")
  157. }
  158.  
  159. public plugin_init()
  160. {
  161.     register_plugin(PLUGIN, VERSION, AUTHOR)
  162.     register_clcmd("say", "HandleSay")
  163.     register_clcmd("say_team", "HandleSayTeam")
  164.     register_forward(FM_ClientKill,"KillCommand")
  165.  
  166.    
  167.     pKill         = register_cvar("xp_kill", "4")
  168.     pHeadShot     = register_cvar("xp_headshot", "6")
  169.     pSurvive    = register_cvar("xp_survive", "2")
  170.     pSuicide    = register_cvar("xp_suicide", "8")
  171.     pLadder        = register_cvar("xp_ladder", "3")
  172.     pAirshot    = register_cvar("xp_airshot", "5")
  173.     pWater        = register_cvar("xp_water", "5")
  174.     pNinja        = register_cvar("xp_ninja", "7")
  175.     pStealth    = register_cvar("xp_stealth", "2")
  176.     pAssist        = register_cvar("xp_assist", "1")
  177.     pWin        = register_cvar("xp_win", "2")
  178.     pPrefix        = register_cvar("xp_prefix", "Prefix")
  179.    
  180.     register_event("DeathMsg", "eDeath", "a")
  181.     register_message(get_user_msgid("TextMsg"),    "msgTextMsg");  
  182.    
  183.     RegisterHam( Ham_Spawn, "player", "CPlayer__Spawn_Post", .Post = 1 );
  184.     RegisterHam( Ham_Killed, "player", "CPlayer__Killed_Post", .Post = 1 );
  185.     RegisterHam( Ham_TakeDamage, "player", "CPlayer__TakeDamage_Pre", .Post = 0 );
  186.    
  187.     g_Entity = create_entity("info_target");
  188.     entity_set_string(g_Entity, EV_SZ_classname, "ThinkingEnt");
  189.     register_think("ThinkingEnt", "EntityThink");
  190.    
  191.     entity_set_float(g_Entity, EV_FL_nextthink, (get_gametime() + 1.0));
  192.     get_pcvar_string(pPrefix, szPrefix, charsmax(szPrefix))
  193.    
  194.     nvault_open("experience-system")
  195.     SayText = get_user_msgid ("SayText")
  196.    
  197.     register_message(SayText, "MsgDuplicate")
  198.     register_dictionary("time.txt")
  199. }
  200.  
  201. //////////////
  202. //PLAYTIME////
  203. //////////////
  204.  
  205. public EntityThink(iEntity)
  206. {
  207.     new iCurrentTime = get_systime();
  208.     new iPlayers[MAX_PLAYERS] , iNum;
  209.  
  210.     get_players(iPlayers, iNum);
  211.  
  212.     for(new i = 0, id; i < iNum; i++)
  213.     {
  214.         id = iPlayers[i];
  215.  
  216.         if((iCurrentTime - g_ConnectTime[id]) == 300)
  217.         {
  218.             iPlayerXP[id] += 2
  219.             ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 5^x03 minutes and gained^x04 2^x03 experience!", szPrefix);
  220.         }
  221.  
  222.         if((iCurrentTime - g_ConnectTime[id]) == 600)
  223.         {
  224.             iPlayerXP[id] += 5
  225.             ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 10^x03 minutes and gained^x04 5^x03 experience!", szPrefix);
  226.         }
  227.  
  228.         if((iCurrentTime - g_ConnectTime[id]) == 1200)
  229.         {
  230.             iPlayerXP[id] += 10
  231.             ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 20^x03 minutes and gained^x04 10^x03 experience!", szPrefix);
  232.         }
  233.        
  234.         if((iCurrentTime - g_ConnectTime[id]) == 3600)
  235.         {
  236.             iPlayerXP[id] += 30
  237.             ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have played for^x04 1^x03 hour and gained^x04 30^x03 experience!", szPrefix);
  238.         }
  239.     }
  240.  
  241.     entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  242. }
  243.  
  244. //////////////
  245. //ASSIST//////
  246. //////////////
  247.  
  248. public CPlayer__Spawn_Post( iPlayer )
  249. {
  250.     if( !is_user_alive( iPlayer ) )
  251.         return;
  252.    
  253.     for( new pPlayer = 1; pPlayer <= MAX_PLAYERS; pPlayer++ )
  254.         g_iDamage[ iPlayer ][ pPlayer ] = 0;
  255. }
  256.  
  257. public CPlayer__Killed_Post( iVictim, iAttacker, iGib )
  258. {
  259.     if( iVictim == iAttacker || !is_user_connected( iVictim ) || !is_user_connected( iAttacker ) )
  260.         return;
  261.    
  262.     new iAssistPlayer = 0;
  263.     new iAssistDamage = 0;
  264.    
  265.     for( new pPlayer = 1; pPlayer <= MAX_PLAYERS; pPlayer++ )
  266.     {
  267.         if( pPlayer != iAttacker && g_iDamage[ pPlayer ][ iVictim ] >= ASSIST_MINIMUM_DAMAGE && g_iDamage[ pPlayer ][ iVictim ] > iAssistDamage )
  268.         {
  269.             iAssistPlayer = pPlayer;
  270.             iAssistDamage = g_iDamage[ pPlayer ][ iVictim ];
  271.         }
  272.         g_iDamage[ pPlayer ][ iVictim ] = 0;
  273.     }
  274.    
  275.     if( iAssistPlayer > 0 && iAssistDamage > ASSIST_MINIMUM_DAMAGE )
  276.     {
  277.         static name[32];
  278.         get_user_name(iVictim, name, 31)
  279.         if(is_user_in_party(iAssistPlayer))
  280.         {
  281.             iPlayerXP[iAssistPlayer] += get_pcvar_num(pAssist) * 1.5
  282.             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)
  283.         } else {
  284.             iPlayerXP[iAssistPlayer] += get_pcvar_num(pAssist)
  285.             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))
  286.         }
  287.     }
  288. }
  289.  
  290. public CPlayer__TakeDamage_Pre( iVictim, iInflictor, iAttacker, Float: flDamage )
  291. {
  292.     if( iVictim == iAttacker || !is_user_connected( iAttacker ) || !is_user_connected( iVictim ) )
  293.         return;
  294.    
  295.     g_iDamage[ iAttacker ][ iVictim ] += floatround( flDamage );
  296. }
  297.  
  298. //////////////
  299. //ASSIST//////
  300. //////////////
  301.  
  302. public msgTextMsg()
  303. {
  304.     static textmsg[22]
  305.     get_msg_arg_string(2, textmsg, 21)
  306.    
  307.     //T Win
  308.     if(equal(textmsg, "#Terrorists_Win"))
  309.     {
  310.         for(new id = 1; id <= get_maxplayers(); id++)
  311.         {
  312.             if(is_user_connected(id) && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
  313.             {
  314.                 if(is_user_in_party(id))
  315.                 {
  316.                     iPlayerXP[id] += get_pcvar_num(pSurvive) * 1.5;
  317.                     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)
  318.                 } else {
  319.                     iPlayerXP[id] += get_pcvar_num(pSurvive);
  320.                     ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You survived and earned ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pSurvive))
  321.                 }
  322.             }
  323.         }
  324.     }else if(equal(textmsg, "#CTs_Win"))
  325.     {
  326.         for(new id = 1; id <= get_maxplayers(); id++)
  327.         {
  328.             if(is_user_connected(id) && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
  329.             {
  330.                 if(is_user_in_party(id))
  331.                 {
  332.                     iPlayerXP[id] += get_pcvar_num(pWin) * 1.5
  333.                     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)
  334.                 } else {
  335.                     iPlayerXP[id] += get_pcvar_num(pWin)
  336.                     ColorChat(id, NORMAL, "[^x04%s^x01] ^x03You won the round and earned ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pWin))
  337.                 }
  338.             }
  339.         }
  340.     }
  341.    
  342.     return PLUGIN_CONTINUE
  343. }
  344.  
  345. public MsgDuplicate(id)
  346. {
  347.     return PLUGIN_HANDLED
  348. }
  349.  
  350. public HandleSay(id) {
  351.     new arg[192], szName[32], target[32]
  352.     static argv[36]
  353.    
  354.     read_args(arg, charsmax(arg))
  355.     read_argv(1, argv, charsmax(argv))
  356.     get_user_name(id, szName, charsmax(szName))
  357.     parse(argv, argv, charsmax(argv), target, charsmax(target))
  358.    
  359.     remove_quotes(arg)
  360.    
  361.     if(equali(argv, "/time")) {
  362.         if(!target[0]) {
  363.             Cmd_ShowPlayTime(id)
  364.         } else {
  365.             new targetName = cmd_target(id, target, 2)
  366.             if(targetName) {
  367.                 displayPlayTime(id, targetName)
  368.             } else {
  369.                 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)
  370.             }
  371.         }
  372.        
  373.         return PLUGIN_HANDLED
  374.     }
  375.    
  376.     if(equali(argv, "/xp"))
  377.     {
  378.         if(!target[0])
  379.         {
  380.             ExperienceMenu(id)
  381.         } else {
  382.             new targetName = cmd_target(id, target, 2)
  383.             if(targetName) {
  384.                 displayExperience(id, targetName)
  385.             } else {
  386.                 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)
  387.             }
  388.         }
  389.     }
  390.    
  391.     if(cs_get_user_team(id) == CS_TEAM_T && is_user_admin(id))
  392.     {
  393.         ColorChat(0, NORMAL, "^x01[^x04 Hiders ^x01] [^x04%s^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  394.     }else if(cs_get_user_team(id) == CS_TEAM_CT && is_user_admin(id))
  395.     {
  396.         ColorChat(0, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  397.     }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR && is_user_admin(id))
  398.     {
  399.         ColorChat(0, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] [^x04 Admin ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  400.     }else if(cs_get_user_team(id) == CS_TEAM_T)
  401.     {
  402.         ColorChat(0, NORMAL, "^x01[^x04 Hiders ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  403.     }else if(cs_get_user_team(id) == CS_TEAM_CT)
  404.     {
  405.         ColorChat(0, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  406.     }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
  407.     {
  408.         ColorChat(0, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  409.     }
  410.    
  411.     return PLUGIN_CONTINUE
  412. }
  413.  
  414. public HandleSayTeam(id) {
  415.     new arg[192], szName[32], target[32]
  416.     static argv[36]
  417.    
  418.     read_args(arg, charsmax(arg))
  419.     read_argv(1, argv, charsmax(argv))
  420.     get_user_name(id, szName, charsmax(szName))
  421.     parse(argv, argv, charsmax(argv), target, charsmax(target))
  422.    
  423.     remove_quotes(arg)
  424.     for(new iPlayer = 1; iPlayer < get_maxplayers(); iPlayer++)
  425.     {
  426.         if(is_user_connected(iPlayer))
  427.         {
  428.             if(cs_get_user_team(iPlayer) == cs_get_user_team(id))
  429.             {
  430.                 if(cs_get_user_team(id) == CS_TEAM_T && is_user_admin(id))
  431.                 {
  432.                     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)
  433.                 }else if(cs_get_user_team(id) == CS_TEAM_CT && is_user_admin(id))
  434.                 {
  435.                     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)
  436.                 }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR && is_user_admin(id))
  437.                 {
  438.                     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)
  439.                 }else if(cs_get_user_team(id) == CS_TEAM_T)
  440.                 {
  441.                     ColorChat(iPlayer, NORMAL, "^x01[^x04 Hiders ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  442.                 }else if(cs_get_user_team(id) == CS_TEAM_CT)
  443.                 {
  444.                     ColorChat(iPlayer, NORMAL, "^x01[^x04 Seekers ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  445.                 }else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
  446.                 {
  447.                     ColorChat(iPlayer, NORMAL, "^x01[^x04 Spectators ^x01] [^x04 %s ^x01] (^x03 Team ^x01) ^x03%s^x01: ^x04%s", Prefix[iPlayerLevel[id]], szName, arg)
  448.                 }    
  449.             } else {
  450.                 return PLUGIN_HANDLED
  451.             }
  452.         }
  453.     }
  454.     return PLUGIN_CONTINUE
  455. }
  456.  
  457. public Cmd_ShowPlayTime(id) {
  458.     new szTime[128], cszTime[128]
  459.     new iCurrentTime = get_systime();
  460.     get_time_length(id, get_user_total_playtime(id), timeunit_seconds, szTime, charsmax(szTime))
  461.     get_time_length(id, iCurrentTime - g_ConnectTime[id], timeunit_seconds, cszTime, charsmax(cszTime))
  462.    
  463.     ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03Your current session^x01:^x04 %s", szPrefix, cszTime)
  464.     ColorChat(id, GREEN, "^x01[^x04%s^x01] ^x03Total played time on the server^x01:^x04 %s", szPrefix, szTime)
  465. }
  466.  
  467. public displayPlayTime(id, target) {
  468.     new name[32], szTime[128], cszTime[128]
  469.     new iCurrentTime = get_systime();
  470.     get_user_name(target, name, sizeof(name) - 1);
  471.     get_time_length(target, get_user_total_playtime(target), timeunit_seconds, szTime, charsmax(szTime))
  472.     get_time_length(target, iCurrentTime - g_ConnectTime[target], timeunit_seconds, cszTime, charsmax(cszTime))
  473.    
  474.     ColorChat(id, GREEN, "^x01[^x04%s^x01]^x01 Current session of^x03 %s^x01:^x04 %s", szPrefix, name, cszTime)
  475.     ColorChat(id, GREEN, "^x01[^x04%s^x01]^x01 Total played time on the server of^x03 %s^x01:^x04 %s", szPrefix, name, szTime)
  476. }
  477.  
  478. public displayExperience(id, target)  
  479. {
  480.     new szName[32]
  481.     get_user_name(target, szName, charsmax(szName))
  482.    
  483.     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])
  484. }
  485.  
  486. public ExperienceMenu(id)
  487. {
  488.     new szTemp[2500], szName[33]; get_user_name(id, szName, charsmax(szName))
  489.    
  490.     new szTime[128], cszTime[128]
  491.     new iCurrentTime = get_systime();
  492.     get_time_length(id, get_user_total_playtime(id), timeunit_seconds, szTime, charsmax(szTime))
  493.     get_time_length(id, iCurrentTime - g_ConnectTime[id], timeunit_seconds, cszTime, charsmax(cszTime))
  494.    
  495.     if(iPlayerLevel[id] != MAX_EXPERIENCE - 1) {
  496.             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 ]" : "")
  497.     } else {
  498.         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 ]" : "")
  499.     }
  500.  
  501.     new menu = menu_create(szTemp, "menu_handler")
  502.     menu_additem(menu, "", "1")
  503.     menu_display(id, menu)
  504. }
  505.  
  506. public menu_handler(id, menu, item) {
  507.     if(item == MENU_EXIT) {
  508.         menu_destroy(menu)
  509.         return PLUGIN_HANDLED
  510.     }
  511.    
  512.     switch(item) {
  513.         case 0:
  514.         {
  515.             menu_destroy(menu)
  516.             return PLUGIN_HANDLED
  517.         }
  518.     }
  519.    
  520.     return PLUGIN_CONTINUE
  521. }
  522.  
  523. public eDeath()
  524. {
  525.     new Attacker = read_data(1)
  526.     new Victim = read_data(2)
  527.     new Headshot = read_data(3)
  528.     new Killer[32]
  529.     new buttons, velocity
  530.    
  531.     read_data(4, Killer, 31)
  532.    
  533.     if(equal(Killer, "worldspawn"))
  534.     {
  535.         if(iPlayerXP[Victim] - get_pcvar_num(pSuicide) < 0)
  536.         {
  537.             ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You cannot lose more experience!", szPrefix)
  538.         }else
  539.         {
  540.             iPlayerXP[Victim] -= get_pcvar_num(pSuicide)
  541.            
  542.             if(iPlayerXP[Victim] < szExperience[iPlayerLevel[Victim]])
  543.             {
  544.                 iPlayerLevel[Victim]--
  545.                 ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04-%i^x03 experience and fell ^x04one^x03 level!", szPrefix, get_pcvar_num(pSuicide))
  546.             }else
  547.                 ColorChat(Victim, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04-%i^x03 experience!", szPrefix, get_pcvar_num(pSuicide))
  548.         }
  549.     }
  550.    
  551.     if(Attacker == 0)
  552.         return PLUGIN_HANDLED
  553.        
  554.     if(Victim == 0)
  555.         return PLUGIN_HANDLED
  556.        
  557.     if(Headshot) {
  558.         if(is_user_in_party(id))
  559.         {
  560.             iPlayerXP[Attacker] += get_pcvar_num(pHeadShot) * 1.5
  561.             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);
  562.         } else {
  563.             iPlayerXP[Attacker] += get_pcvar_num(pHeadShot)
  564.             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));
  565.         }
  566.     }
  567.    
  568.     if(IsOnLadder(Victim) && IsOnLadder(Attacker)) {
  569.         if(is_user_in_party(id))
  570.         {
  571.             iPlayerXP[Attacker] += get_pcvar_num(pLadder) * 1.5
  572.             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);
  573.         } else {
  574.             iPlayerXP[Attacker] += get_pcvar_num(pLadder)
  575.             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));
  576.         }
  577.     }
  578.    
  579.     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))
  580.     {    
  581.         if(is_user_in_party(id))
  582.         {
  583.             iPlayerXP[Attacker] += get_pcvar_num(pAirshot) * 1.5
  584.             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);
  585.         } else {
  586.             iPlayerXP[Attacker] += get_pcvar_num(pAirshot)
  587.             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));
  588.         }
  589.     }
  590.    
  591.     if((pev(Attacker, pev_flags) & FL_INWATER) && (pev(Victim, pev_flags) & FL_INWATER))
  592.     {
  593.         if(is_user_in_party(id))
  594.         {
  595.             iPlayerXP[Attacker] += get_pcvar_num(pWater) * 1.5
  596.             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);
  597.         } else {
  598.             iPlayerXP[Attacker] += get_pcvar_num(pWater)
  599.             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));
  600.         }
  601.     }
  602.    
  603.     if((!(pev(Attacker, pev_flags) & FL_ONGROUND) && !IsOnLadder(Attacker)) && (!IsOnLadder(Victim) && (pev(Victim, pev_flags) & FL_ONGROUND)) && (distance_to_ground(Attacker) > 70.0))
  604.     {
  605.         if(is_user_in_party(Attacker))
  606.         {
  607.             iPlayerXP[Attacker] += get_pcvar_num(pNinja) * 1.5
  608.             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;
  609.         } else {
  610.             iPlayerXP[Attacker] += get_pcvar_num(pNinja)
  611.             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));
  612.         }
  613.     }
  614.    
  615.     buttons = pev(Attacker, pev_button)
  616.     pev(Attacker, pev_velocity, velocity)
  617.    
  618.     if((buttons&IN_RUN || buttons&IN_DUCK) && ((pev(Attacker, pev_flags) & FL_ONGROUND) && (pev(Victim, pev_flags) & FL_ONGROUND)))
  619.     {
  620.         if(is_user_in_party(Attacker))
  621.         {
  622.             iPlayerXP[Attacker] += get_pcvar_num(pStealth) * 1.5
  623.             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);
  624.         } else {
  625.             iPlayerXP[Attacker] += get_pcvar_num(pStealth)
  626.             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));
  627.         }
  628.     }
  629.    
  630.     if(!Headshot)
  631.     {
  632.         if(is_user_in_party(Attacker))
  633.         {
  634.             iPlayerXP[Attacker] += get_pcvar_num(pKill) * 1.5
  635.             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);
  636.         } else {
  637.             iPlayerXP[Attacker] += get_pcvar_num(pKill)
  638.             ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 You have killed a player and earned ^x04+%i^x03 experience!", szPrefix, get_pcvar_num(pKill));
  639.         }
  640.     }
  641.     if(iPlayerLevel[Attacker] != 44)
  642.     {
  643.         while(iPlayerXP[Attacker] >= szExperience[iPlayerLevel[Attacker] + 1]) {
  644.             iPlayerLevel[Attacker]++
  645.             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]);
  646.             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])
  647.         }
  648.     }else {
  649.         ColorChat(Attacker, NORMAL, "^x01[^x04%s^x01]^x03 Congratulations! You have reached the^x04 maximum^x03 level.", szPrefix);
  650.     }
  651.    
  652.     SaveData(Attacker)
  653.     return PLUGIN_CONTINUE
  654. }
  655.  
  656.  
  657. public KillCommand(id)
  658. {
  659.     if(iPlayerXP[id] - get_pcvar_num(pSuicide) < 0)
  660.         {
  661.             ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You cannot lose more experience!", szPrefix)
  662.         }else
  663.         {
  664.             iPlayerXP[id] -= get_pcvar_num(pSuicide)
  665.            
  666.             if(iPlayerXP[id] < szExperience[iPlayerLevel[id]])
  667.             {
  668.                 iPlayerLevel[id]--
  669.                 ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04%i^x03 experience and fell ^x04one^x03 level!", szPrefix, get_pcvar_num(pSuicide))
  670.             }else
  671.                 ColorChat(id, NORMAL, "^x01[^x04%s^x01] ^x03You have lost ^x04%i^x03 experience!", szPrefix, get_pcvar_num(pSuicide))
  672.         }
  673.  
  674.     return FMRES_SUPERCEDE
  675. }
  676.  
  677. public client_disconnect(id)
  678. {
  679.     SaveData(id)
  680.     new szTime[32]
  681.     formatex(szTime, charsmax(szTime), "%d", get_user_total_playtime( id ))
  682.     nvault_set(gVault, g_szSteamId[id], szTime)
  683. }
  684.  
  685. public client_connect(id)
  686. {
  687.     LoadData(id)
  688. }
  689.  
  690. public SaveData(id)
  691. {
  692.     new SteamID[32]
  693.     get_user_authid(id, SteamID, charsmax(SteamID))
  694.    
  695.     new vaultkey[64], vaultdata[256]
  696.    
  697.     format(vaultkey, charsmax(vaultkey), "%s-experiencesystem", SteamID)
  698.     format(vaultdata, charsmax(vaultdata), "%i#%i#", iPlayerXP[id], iPlayerLevel[id])
  699.     nvault_set(gVault, vaultkey, vaultdata)
  700.     return PLUGIN_CONTINUE
  701. }
  702.  
  703. public LoadData(id)
  704. {
  705.     new SteamID[32]
  706.     get_user_authid(id, SteamID, charsmax(SteamID))
  707.    
  708.     new vaultkey[64], vaultdata[256]
  709.    
  710.     format(vaultkey, charsmax(vaultkey), "%s-experiencesystem", SteamID)
  711.     format(vaultdata, charsmax(vaultdata), "%i#%i#", iPlayerXP[id], iPlayerLevel[id])
  712.     nvault_get(gVault, vaultkey, vaultdata, charsmax(vaultdata))
  713.    
  714.     replace_all(vaultdata, charsmax(vaultdata), "#", " ")
  715.    
  716.     new xp[32], level[32]
  717.    
  718.     parse(vaultdata, xp, charsmax(xp), level, charsmax(level))
  719.    
  720.     iPlayerXP[id] = str_to_num(xp)
  721.     iPlayerLevel[id] = str_to_num(level)
  722.    
  723.     return PLUGIN_CONTINUE
  724. }
  725.  
  726. public client_authorized(id)
  727. {
  728.     get_user_authid(id, g_szSteamId[id], charsmax(g_szSteamId[]))
  729.    
  730.     new szTime[32]
  731.     nvault_get(gVault, g_szSteamId[id], szTime, charsmax(szTime))
  732.     g_iLastPlayedTime[id] = str_to_num(szTime)
  733.     g_ConnectTime[id] = get_systime();
  734. }
  735.  
  736. public native_give_user_xp(iPlugins, iParams)
  737. {
  738.     if(iParams != 1)
  739.         return PLUGIN_CONTINUE
  740.        
  741.     new id = get_param(1)
  742.    
  743.     if(!id)
  744.         return PLUGIN_HANDLED
  745.    
  746.     new amount = get_param(2)
  747.    
  748.     is_user_in_party(id) ? iPlayerXP[id] += amount * 1.5 : iPlayerXP[id] += amount
  749.    
  750.     return PLUGIN_CONTINUE
  751. }
  752.  
  753.  
  754. stock Float:distance_to_ground( id )
  755. {
  756.     new Float:start[3], Float:end[3];
  757.     entity_get_vector(id, EV_VEC_origin, start);
  758.     if( entity_get_int(id, EV_INT_flags) & FL_DUCKING )
  759.     {
  760.         start[2] += 18.0;
  761.     }
  762.  
  763.     end[0] = start[0];
  764.     end[1] = start[1];
  765.     end[2] = start[2] - 9999.0;
  766.  
  767.     new ptr = create_tr2();
  768.     engfunc(EngFunc_TraceHull, start, end, IGNORE_MONSTERS, HULL_HUMAN, id, ptr);
  769.     new Float:fraction;
  770.     get_tr2(ptr, TR_flFraction, fraction);
  771.     free_tr2(ptr);
  772.  
  773.     return fraction * 9999.0;
  774. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement