Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Array(size,value)
- local array = {}
- for i = 1, size do
- array[i]=value
- end
- return array
- end
- function totable(t,match)
- local cmd = {}
- if not match then match = "[^%s]+" end
- for word in string.gmatch(t, match) do
- table.insert(cmd, word)
- end
- return cmd
- end
- cs_exp = Array(32,0)
- cs_level = Array(32,0)
- cs_req = Array(32,0)
- function cs_msg(clr,txt)
- msg("©"..clr..""..txt)
- end
- function cs_msg2(id,clr,txt)
- msg2(id,"©"..clr..""..txt)
- end
- function SaveUser(id)
- for id = 1,32 do
- if player(id,"usgn") > 0 then
- file = io.open("sys/lua/save/"..player(id,"usgn")..".txt","w") or io.tmpfile()
- local text = ""
- text = tostring(cs_exp[id])
- text = text.." "..cs_level[id]
- file:write(text)
- file:close()
- end
- end
- end
- function LoadUser(id,file)
- local UsgnID = player(id,"usgn")
- local file = io.open("sys/lua/save/"..UsgnID..".txt","r")
- if file then
- -- cs_msg2(id,"255255000","[Server]: \169000255000Logged In as "..UsgnID.." @C")
- cs_msg2(id,"255255000","[Server]: \169000255000EXP loaded Successfully.")
- for line in file:lines() do
- local parses = totable(line)
- local userExp=tonumber(parses[1])
- if userExp ~= nil then
- cs_exp[id]= userExp
- end
- if (tonumber(parses[2])~=nil) then
- cs_level[id]=tonumber(parses[2])
- end
- end
- else
- cs_msg2(id,"255255000","[Server]: \169255255000Logged In as "..UsgnID.." @C")
- cs_msg2(id,"255255000","[Server]: \169255000000EXP loading failed.")
- end
- end
- function hudtext2(id,tid,color,txt,x,y)
- local toprint = ("©"..color.." "..txt)
- parse('hudtxt2 '..id..' '..tid..' "'..toprint..'" '..x.." "..y)
- end
- function ExpInfo(id)
- if id~=nil then
- hudtext2(id, 26,"00255000"," -Exp: "..cs_exp[id].."/"..cs_req[id].." -Level: "..cs_level[id].."/50",5,430)
- end
- end
- addhook("join","d_join")
- function d_join(id)
- cs_exp[id]=0
- cs_level[id]=1
- cs_req[id]=2000
- rp_criminal[id]=false
- rp_police[id]=false
- rp_doctor[id]=false
- rp_killer[id]=false
- parse('hudtxt2 '..id..' "30" "\169255255255-Job: NONE" "230" "430"')
- if player(id,"usgn") ~= 0 then
- LoadUser(id,file)
- end
- end
- addhook("leave","d_leave")
- function d_leave(id)
- if player(id,"usgn") ~= 0 then
- SaveUser(id)
- end
- cs_exp[id]=0
- cs_level[id]=1
- cs_req[id]=1000
- end
- addhook("minute","exp_min")
- function exp_min(id)
- for id = 1,32 do
- local UsgnID = player(id,"usgn")
- if player(id,"usgn") ~= 0 then
- if player == exist then
- SaveUser(id)
- end
- end
- end
- print("EXP Data saved.")
- end
- addhook("spawn","rv_spawn")
- function rv_spawn(id)
- ExpInfo(id)
- updatejobhud(id)
- rp_killer[id]=false
- end
- addhook("second","expsecond")
- function expsecond()
- for _,id in ipairs(player(0,"tableliving")) do
- cs_exp[id]=cs_exp[id]+1
- ExpInfo(id)
- end
- end
- addhook("ms100","d_update")
- function d_update()
- for id=1,32 do
- if player(id,'exists') then
- name = player(id,"name")
- if cs_exp[id]<=1000 then --0
- cs_level[id] = 1
- cs_req[id] = 2000
- end
- if cs_exp[id]>=2000 then --50
- cs_level[id] = 2
- cs_req[id] = 3000
- end
- if cs_exp[id]>=3000 then --60
- cs_level[id] = 3
- cs_req[id] = 4000
- end
- if cs_exp[id]>=4000 then --70
- cs_level[id] = 4
- cs_req[id] = 5000
- end
- if cs_exp[id]==5000 then
- rp_money[id]=rp_money[id]+50000
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 5 and was rewarded with 50k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- cs_exp[id]=5001
- updatehud(id)
- end
- if cs_exp[id]>=5000 then --80
- cs_level[id] = 5
- cs_req[id] = 6000
- end
- if cs_exp[id]>=6000 then --90
- cs_level[id] = 6
- cs_req[id] = 7000
- end
- if cs_exp[id]>=7000 then --100
- cs_level[id] = 7
- cs_req[id] = 8000
- end
- if cs_exp[id]>=8000 then --110
- cs_level[id] = 8
- cs_req[id] = 9000
- end
- if cs_exp[id]>=9000 then --120
- cs_level[id] = 9
- cs_req[id] = 10000
- end
- if cs_exp[id]==10000 then
- rp_money[id]=rp_money[id]+100000
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 10 and was rewarded with 100k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- cs_exp[id]=10001
- updatehud(id)
- end
- if cs_exp[id]>=10000 then --130
- cs_level[id] = 10
- cs_req[id] = 11000
- end
- if cs_exp[id]>=11000 then --140
- cs_level[id] = 11
- cs_req[id] = 12000
- end
- if cs_exp[id]>=12000 then --150
- cs_level[id] = 12
- cs_req[id] = 13000
- end
- if cs_exp[id]>=13000 then --160
- cs_level[id] = 13
- cs_req[id] = 14000
- end
- if cs_exp[id]>=14000 then --170
- cs_level[id] = 14
- cs_req[id] = 15000
- end
- if cs_exp[id]==15000 then
- rp_money[id]=rp_money[id]+150000
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 15 and was rewarded with 150k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- cs_exp[id]=15001
- updatehud(id)
- end
- if cs_exp[id]>=15000 then --180
- cs_level[id] = 15
- cs_req[id] = 16000
- end
- if cs_exp[id]>=16000 then --190
- cs_level[id] = 16
- cs_req[id] = 17000
- end
- if cs_exp[id]>=17000 then --200
- cs_level[id] = 17
- cs_req[id] = 18000
- end
- if cs_exp[id]>=18000 then --210
- cs_level[id] = 18
- cs_req[id] = 19000
- end
- if cs_exp[id]>=19000 then --220
- cs_level[id] = 19
- cs_req[id] = 20000
- end
- if cs_exp[id]==20000 then
- rp_money[id]=rp_money[id]+200000
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 20 and was rewarded with 200k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- cs_exp[id]=20001
- updatehud(id)
- end
- if cs_exp[id]>=20000 then --230
- cs_level[id] = 20
- cs_req[id] = 21000
- end
- if cs_exp[id]>=21000 then --240
- cs_level[id] = 21
- cs_req[id] = 22000
- end
- if cs_exp[id]>=22000 then --250
- cs_level[id] = 22
- cs_req[id] = 23000
- end
- if cs_exp[id]>=23000 then --260
- cs_level[id] = 23
- cs_req[id] = 24000
- end
- if cs_exp[id]>=24000 then --270
- cs_level[id] = 24
- cs_req[id] = 25000
- end
- if cs_exp[id]==25000 then
- rp_money[id]=rp_money[id]+250000
- cs_exp[id]=25001
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 25 and was rewarded with 250k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- updatehud(id)
- end
- if cs_exp[id]>=25000 then --280
- cs_level[id] = 25
- cs_req[id] = 26000
- end
- if cs_exp[id]>=26000 then
- cs_level[id] = 26
- cs_req[id] = 27000
- end
- if cs_exp[id]>=27000 then
- cs_level[id] = 27
- cs_req[id] = 28000
- end
- if cs_exp[id]>=28000 then
- cs_level[id] = 28
- cs_req[id] = 29000
- end
- if cs_exp[id]>=29000 then
- cs_level[id] = 29
- cs_req[id] = 30000
- end
- if cs_exp[id]==30000 then
- rp_money[id]=rp_money[id]+300000
- cs_exp[id]=30001
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 30 and was rewarded with 300k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- updatehud(id)
- end
- if cs_exp[id]>=30000 then
- cs_level[id] = 30
- cs_req[id] = 31000
- end
- if cs_exp[id]>=31000 then
- cs_level[id] = 31
- cs_req[id] = 32000
- end
- if cs_exp[id]>=32000 then
- cs_level[id] = 32
- cs_req[id] = 33000
- end
- if cs_exp[id]>=33000 then
- cs_level[id] = 33
- cs_req[id] = 34000
- end
- if cs_exp[id]>=34000 then
- cs_level[id] = 34
- cs_req[id] = 35000
- end
- if cs_exp[id]==35000 then
- if rp_Adminlevel[id]<= 0 then
- if rp_vip[id]<=0 then
- if rp_license[id]<=1 then
- rp_money[id]=rp_money[id]+350000
- cs_exp[id]=35001
- rp_license[id]=2
- rp_vip[id]=1
- updatehud(id)
- fname = "sys/lua/IF/vip.newext"
- file = io.open(fname, "a")
- file:write(player(id, "usgn").."\n")
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 35 and was rewarded with 350k + VIP.")
- gmsg2(id,"255255000","[Server]: \169000255000You are now a VIP User.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- updatehud(id)
- end
- end
- end
- end
- if cs_exp[id]>=35000 then
- cs_level[id] = 35
- cs_req[id] = 36000
- end
- if cs_exp[id]>=36000 then
- cs_level[id] = 36
- cs_req[id] = 37000
- end
- if cs_exp[id]>=37000 then
- cs_level[id] = 37
- cs_req[id] = 38000
- end
- if cs_exp[id]>=38000 then
- cs_level[id] = 38
- cs_req[id] = 39000
- end
- if cs_exp[id]>=39000 then
- cs_level[id] = 39
- cs_req[id] = 40000
- end
- if cs_exp[id]==40000 then
- rp_money[id]=rp_money[id]+400000
- cs_exp[id]=40001
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 40 and was rewarded with 400k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- updatehud(id)
- end
- if cs_exp[id]>=40000 then
- cs_level[id] = 40
- cs_req[id] = 41000
- end
- if cs_exp[id]>=41000 then
- cs_level[id] = 41
- cs_req[id] = 42000
- end
- if cs_exp[id]>=42000 then
- cs_level[id] = 42
- cs_req[id] = 43000
- end
- if cs_exp[id]>=43000 then
- cs_level[id] = 43
- cs_req[id] = 44000
- end
- if cs_exp[id]>=44000 then
- cs_level[id] = 44
- cs_req[id] = 45000
- end
- if cs_exp[id]==45000 then
- rp_money[id]=rp_money[id]+450000
- cs_exp[id]=45001
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 45 and was rewarded with 450k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- updatehud(id)
- end
- if cs_exp[id]>=45000 then
- cs_level[id] = 45
- cs_req[id] = 46000
- end
- if cs_exp[id]>=46000 then
- cs_level[id] = 46
- cs_req[id] = 47000
- end
- if cs_exp[id]>=47000 then
- cs_level[id] = 47
- cs_req[id] = 48000
- end
- if cs_exp[id]>=48000 then
- cs_level[id] = 48
- cs_req[id] = 49000
- end
- if cs_exp[id]>=49000 then
- cs_level[id] = 49
- cs_req[id] = 50000
- end
- if cs_exp[id]==50000 then
- rp_money[id]=rp_money[id]+500000
- cs_exp[id]=50001
- msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 50 and was rewarded with 500k.")
- parse("sv_sound2 "..id.." !7/levelup.ogg")
- end
- if cs_exp[id]>=50000 then
- cs_level[id] = 50
- cs_req[id] = 50000
- updatehud(id)
- end
- --end is here
- end
- end
- ExpInfo(id)
- end
- addhook("die", "dieded")
- function dieded(id, vid, wep, x, y)
- -- Changed nil values with 0 since CS2D doesn't send nil values
- if vid ~= 0 and id ~= 0 and id ~= vid then
- cs_exp[vid]=cs_exp[vid]-10
- cs_exp[id]=cs_exp[id]+5
- -- msg(player(id, "name").." killed "..player(vid, "name").."!")
- msg2(vid,"\169255255000[Server]: \169255000000You got killed by "..player(id, "name").." and lost 10 EXP + 1000$!")
- msg2(id,"\169255255000[Server]: \169000255000You killed "..player(vid, "name").." and gained 5 EXP + 500$!")
- rp_killer[id]=true
- rp_money[id]=rp_money[id]+200
- updatehud(id)
- if rp_money[vid]>=1000 then
- rp_money[vid]=rp_money[vid]-1000
- updatehud(vid)
- end
- if rp_criminal[id]==true then
- rp_money[id]=rp_money[id]+2000
- cs_exp[id]=cs_exp[id]+5
- msg2(id,"\169255255000[Server]: \169000255000Criminal bonus 2000$ and 10 EXP!")
- end
- if rp_criminal[vid]==true and rp_police[id]== true then
- rp_money[id]=rp_money[id]+5000
- cs_exp[id]=cs_exp[id]+20
- msg2(id,"\169255255000[Server]: \169000255000You've killed a criminal, you won 5000$ and 20 EXP!")
- end
- if rp_criminal[vid]==true then
- cs_exp[vid]=cs_exp[vid]-40
- msg2(vid,"\169255255000[Server]: \169255000000You've been killed and lost 10,000$ and 40 EXP!")
- if rp_money[vid]>=10000 then
- rp_money[vid]=rp_money[vid]-10000
- updatehud(vid)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement