you had errors
Code: [Select]
//xp.txt
//By: Hyp3r
//is run when mod is loaded
block load
{
es_xset usr 0
//checks to see if the keygroup is already existent
es_xexists usr keygroup xp
//runs if it dosen't exist
ifx false(usr) do
{
//if it is not there load it
es_xkeygroupload xp "|xp"
}
//otherwise do
else do
{
//if it exists delete the current one and load the saved one
es_xkeygroupdelete xp
es_xkeygroupload xp "|xp"
}
//sets values for xp given when scroing kills and a level interval
es_xset killxp 50
es_xset Headshotxp 30
es_xset Knife 50
es_xset levelinterval 200
}
//Happens when a player joins the server
event player_activate
{
es_xset steam 0
//checks to see if player already has a key in the keygroup
es_exists steam key xp event_var(es_steamid)
// if the player dosent have a key do
ifx false(steam) do
{
//creates a key for the steamid
es_keycreate xp event_var(es_steamid)
//sets the players xp to zero and level to one
es_keysetvalue xp event_var(es_steamid) xp 0
es_keysetvalue xp event_var(es_steamid) level 1
}
}
//runs when the player dies
event player_death
{
//checks to see if the killer was not on the same team as the victim
if (event_var(es_usersteam) != event_var(es_attackerteam)) do
{
es_xset curxp 0
//gets the players current xp
es_keygetvalue curxp xp event_var(es_attackersteamid) xp
//adds the killxp value to the users current xp and tells the user they got xp
es_math curxp + server_var(killxp)
es_tell event_var(attacker) #green You have gained server_var(killxp) for scoring a kill!
//checks to see if the kill was a headshot
if (event_var(headshotxp) ==1)d do
{
//if headshot = true add headshotxp and tell the user
es_math curxp + server_var(Headshotxp)
es_tell event_var(attacker) #green You Have gained server_var(Headshotxp) for scoring a headshot
}
if (event_var(weapon) == knife) do
{
//if knife = true add the knife xp value to curxp
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 new xp value to the attackers xp
es_keysetvalue xp event_var(attackersteamid) xp server_var(curxp)
//store the users id and steamid to server variables so the check level block made later 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 gained enough xp to lvl up
es_xdoblock xp/checklevel
}
}
//do a block that checks if the user has enough xp to level up
block checklevel
{
es_xset curxp 0
//gets the users current xp
es_keygetvalue xp server_var(steam) xp
es_xset curlvl 0
//gets the users current level
es_keygetvalue curlvl xp server_var(steam) level
// use a maths statement to create the xp value needed to advance a level
//set xp needed = to the level interval
es_set xpneeded levelinterval
es_math xpneeded * server_var(curlvl)
//checks to see if the users current xp is >= to the xp needed to lvl
ifx parse("curxp >= xpneeded") do
{
//if ture level up the user
//step1. minus the xp needed from the current xp
es_math curxp - server_var(xpneeded)
//stores the remainging xp
es_keysetvalue xp server_var(steam) xp server_var(curxp)
//add one to the users lvl
es_xmath curlvl + 1
//stores the users new lvl
es_keysetvalue xp server_var(steam) level server_var(curlvl)
//tell the user they leveled up
es_tell #lightgreen You have advanced to level: server_var(curlvl)
}
es_xkeygroupsave xp "|xp"
}
//runs when something is typed into chat
event player_say
{
//checks if the user typed !xp to see howmuch xp they have
if (event_var(text) == !xp) do
{
es_xset curxp 0
es_xset curlvl 0
//gets the users 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 the users level times the levelinterval
es_math curlvl * server_var(levelinterval)
//tell the user tell the user how much xp they have and how much they need to level
es_tell event_var(userid) You have server_var(curxp) / server_var(curlvl) Xp
}
}
//runs when the mod is unloaded
block unload
{
//removes the keygroup xp from the server so it's not taking up any extra space
es_xkeygroupdelete xp
}


Logged
