//xp.txt //By: J3ff Hoogland //Contact: blue_starsoar@yahoo.com //Homepage: www.dndsource.net //ES Homepage: mattie.info/cs/ //Is run when the mod is loaded block load { es_xset usr 0 //Checks to see if the keygroup is already there es_xexists usr keygroup xp //False means it is not there ifx false(usr) do { //If it is not there load it es_xkeygroupload xp "|xp" } else do { //If it is there delete the current copy and load the saved one es_xkeygroupdelete xp es_xkeygroupload xp "|xp" } //Sets values for xp given when scoring a kill, and a level interval xp es_xset killxp 50 es_xset hsxp 35 es_xset knifexp 80 es_xset lvlint 250 } //Happens when a player joins the server event player_activate { es_xset steam 0 //Checks to see if the user already has a key in the keygroup es_exists steam key xp event_var(es_steamid) ifx false(steam) do { //If there is no key there with the steamid create it es_keycreate xp event_var(es_steamid) //Sets the defualt for the user's level and xp es_keysetvalue xp event_var(es_steamid) xp 0 es_keysetvalue xp event_var(es_steamid) level 1 } } //Runs every time a user dies event player_death { //Checks to make sure the victim's team is not the same as the killer's team if (event_var(es_usersteam) != event_var(es_attackerteam)) do { es_xset curxp 0 //Gets the user's current xp es_keygetvalue curxp xp event_var(es_attackersteamid) xp //Adds the killxp value to the user's current xp and tells the user they gained xp es_math curxp + server_var(killxp) es_tell event_var(attacker) #green You have gained server_var(killxp) xp for scoring a kill! //Checks to see if the kill was a head shot if (event_var(headshot) == 1) do { //If headshot = true the add the hsxp value and tell the user it happened es_math curxp + server_var(hsxp) es_tell event_var(attacker) #green You have gained server_var(hsxp) xp for scoring a headshot! } //Checks to see if the kill was a scored with a knife if (event_var(weapon) == knife) do { //If knife = true add the knifexp value and tell the user es_math curxp + server_var(knifexp) es_tell event_var(attacker) #green You have gained server_var(knifexp) xp for scoring a knife kill! } //Stores the new value of the user's xp es_keysetvalue xp event_var(es_attackersteamid) xp server_var(curxp) //Store the user's id and steam to server_vars so the check level block checks the correct user es_set id event_var(attacker) es_set steam event_var(es_attackersteamid) //Runs a block that checks if a user has enough xp to 'lvl up' es_xdoblock xp/checklevel } } //A block that checks if a user has enough 'xp' to gain a 'level' block checklevel { es_xset curxp 0 //Gets the user's current xp es_keygetvalue curxp xp server_var(steam) xp es_xset curlvl 0 //Gets the user's current level es_keygetvalue curlvl xp server_var(steam) level //Use a math statement to create the xp value needed for a user to advance a 'level' //Set the xp need = to the level interval es_set xpneeded server_var(lvlint) //Then multiply that value times the user's current level es_math xpneeded * server_var(curlvl) //Checks to see if the user's current xp is >= the xp needed to advance in level ifx parse("curxp >= xpneeded") do { //if true level the user up //Step 1. Minus the xp needed from the current xp es_math curxp - server_var(curlvl) //Store the remaining xp es_keysetvalue xp server_var(steam) xp server_var(curxp) //Add one to the user's level es_xmath curlvl + 1 //Store the user's new level es_keysetvalue xp server_var(steam) level server_var(curlvl) //Tell the user they leveled up es_tell server_var(id) #lightgreen You have advanced to :evel: server_var(curlvl) } } //Runs every time a rounds ends in the server event round_end { //Save the keygroup containing user's xp at the end of each round es_xkeygroupsave xp "|xp" //Wipe that keygroup from memory es_xkeygroupdelete xp //Reload that keygroup into memory es_xkeygroupload xp "|xp" } //Runs when ever somthing is tpyed into chat event player_say { //Checks to see if the user typed !xp to see how much xp they have! if (event_var(text) == !xp) do { es_xset curxp 0 es_xset curlvl 0 //Gets the user's current level and xp es_keygetvalue curxp xp event_var(es_steamid) xp es_keygetvalue curlvl xp event_var(es_steamid) level //creates the value needed to level based off of the user's level and the server_var(lvlint) es_math curlvl * server_var(lvlint) //Tell the user how much xp they have and how much they need to 'level up' es_tell event_var(userid) You have server_var(curxp) Xp, You will gain a level at server_var(curlvl) Xp! } }