Advertisement
Guest User

Untitled

a guest
Dec 27th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.11 KB | None | 0 0
  1. function Array(size,value)
  2.      local array = {}
  3.      for i = 1, size do
  4.           array[i]=value
  5.      end
  6.      return array
  7. end
  8.  
  9. function totable(t,match)
  10.      local cmd = {}
  11.      if not match then match = "[^%s]+" end
  12.      for word in string.gmatch(t, match) do
  13.           table.insert(cmd, word)
  14.      end
  15.      return cmd
  16. end
  17.  
  18. cs_exp   = Array(32,0)
  19. cs_level = Array(32,0)
  20. cs_req   = Array(32,0)
  21.  
  22. function cs_msg(clr,txt)
  23.      msg("©"..clr..""..txt)
  24. end
  25.  
  26. function cs_msg2(id,clr,txt)
  27.      msg2(id,"©"..clr..""..txt)
  28. end
  29.  
  30. function SaveUser(id)
  31.     for id = 1,32 do
  32.         if player(id,"usgn") > 0 then
  33.             file = io.open("sys/lua/save/"..player(id,"usgn")..".txt","w") or io.tmpfile()
  34.             local text = ""
  35.             text = tostring(cs_exp[id])
  36.             text = text.." "..cs_level[id]
  37.             file:write(text)
  38.             file:close()
  39.         end
  40.     end
  41. end
  42.  
  43. function LoadUser(id,file)
  44.      local UsgnID = player(id,"usgn")
  45.      local file = io.open("sys/lua/save/"..UsgnID..".txt","r")
  46.      if file then
  47. --          cs_msg2(id,"255255000","[Server]: \169000255000Logged In as "..UsgnID.." @C")
  48.           cs_msg2(id,"255255000","[Server]: \169000255000EXP loaded Successfully.")
  49.           for line in file:lines() do
  50.           local parses = totable(line)
  51.             local userExp=tonumber(parses[1])
  52.           if userExp ~= nil then
  53.              cs_exp[id]= userExp
  54.           end
  55.           if (tonumber(parses[2])~=nil) then
  56.              cs_level[id]=tonumber(parses[2])
  57.           end
  58.           end
  59.      else
  60.           cs_msg2(id,"255255000","[Server]: \169255255000Logged In as "..UsgnID.." @C")
  61.           cs_msg2(id,"255255000","[Server]: \169255000000EXP loading failed.")
  62.      end
  63. end
  64.  
  65. function hudtext2(id,tid,color,txt,x,y)
  66.      local toprint = ("©"..color.." "..txt)
  67.      parse('hudtxt2 '..id..' '..tid..' "'..toprint..'" '..x.." "..y)
  68. end
  69.  
  70. function ExpInfo(id)
  71.      if id~=nil then
  72.           hudtext2(id, 26,"00255000"," -Exp: "..cs_exp[id].."/"..cs_req[id].."  -Level: "..cs_level[id].."/50",5,430)
  73.      end
  74. end
  75.  
  76. addhook("join","d_join")
  77. function d_join(id)
  78.     cs_exp[id]=0
  79.     cs_level[id]=1
  80.     cs_req[id]=2000
  81.     rp_criminal[id]=false
  82.     rp_police[id]=false
  83.     rp_doctor[id]=false
  84.     rp_killer[id]=false
  85.     parse('hudtxt2 '..id..' "30" "\169255255255-Job: NONE" "230" "430"')
  86.     if player(id,"usgn") ~= 0 then
  87.         LoadUser(id,file)
  88.     end
  89. end
  90.  
  91. addhook("leave","d_leave")
  92. function d_leave(id)
  93.     if player(id,"usgn") ~= 0 then
  94.         SaveUser(id)
  95.     end
  96.     cs_exp[id]=0
  97.     cs_level[id]=1
  98.     cs_req[id]=1000
  99. end
  100.  
  101. addhook("minute","exp_min")
  102. function exp_min(id)
  103.     for id = 1,32 do
  104.     local UsgnID = player(id,"usgn")
  105.         if player(id,"usgn") ~= 0 then
  106.             if player == exist then
  107.                 SaveUser(id)
  108.             end
  109.         end
  110.     end
  111. print("EXP Data saved.")
  112. end
  113.  
  114. addhook("spawn","rv_spawn")
  115. function rv_spawn(id)
  116.     ExpInfo(id)
  117.     updatejobhud(id)
  118.     rp_killer[id]=false
  119. end
  120.  
  121. addhook("second","expsecond")
  122. function expsecond()
  123. for _,id in ipairs(player(0,"tableliving")) do
  124. cs_exp[id]=cs_exp[id]+1
  125. ExpInfo(id)
  126. end
  127. end
  128.  
  129. addhook("ms100","d_update")
  130. function d_update()
  131. for id=1,32 do
  132.           if player(id,'exists') then
  133.           name = player(id,"name")
  134.                if cs_exp[id]<=1000 then --0
  135.                     cs_level[id] = 1
  136.                     cs_req[id] = 2000
  137.                end
  138.                if cs_exp[id]>=2000 then --50
  139.                     cs_level[id] = 2
  140.                     cs_req[id] = 3000
  141.                end
  142.                if cs_exp[id]>=3000 then --60
  143.                     cs_level[id] = 3
  144.                     cs_req[id] = 4000
  145.                end
  146.                if cs_exp[id]>=4000 then --70
  147.                     cs_level[id] = 4
  148.                     cs_req[id] = 5000
  149.                end
  150.                
  151.                         if cs_exp[id]==5000 then
  152.                         rp_money[id]=rp_money[id]+50000
  153.                         msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 5 and was rewarded with 50k.")
  154.                         parse("sv_sound2 "..id.." !7/levelup.ogg")
  155.                         cs_exp[id]=5001
  156.                         updatehud(id)
  157.                 end
  158.                
  159.                if cs_exp[id]>=5000 then --80
  160.                     cs_level[id] = 5
  161.                     cs_req[id] = 6000
  162.                end
  163.                if cs_exp[id]>=6000 then --90
  164.                     cs_level[id] = 6
  165.                     cs_req[id] = 7000
  166.                end
  167.                if cs_exp[id]>=7000 then --100
  168.                     cs_level[id] = 7
  169.                     cs_req[id] = 8000
  170.                end
  171.                if cs_exp[id]>=8000 then --110
  172.                     cs_level[id] = 8
  173.                     cs_req[id] = 9000
  174.                end
  175.                if cs_exp[id]>=9000 then --120
  176.                     cs_level[id] = 9
  177.                     cs_req[id] = 10000
  178.                end
  179.                
  180.                            if cs_exp[id]==10000 then
  181.                            rp_money[id]=rp_money[id]+100000
  182.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 10 and was rewarded with 100k.")
  183.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  184.                            cs_exp[id]=10001
  185.                         updatehud(id)
  186.                            end
  187.                
  188.                if cs_exp[id]>=10000 then --130
  189.                     cs_level[id] = 10
  190.                     cs_req[id] = 11000
  191.                end
  192.                if cs_exp[id]>=11000 then --140
  193.                     cs_level[id] = 11
  194.                     cs_req[id] = 12000
  195.                end
  196.                if cs_exp[id]>=12000 then --150
  197.                     cs_level[id] = 12
  198.                     cs_req[id] = 13000
  199.                end
  200.                if cs_exp[id]>=13000 then --160
  201.                     cs_level[id] = 13
  202.                     cs_req[id] = 14000
  203.                end
  204.                if cs_exp[id]>=14000 then --170
  205.                     cs_level[id] = 14
  206.                     cs_req[id] = 15000
  207.                end
  208.                
  209.                            if cs_exp[id]==15000 then
  210.                            rp_money[id]=rp_money[id]+150000
  211.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 15 and was rewarded with 150k.")
  212.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  213.                            cs_exp[id]=15001
  214.                         updatehud(id)
  215.                            end
  216.                
  217.                if cs_exp[id]>=15000 then --180
  218.                     cs_level[id] = 15
  219.                     cs_req[id] = 16000
  220.                end
  221.                if cs_exp[id]>=16000 then --190
  222.                     cs_level[id] = 16
  223.                     cs_req[id] = 17000
  224.                end
  225.                if cs_exp[id]>=17000 then --200
  226.                     cs_level[id] = 17
  227.                     cs_req[id] = 18000
  228.                end
  229.                if cs_exp[id]>=18000 then --210
  230.                     cs_level[id] = 18
  231.                     cs_req[id] = 19000
  232.                end
  233.                if cs_exp[id]>=19000 then --220
  234.                     cs_level[id] = 19
  235.                     cs_req[id] = 20000
  236.                end
  237.                
  238.                            if cs_exp[id]==20000 then
  239.                            rp_money[id]=rp_money[id]+200000
  240.                             msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 20 and was rewarded with 200k.")
  241.                             parse("sv_sound2 "..id.." !7/levelup.ogg")
  242.                            cs_exp[id]=20001
  243.                         updatehud(id)
  244.                            end
  245.                
  246.                if cs_exp[id]>=20000 then --230
  247.                     cs_level[id] = 20
  248.                     cs_req[id] = 21000
  249.                end
  250.                if cs_exp[id]>=21000 then --240
  251.                     cs_level[id] = 21
  252.                     cs_req[id] = 22000
  253.                end
  254.                if cs_exp[id]>=22000 then --250
  255.                     cs_level[id] = 22
  256.                     cs_req[id] = 23000
  257.                end
  258.                if cs_exp[id]>=23000 then --260
  259.                     cs_level[id] = 23
  260.                     cs_req[id] = 24000
  261.                end
  262.                if cs_exp[id]>=24000 then --270
  263.                     cs_level[id] = 24
  264.                     cs_req[id] = 25000
  265.                end
  266.                if cs_exp[id]==25000 then
  267.                rp_money[id]=rp_money[id]+250000
  268.                     cs_exp[id]=25001
  269.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 25 and was rewarded with 250k.")
  270.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  271.                         updatehud(id)
  272.                 end
  273.                if cs_exp[id]>=25000 then --280
  274.                     cs_level[id] = 25
  275.                     cs_req[id] = 26000
  276.                end
  277.                
  278.                if cs_exp[id]>=26000 then
  279.                     cs_level[id] = 26
  280.                     cs_req[id] = 27000
  281.                end
  282.                if cs_exp[id]>=27000 then
  283.                     cs_level[id] = 27
  284.                     cs_req[id] = 28000
  285.                end              
  286.                if cs_exp[id]>=28000 then
  287.                     cs_level[id] = 28
  288.                     cs_req[id] = 29000
  289.                end        
  290.                if cs_exp[id]>=29000 then
  291.                     cs_level[id] = 29
  292.                     cs_req[id] = 30000
  293.                end    
  294.                if cs_exp[id]==30000 then
  295.                rp_money[id]=rp_money[id]+300000
  296.                     cs_exp[id]=30001
  297.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 30 and was rewarded with 300k.")
  298.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  299.                         updatehud(id)
  300.                 end
  301.                if cs_exp[id]>=30000 then
  302.                     cs_level[id] = 30
  303.                     cs_req[id] = 31000
  304.                end          
  305.                if cs_exp[id]>=31000 then
  306.                     cs_level[id] = 31
  307.                     cs_req[id] = 32000
  308.                end            
  309.                if cs_exp[id]>=32000 then
  310.                     cs_level[id] = 32
  311.                     cs_req[id] = 33000
  312.                end            
  313.                if cs_exp[id]>=33000 then
  314.                     cs_level[id] = 33
  315.                     cs_req[id] = 34000
  316.                end          
  317.                if cs_exp[id]>=34000 then
  318.                     cs_level[id] = 34
  319.                     cs_req[id] = 35000
  320.                end    
  321.                if cs_exp[id]==35000 then
  322.                     if rp_Adminlevel[id]<= 0 then
  323.                         if rp_vip[id]<=0 then
  324.                             if rp_license[id]<=1 then
  325.                                 rp_money[id]=rp_money[id]+350000
  326.                                 cs_exp[id]=35001
  327.                                 rp_license[id]=2
  328.                                 rp_vip[id]=1
  329.                                 updatehud(id)
  330.                                 fname = "sys/lua/IF/vip.newext"
  331.                                 file = io.open(fname, "a")
  332.                                 file:write(player(id, "usgn").."\n")
  333.                                 msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 35 and was rewarded with 350k + VIP.")
  334.                                 gmsg2(id,"255255000","[Server]: \169000255000You are now a VIP User.")
  335.                                 parse("sv_sound2 "..id.." !7/levelup.ogg")
  336.                                 updatehud(id)
  337.                             end
  338.                         end
  339.                     end
  340.                 end    
  341.                if cs_exp[id]>=35000 then
  342.                     cs_level[id] = 35
  343.                     cs_req[id] = 36000
  344.                end          
  345.                if cs_exp[id]>=36000 then
  346.                     cs_level[id] = 36
  347.                     cs_req[id] = 37000
  348.                end            
  349.                if cs_exp[id]>=37000 then
  350.                     cs_level[id] = 37
  351.                     cs_req[id] = 38000
  352.                end          
  353.                if cs_exp[id]>=38000 then
  354.                     cs_level[id] = 38
  355.                     cs_req[id] = 39000
  356.                end          
  357.                if cs_exp[id]>=39000 then
  358.                     cs_level[id] = 39
  359.                     cs_req[id] = 40000
  360.                end  
  361.                if cs_exp[id]==40000 then
  362.                rp_money[id]=rp_money[id]+400000
  363.                     cs_exp[id]=40001
  364.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 40 and was rewarded with 400k.")
  365.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  366.                         updatehud(id)
  367.                 end
  368.                if cs_exp[id]>=40000 then
  369.                     cs_level[id] = 40
  370.                     cs_req[id] = 41000
  371.                end          
  372.                if cs_exp[id]>=41000 then
  373.                     cs_level[id] = 41
  374.                     cs_req[id] = 42000
  375.                end          
  376.                if cs_exp[id]>=42000 then
  377.                     cs_level[id] = 42
  378.                     cs_req[id] = 43000
  379.                end          
  380.                if cs_exp[id]>=43000 then
  381.                     cs_level[id] = 43
  382.                     cs_req[id] = 44000
  383.                end          
  384.                if cs_exp[id]>=44000 then
  385.                     cs_level[id] = 44
  386.                     cs_req[id] = 45000
  387.                end        
  388.                if cs_exp[id]==45000 then
  389.                rp_money[id]=rp_money[id]+450000
  390.                     cs_exp[id]=45001
  391.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 45 and was rewarded with 450k.")
  392.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  393.                         updatehud(id)
  394.                 end            
  395.                if cs_exp[id]>=45000 then
  396.                     cs_level[id] = 45
  397.                     cs_req[id] = 46000
  398.                end            
  399.                if cs_exp[id]>=46000 then
  400.                     cs_level[id] = 46
  401.                     cs_req[id] = 47000
  402.                end            
  403.                if cs_exp[id]>=47000 then
  404.                     cs_level[id] = 47
  405.                     cs_req[id] = 48000
  406.                end          
  407.                if cs_exp[id]>=48000 then
  408.                     cs_level[id] = 48
  409.                     cs_req[id] = 49000
  410.                end          
  411.                if cs_exp[id]>=49000 then
  412.                     cs_level[id] = 49
  413.                     cs_req[id] = 50000
  414.                end  
  415.                if cs_exp[id]==50000 then
  416.                rp_money[id]=rp_money[id]+500000
  417.                     cs_exp[id]=50001
  418.                     msg("\169255255000[Server]: \169000255000"..player(id,"name").." is now level 50 and was rewarded with 500k.")
  419.                     parse("sv_sound2 "..id.." !7/levelup.ogg")
  420.                 end                    
  421.                if cs_exp[id]>=50000 then
  422.                     cs_level[id] = 50
  423.                     cs_req[id] = 50000
  424.                         updatehud(id)
  425.                end
  426. --end is here
  427.           end
  428.      end
  429.      ExpInfo(id)
  430. end
  431.  
  432. addhook("die", "dieded")
  433.  
  434. function dieded(id, vid, wep, x, y)
  435.      -- Changed nil values with 0 since CS2D doesn't send nil values
  436.      if vid ~= 0 and id ~= 0 and id ~= vid then
  437.           cs_exp[vid]=cs_exp[vid]-10
  438.           cs_exp[id]=cs_exp[id]+5
  439. --          msg(player(id, "name").." killed "..player(vid, "name").."!")
  440.           msg2(vid,"\169255255000[Server]: \169255000000You got killed by "..player(id, "name").." and lost 10 EXP + 1000$!")
  441.           msg2(id,"\169255255000[Server]: \169000255000You killed "..player(vid, "name").." and gained 5 EXP + 500$!")
  442.           rp_killer[id]=true
  443.           rp_money[id]=rp_money[id]+200
  444.           updatehud(id)
  445.          
  446.           if rp_money[vid]>=1000 then
  447.                rp_money[vid]=rp_money[vid]-1000
  448.                updatehud(vid)
  449.           end
  450.           if rp_criminal[id]==true then
  451.                rp_money[id]=rp_money[id]+2000
  452.                cs_exp[id]=cs_exp[id]+5
  453.                msg2(id,"\169255255000[Server]: \169000255000Criminal bonus 2000$ and 10 EXP!")
  454.           end
  455.           if rp_criminal[vid]==true and rp_police[id]== true then
  456.                rp_money[id]=rp_money[id]+5000
  457.                cs_exp[id]=cs_exp[id]+20
  458.                msg2(id,"\169255255000[Server]: \169000255000You've killed a criminal, you won 5000$ and 20 EXP!")
  459.           end
  460.           if rp_criminal[vid]==true then
  461.                cs_exp[vid]=cs_exp[vid]-40
  462.                msg2(vid,"\169255255000[Server]: \169255000000You've been killed and lost 10,000$ and 40 EXP!")
  463.                if rp_money[vid]>=10000 then
  464.                     rp_money[vid]=rp_money[vid]-10000
  465.                     updatehud(vid)
  466.                end
  467.           end
  468.      end
  469. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement