i want this 2script going to be mixed!

i am a noob but i know basics ( i guess ) maybe codes will make me very pleased
im combining scripts from
http://www.unrealsoftware.de/files_show.php?file=16711
and
http://www.unrealsoftware.de/files_show.php?file=14215
(alternate download)
http://www.mediafire.com/download/2wercx28jof10uk/system_level_rank_mod.zip
the thing i want is
Quote
if my rank is "Noob" it will show Peasant I rank, if i ranked up it will become Peasant II, and it will be silver 1 silver 2 blah2...
(fk grammar)
Point: Uprank = image changes to the desire rank
Here's the code for you guys who can't download
Spoiler 

Quote
-- Arrays --
p_maxexp = initArray(32,0)
p_exp = initArray(32,0)
p_level = initArray(32,0)
p_usgn = initArray(32,0)
p_killstreak = initArray(32,0)
p_lastkill = initArray(32,0)
p_rank = initArray(32,"")
levelname = {}
levelimage = {}
levelname[1] = "Cadet I"
levelimage[1] = "gfx/bf3.png"
levelname[2] = "Cadet II"
levelimage[2] = "gfx/bf3.png"
levelname[3] = "Cadet III"
levelimage[3] = "gfx/bf3.png"
levelname[4] = "Silver I"
levelimage[4] = "gfx/bf3.png"
levelname[5] = "Silver II"
levelimage[5] = "gfx/bf3.png"
levelname[6] = "Silver Elite"
levelimage[6] = "gfx/bf3.png"
levelname[7] = "Silver Elite Master"
levelimage[7] = "gfx/bf3.png"
levelname[8] = "Gold Nova I"
levelimage[8] = "gfx/bf3.png"
levelname[9] = "Gold Nova II"
levelname[10] = "Gold Nova III"
levelname[11] = "Gold Nova Master"
levelname[12] = "Cadet Elite Master"
levelname[13] = "General Cadet Master"
levelname[14] = "General Cadet Master I"
levelname[15] = "General Cadet Master II"
levelname[16] = "General Silver Master"
levelname[17] = "General Nova Master I "
levelname[18] = "General Nova Master II"
levelname[19] = "General Nova Master III"
levelname[20] = "Global Cadet Master"
levelname[21] = "Global Silver Master"
levelname[22] = "Global Nova Master"
levelname[23] = "Global Cadet Guardian"
levelname[24] = "Global Silver Guardian"
levelname[25] = "Global Nova Guardian"
p_maxexp = initArray(32,0)
p_exp = initArray(32,0)
p_level = initArray(32,0)
p_usgn = initArray(32,0)
p_killstreak = initArray(32,0)
p_lastkill = initArray(32,0)
p_rank = initArray(32,"")
levelname = {}
levelimage = {}
levelname[1] = "Cadet I"
levelimage[1] = "gfx/bf3.png"
levelname[2] = "Cadet II"
levelimage[2] = "gfx/bf3.png"
levelname[3] = "Cadet III"
levelimage[3] = "gfx/bf3.png"
levelname[4] = "Silver I"
levelimage[4] = "gfx/bf3.png"
levelname[5] = "Silver II"
levelimage[5] = "gfx/bf3.png"
levelname[6] = "Silver Elite"
levelimage[6] = "gfx/bf3.png"
levelname[7] = "Silver Elite Master"
levelimage[7] = "gfx/bf3.png"
levelname[8] = "Gold Nova I"
levelimage[8] = "gfx/bf3.png"
levelname[9] = "Gold Nova II"
levelname[10] = "Gold Nova III"
levelname[11] = "Gold Nova Master"
levelname[12] = "Cadet Elite Master"
levelname[13] = "General Cadet Master"
levelname[14] = "General Cadet Master I"
levelname[15] = "General Cadet Master II"
levelname[16] = "General Silver Master"
levelname[17] = "General Nova Master I "
levelname[18] = "General Nova Master II"
levelname[19] = "General Nova Master III"
levelname[20] = "Global Cadet Master"
levelname[21] = "Global Silver Master"
levelname[22] = "Global Nova Master"
levelname[23] = "Global Cadet Guardian"
levelname[24] = "Global Silver Guardian"
levelname[25] = "Global Nova Guardian"
Spoiler 

Quote
-- Core functions --
Image = {}
function initArray(length,mode)
local array = {}
for i = 1,length do
array[i] = mode
end
return array
end
function string_split(str,pattern)
local entry = {}
for str in string.gmatch(str,pattern) do
if str ~= "" then
table.insert(entry,str)
end
end
return entry
end
function is_file(filename)
local file = io.open(filename)
if file then
io.close(file)
return true
end
return false
end
function create_user(uid)
local usgn = get_usgn(uid)
local path = saves_folder..usgn..".txt"
if not is_file(path) then
file = io.open(path,"w")
file : write("maxexp="..p_maxexp[uid].."\n")
file : write("level="..p_level[uid].."\n")
file : write("rank="..p_rank[uid].."\n")
file : write("exp="..p_exp[uid].."\n")
file : close()
print("The user with number "..usgn.." created successfully.")
else
print("The user with number "..usgn.." already exists in the database.")
end
end
function refresh_user(uid)
local usgn = get_usgn(uid)
local path = saves_folder..usgn..".txt"
if is_file(path) then
file = io.open(path,"w")
file : write("maxexp="..p_maxexp[uid].."\n")
file : write("level="..p_level[uid].."\n")
file : write("rank="..p_rank[uid].."\n")
file : write("exp="..p_exp[uid].."\n")
file : close()
print("The user "..usgn.." successfully updated.")
else
print("The user "..usgn.." does not exist in the database.")
end
end
function isPlayer(uid)
return player(uid,"exists")
end
function playerInScreen(uid,player)
x,y = get_pos(uid)
px,py = get_pos(player)
if px - x > 320 or py - y > 240 then
return false
else
return true
end
end
function get_pos(uid)
return player(uid,"x"),player(uid,"y")
end
function get_name(uid)
return player(uid,"name")
end
function get_usgn(uid)
return player(uid,"usgn")
end
function get_ip(uid)
return player(uid,"ip")
end
function reset_flags(uid)
p_maxexp[uid] = 50
p_level[uid] = 1
p_rank[uid] = "[Norank]"
p_rank[uid] = "[Norank]"
p_exp[uid] = 0
end
function set_flags(uid)
local usgn = get_usgn(uid)
local name = get_name(uid)
local path = saves_folder..usgn..".txt"
p_usgn[uid] = usgn
if is_file(path) then
local file = io.open(path,"r")
local temp = {}
for line in file:lines() do
local temp = string_split(line,"[^=]*")
if temp[1] == "maxexp" then p_maxexp[uid] = tonumber(temp[2]) end
if temp[1] == "level" then p_level[uid] = tonumber(temp[2]) end
if temp[1] == "rank" then p_rank[uid] = tostring(temp[2]) end
if temp[1] == "exp" then p_exp[uid] = tonumber(temp[2]) end
end
file : close()
msg2(uid,"©210235255Welcome "..name.." his USGN is "..usgn..", your information has been loaded successfully!")
elseif usgn ~= 0 then
create_user(uid)
msg2(uid,"©210235255Welcome "..name.." his USGN is "..usgn..", your information has been created successfully!")
else
msg2(uid,"©210235255"..name..", Please login into your usgn! Your data will not save.")
end
end
function refresh_hud(uid)
hud_txt2(uid,1,"©255255255 Experience: "..p_exp[uid].."/"..p_maxexp[uid],2,115,0)
hud_txt2(uid,2,"©255255255 USGN: "..player(uid,"usgn"),2,130,0)
hud_txt2(uid,3,"©255255255 Level: "..p_level[uid],2,145,0)
hud_txt2(uid,4,"©255255255 Rank: "..p_rank[uid],2,160,0)
end
function get_max_xp(level)
max_xp=(50*(level-1)*(level-1)*(level-1)-150*(level-1)*(level-1)+400*(level-1))/3
return max_xp
end
function check_level(uid)
if p_exp[uid] >= p_maxexp[uid] then
p_level[uid] = p_level[uid]+1
p_exp[uid] = 0
local x,y = get_pos(uid)
local level = p_level[uid]
if levelname[level] then
img[level] = image("..levelimage..", 0, 0, id+132)
Image = nil
p_rank[uid] = levelname[level]
msg2(uid,"©210235255You just go to the patent "..p_rank[uid])
end
p_maxexp[uid]=get_max_xp(level)
effect("flare",x,y,20,20,255,255,0)
msg2(uid,"©210235255[Levelup] From "..(level-1).." to level "..level..".")
end
end
function hud_txt2(uid,id,text,x,y,align)
parse("hudtxt2 "..uid.." "..id.." \""..text.."\" "..x.." "..y.." "..align)
end
function effect(name,x,y,radius,amount,r,g,b)
parse("effect \""..name.."\" "..x.." "..y.." "..radius.." "..amount.." "..r.." "..g.." "..b)
end
------------IMAGE SCRIPT ( Ignore this its a test script by vademon )
hudimagetable = {}
function imageJoin( id ) -- < sets the variable id which equals the player ID who joined
local x = player(id, "x") -- Sets on screen image
local y = player(id, "y")
hudimagetable[ id ] = image("gfx/yates/ranks/rank_list.png", 320, 230, 2) -- saves the returned value in the table exclusively for this player
end
function imageSpawn(id) -- remove image when this player spawns
if hudimagetable[id] ~= nil then -- does the address of the image exist?
freeimage( hudimagetable[ id] ) -- retrieve the saved value for this player
hudimagetable[id] = nil -- delete the image address
end
end
Error here:
--Lua error update, i fixed the " id " a nil value, now theres an error with the hooks and function value
Image = {}
function initArray(length,mode)
local array = {}
for i = 1,length do
array[i] = mode
end
return array
end
function string_split(str,pattern)
local entry = {}
for str in string.gmatch(str,pattern) do
if str ~= "" then
table.insert(entry,str)
end
end
return entry
end
function is_file(filename)
local file = io.open(filename)
if file then
io.close(file)
return true
end
return false
end
function create_user(uid)
local usgn = get_usgn(uid)
local path = saves_folder..usgn..".txt"
if not is_file(path) then
file = io.open(path,"w")
file : write("maxexp="..p_maxexp[uid].."\n")
file : write("level="..p_level[uid].."\n")
file : write("rank="..p_rank[uid].."\n")
file : write("exp="..p_exp[uid].."\n")
file : close()
print("The user with number "..usgn.." created successfully.")
else
print("The user with number "..usgn.." already exists in the database.")
end
end
function refresh_user(uid)
local usgn = get_usgn(uid)
local path = saves_folder..usgn..".txt"
if is_file(path) then
file = io.open(path,"w")
file : write("maxexp="..p_maxexp[uid].."\n")
file : write("level="..p_level[uid].."\n")
file : write("rank="..p_rank[uid].."\n")
file : write("exp="..p_exp[uid].."\n")
file : close()
print("The user "..usgn.." successfully updated.")
else
print("The user "..usgn.." does not exist in the database.")
end
end
function isPlayer(uid)
return player(uid,"exists")
end
function playerInScreen(uid,player)
x,y = get_pos(uid)
px,py = get_pos(player)
if px - x > 320 or py - y > 240 then
return false
else
return true
end
end
function get_pos(uid)
return player(uid,"x"),player(uid,"y")
end
function get_name(uid)
return player(uid,"name")
end
function get_usgn(uid)
return player(uid,"usgn")
end
function get_ip(uid)
return player(uid,"ip")
end
function reset_flags(uid)
p_maxexp[uid] = 50
p_level[uid] = 1
p_rank[uid] = "[Norank]"
p_rank[uid] = "[Norank]"
p_exp[uid] = 0
end
function set_flags(uid)
local usgn = get_usgn(uid)
local name = get_name(uid)
local path = saves_folder..usgn..".txt"
p_usgn[uid] = usgn
if is_file(path) then
local file = io.open(path,"r")
local temp = {}
for line in file:lines() do
local temp = string_split(line,"[^=]*")
if temp[1] == "maxexp" then p_maxexp[uid] = tonumber(temp[2]) end
if temp[1] == "level" then p_level[uid] = tonumber(temp[2]) end
if temp[1] == "rank" then p_rank[uid] = tostring(temp[2]) end
if temp[1] == "exp" then p_exp[uid] = tonumber(temp[2]) end
end
file : close()
msg2(uid,"©210235255Welcome "..name.." his USGN is "..usgn..", your information has been loaded successfully!")
elseif usgn ~= 0 then
create_user(uid)
msg2(uid,"©210235255Welcome "..name.." his USGN is "..usgn..", your information has been created successfully!")
else
msg2(uid,"©210235255"..name..", Please login into your usgn! Your data will not save.")
end
end
function refresh_hud(uid)
hud_txt2(uid,1,"©255255255 Experience: "..p_exp[uid].."/"..p_maxexp[uid],2,115,0)
hud_txt2(uid,2,"©255255255 USGN: "..player(uid,"usgn"),2,130,0)
hud_txt2(uid,3,"©255255255 Level: "..p_level[uid],2,145,0)
hud_txt2(uid,4,"©255255255 Rank: "..p_rank[uid],2,160,0)
end
function get_max_xp(level)
max_xp=(50*(level-1)*(level-1)*(level-1)-150*(level-1)*(level-1)+400*(level-1))/3
return max_xp
end
function check_level(uid)
if p_exp[uid] >= p_maxexp[uid] then
p_level[uid] = p_level[uid]+1
p_exp[uid] = 0
local x,y = get_pos(uid)
local level = p_level[uid]
if levelname[level] then
img[level] = image("..levelimage..", 0, 0, id+132)
Image = nil
p_rank[uid] = levelname[level]
msg2(uid,"©210235255You just go to the patent "..p_rank[uid])
end
p_maxexp[uid]=get_max_xp(level)
effect("flare",x,y,20,20,255,255,0)
msg2(uid,"©210235255[Levelup] From "..(level-1).." to level "..level..".")
end
end
function hud_txt2(uid,id,text,x,y,align)
parse("hudtxt2 "..uid.." "..id.." \""..text.."\" "..x.." "..y.." "..align)
end
function effect(name,x,y,radius,amount,r,g,b)
parse("effect \""..name.."\" "..x.." "..y.." "..radius.." "..amount.." "..r.." "..g.." "..b)
end
------------IMAGE SCRIPT ( Ignore this its a test script by vademon )
hudimagetable = {}
function imageJoin( id ) -- < sets the variable id which equals the player ID who joined
local x = player(id, "x") -- Sets on screen image
local y = player(id, "y")
hudimagetable[ id ] = image("gfx/yates/ranks/rank_list.png", 320, 230, 2) -- saves the returned value in the table exclusively for this player
end
function imageSpawn(id) -- remove image when this player spawns
if hudimagetable[id] ~= nil then -- does the address of the image exist?
freeimage( hudimagetable[ id] ) -- retrieve the saved value for this player
hudimagetable[id] = nil -- delete the image address
end
end
Error here:
--Lua error update, i fixed the " id " a nil value, now theres an error with the hooks and function value
Quote
LUA ERROR: sys/lua/rank_mod/Data/functions.lua:151: attempt to call local 'image' (a string
value)
-> sys/lua/rank_mod/Data/functions.lua:151: in function 'check_level'
-> sys/lua/rank_mod/Data/hooks.lua:46: in function <sys/lua/rank_mod/Data/hooks.lua:42>
-> in Lua hook 'join', params: 1
value)
-> sys/lua/rank_mod/Data/functions.lua:151: in function 'check_level'
-> sys/lua/rank_mod/Data/hooks.lua:46: in function <sys/lua/rank_mod/Data/hooks.lua:42>
-> in Lua hook 'join', params: 1
The code isn't by me, Originally created by M_ and Yates
Edit: i fixed the codes but this is the thing i can't fix...
"LUA ERROR: image - can't load image at '..levelimage.."
Edit: Done fixed :3
edited 10×, last 18.01.16 12:07:29 pm