Jump to content

paid offer


5150

Recommended Posts

i dont usually offer to pay people for a script (or anything MTA related) but this is a must-have for my server. i really really needa rank system for players, but with images of the ranks as well (like, showing chevrons or an officers symbol on their nametag, in tab, or on a panel or something), but i cant find one ANYWHERE. this script is what i look for but its for a different gamemode. it doesnt work in freeroam. if someone could convert it to a working freeroam rank system i would be grateful

client.lua

function checkForStart() 
    if not isTransferBoxActive() then
GUIEditor = {
    progressbar = {},
    edit = {},
    gridlist = {},
    window = {},
    label = {}
}
 
local x, y = guiGetScreenSize()
 
 
GUIEditor.window[1] = guiCreateStaticImage(x/2-(720/2), y/2-(647/2), 720, 647, "wnd.jpg", false)
header = guiCreateStaticImage(0, 0, 720, 30, "Header.png", false, GUIEditor.window[1])
guiCreateLabel(300, 5, 532, 100, "World War 2 Roleplay Rank System", false, header)
 
guiSetAlpha(GUIEditor.window[1], 0.95)
guiSetVisible(GUIEditor.window[1], false)
 
GUIEditor.gridlist[1] = guiCreateGridList(15, 31, 350, 513, false, GUIEditor.window[1])
guiGridListAddColumn(GUIEditor.gridlist[1], "Rank", 0.1)
guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.4)
guiGridListAddColumn(GUIEditor.gridlist[1], "Total Kills", 0.2)
guiGridListAddColumn(GUIEditor.gridlist[1], "Total Deaths", 0.2)
 
GUIEditor.edit[1] = guiCreateEdit(75, 583, 195, 28, "", false, GUIEditor.window[1])
GUIEditor.label[1] = guiCreateLabel(82, 558, 173, 15, "Search for player:", false, GUIEditor.window[1])
 
GUIEditor.label[2] = guiCreateLabel(375, 40, 500, 21, "STATS of player: N/A", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[2], "default-bold-small" )
 
GUIEditor.progressbar[1] = guiCreateProgressBar(420, 162, 215, 24, false, GUIEditor.window[1])
guiProgressBarSetProgress(GUIEditor.progressbar[1], 0)
GUIEditor.label[3] = guiCreateLabel(510, 140, 532, 100, "Rank N/A", false, GUIEditor.window[1])
GUIEditor.label[4] = guiCreateLabel(425, 193, 532, 100, "N/A/N/A      N/A until rank up", false, GUIEditor.window[1])
 
rankImage = guiCreateStaticImage(490, 70, 74, 64, "Ranks/Rank_00.png", false, GUIEditor.window[1])
 
GUIEditor.label[5] = guiCreateLabel(380, 270, 150, 17, "--|Player Statistics|--", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[5], "default-bold-small" )
guiLabelSetColor(GUIEditor.label[5], 0, 100, 255)
GUIEditor.label[6] = guiCreateLabel(380, 314, 332, 15, "Total Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[7] = guiCreateLabel(380, 344, 332, 15, "Total Deaths: N/A", false, GUIEditor.window[1])
GUIEditor.label[8] = guiCreateLabel(380, 374, 332, 15, "K/D Ratio: N/A", false, GUIEditor.window[1])
GUIEditor.label[9] = guiCreateLabel(380, 404, 332, 15, "Kill Assists: N/A", false, GUIEditor.window[1])
GUIEditor.label[10] = guiCreateLabel(380, 434, 332, 15, "Shots Fired: N/A", false, GUIEditor.window[1])
GUIEditor.label[11] = guiCreateLabel(380, 464, 332, 15, "Shots hit: N/A", false, GUIEditor.window[1])
GUIEditor.label[12] = guiCreateLabel(380, 494, 332, 15, "Accuracy: N/A", false, GUIEditor.window[1])
GUIEditor.label[13] = guiCreateLabel(380, 524, 332, 15, "DMG: N/A", false, GUIEditor.window[1])
GUIEditor.label[14] = guiCreateLabel(380, 554, 332, 15, "Kill Streak: N/A", false, GUIEditor.window[1])
GUIEditor.label[15] = guiCreateLabel(380, 584, 332, 15, "Headshots: N/A", false, GUIEditor.window[1])
guiCreateStaticImage(520, 270, 1.5, 350, "line.png", false, GUIEditor.window[1])
r, g, b = 255, 100, 0
guiLabelSetColor(GUIEditor.label[6], r, g, b)
guiLabelSetColor(GUIEditor.label[7], r, g, b)
guiLabelSetColor(GUIEditor.label[8], r, g, b)
guiLabelSetColor(GUIEditor.label[9], r, g, b)
guiLabelSetColor(GUIEditor.label[10], r, g, b)
guiLabelSetColor(GUIEditor.label[11], r, g, b)
guiLabelSetColor(GUIEditor.label[12], r, g, b)
guiLabelSetColor(GUIEditor.label[13], r, g, b)
guiLabelSetColor(GUIEditor.label[14], r, g, b)
guiLabelSetColor(GUIEditor.label[15], r, g, b)
GUIEditor.label[16] = guiCreateLabel(540, 270, 150, 17, "--|Weapons Statistics|--", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[16], "default-bold-small" )
guiLabelSetColor(GUIEditor.label[16], 0, 100, 255)
GUIEditor.label[17] = guiCreateLabel(540, 314, 332, 15, "Total Deagle Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[18] = guiCreateLabel(540, 344, 332, 15, "Total Sniper Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[19] = guiCreateLabel(540, 374, 332, 15, "Total Shotgun Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[20] = guiCreateLabel(540, 404, 332, 15, "Total Rifle Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[21] = guiCreateLabel(540, 434, 332, 15, "Total Grenade Kills: N/A", false, GUIEditor.window[1])
GUIEditor.label[22] = guiCreateLabel(540, 464, 332, 15, "Total Fist Kills: N/A", false, GUIEditor.window[1])
guiLabelSetColor(GUIEditor.label[17], r, g, b)
guiLabelSetColor(GUIEditor.label[18], r, g, b)
guiLabelSetColor(GUIEditor.label[19], r, g, b)
guiLabelSetColor(GUIEditor.label[20], r, g, b)
guiLabelSetColor(GUIEditor.label[21], r, g, b)
guiLabelSetColor(GUIEditor.label[22], r, g, b)
 
GUIEditor.label[23] = guiCreateLabel(540, 494, 150, 17, "--|Game Statistics|--", false, GUIEditor.window[1])
guiSetFont(GUIEditor.label[23], "default-bold-small" )
guiLabelSetColor(GUIEditor.label[23], 0, 100, 255)
 
GUIEditor.label[24] = guiCreateLabel(540, 524, 332, 23, "Time Played: N/A", false, GUIEditor.window[1])
GUIEditor.label[25] = guiCreateLabel(540, 554, 332, 23, "Total Wins: N/A", false, GUIEditor.window[1])
GUIEditor.label[26] = guiCreateLabel(540, 584, 332, 23, "Total Loses: N/A", false, GUIEditor.window[1])
 
guiLabelSetColor(GUIEditor.label[24], r, g, b)
guiLabelSetColor(GUIEditor.label[25], r, g, b)
guiLabelSetColor(GUIEditor.label[26], r, g, b)
 
function calculateRank(XP)
    for i=0, 99999 do
        CurrentXP = i*(i >= 1 and i or 1-1)*400
        if CurrentXP > XP then
            return (i-1), CurrentXP - ((i-1)*(i-1)*400), CurrentXP-XP
        end
    end
end
 
function round(num, idp)
  if idp and idp>0 then
    local mult = 10^idp
    return math.floor(num * mult + 0.5) / mult
  end
  return math.floor(num + 0.5)
end
 
function convertTime(sec)
    local sec = sec or 0
    local h = math.floor(sec/3600)
    local m = math.floor((sec/60)%60)
    --local s = sec % 60
    if h < 0 then local h = 0 end
    if m < 0 then local m = 0 end
    return {h, m}
end
 
addEventHandler("onClientPlayerWeaponFire", localPlayer,
function()
    if exports.tactics:getRoundMapInfo()["modename"] ~= "lobby" then
        ammoFired = (ammoFired or 0) + 1
    end
end)
 
addEvent("onClientRoundFinish", true)
addEventHandler("onClientRoundFinish", root,
function()
    triggerServerEvent("onSendAmmoFired", localPlayer, ammoFired)
    ammoFired = 0
    if isTimer(eTimer) then killTimer(eTimer) end
    eTimer = setTimer(function()
        if isTimer(killCamTimer) then
            killTimer(killCamTimer)
            killerName = nil
            killerHealth = nil
            killerRank = nil
            killerWeapon = nil
            start = nil
            killerFOE = nil
            killerYOU = nil
            destroyShaderForPlayer(killElement)
            killElement = nil
            removeEventHandler("onClientPreRender", root, interpolateCam)
        end
    end, 8000, 1)
end)
 
cacheTableClient = {}
myAccountNameClient = ""
 
addEvent("onServerSendStats", true)
addEventHandler("onServerSendStats", root,
function(cacheTable, myAccountName)
    cacheTableClient = cacheTable
    myAccountNameClient = myAccountName
    if cacheTable and type(cacheTable) == "table" then
        guiGridListClear(GUIEditor.gridlist[1])
        table.sort(cacheTable, function(a, b) return (tonumber(a[3])or 0) > (tonumber(b[3])or 0) end)
        for i, R in ipairs(cacheTable) do
            local row = guiGridListAddRow(GUIEditor.gridlist[1])
            local Rank, RequiredXP, RemainingXP = calculateRank(R[3])
            guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, Rank, false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, R[2], false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], row, 3, R[4], false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], row, 4, R[5], false, false)
            guiGridListSetItemData(GUIEditor.gridlist[1], row, 1, R)
            if myAccountName == R[1] then
                guiSetText(GUIEditor.label[2], "STATS of player: "..R[2].." ("..R[1]..")")
                guiSetText(GUIEditor.label[3], "Rank "..Rank)
                guiSetText(GUIEditor.label[4], RequiredXP-RemainingXP.."/"..RequiredXP.."      "..RemainingXP.." until rank up")
                guiProgressBarSetProgress(GUIEditor.progressbar[1], ((RequiredXP-RemainingXP)/RequiredXP)*10000000)
                guiSetText(GUIEditor.label[6], "Total Kills: "..R[4])
                guiSetText(GUIEditor.label[7], "Total Deaths: "..R[5])
                if R[5] <= 0 then R[5] = 10 end
                guiSetText(GUIEditor.label[8], "K/D Ratio: "..round(tonumber(R[4])/tonumber(R[5]), 2))
                guiSetText(GUIEditor.label[9], "Kill Assists: "..R[6])
                guiSetText(GUIEditor.label[10], "Shots Fired: "..R[7])
                guiSetText(GUIEditor.label[11], "Shots hit: "..R[8])
                if R[7] <= 0 then R[7] = 1 end
                guiSetText(GUIEditor.label[12], "Accuracy: "..round(((R[8]/R[7])*100), 2).."%")
                guiSetText(GUIEditor.label[13], "DMG: "..R[9])
                guiSetText(GUIEditor.label[14], "Kill Streak: "..R[10])
                guiSetText(GUIEditor.label[15], "Headshots: "..R[11])
                guiSetText(GUIEditor.label[17], "Total Deagle Kills: "..R[12])
                guiSetText(GUIEditor.label[18], "Total Sniper Kills: "..R[13])
                guiSetText(GUIEditor.label[19], "Total Shotgun Kills: "..R[14])
                guiSetText(GUIEditor.label[20], "Total Rifle Kills: "..R[15])
                guiSetText(GUIEditor.label[21], "Total Grenade Kills: "..R[16])
                guiSetText(GUIEditor.label[22], "Total Fist Kills: "..R[17])
                local T = convertTime(R[18])
                guiSetText(GUIEditor.label[24], "Time Played: "..T[1].."H "..T[2].."M")
                guiSetText(GUIEditor.label[25], "Total Wins: "..R[19])
                guiSetText(GUIEditor.label[26], "Total Loses: "..R[20])
                local imagePath
                if Rank < 10 then
                    imagePath = "Ranks/Rank_0"..Rank..".png"
                else
                    imagePath = "Ranks/Rank_"..Rank..".png"
                end
                guiStaticImageLoadImage(rankImage, imagePath)
            end
        end
    end
end)
 
addEventHandler("onClientGUIClick", resourceRoot,
function(btn)
    if btn == "left" then
        if source == GUIEditor.gridlist[1] then
            local sR, sC = guiGridListGetSelectedItem(source)
            if sR and sR ~= -1 then
                local R = guiGridListGetItemData(source, sR, 1)
                local Rank, RequiredXP, RemainingXP = calculateRank(R[3])
                guiSetText(GUIEditor.label[2], "STATS of player: "..R[2].." ("..R[1]..")")
                guiSetText(GUIEditor.label[3], "Rank "..Rank)
                guiSetText(GUIEditor.label[4], RequiredXP-RemainingXP.."/"..RequiredXP.."      "..RemainingXP.." until rank up") -- to get xp
                guiProgressBarSetProgress(GUIEditor.progressbar[1], ((RequiredXP-RemainingXP)/RequiredXP)*100)
                guiSetText(GUIEditor.label[6], "Total Kills: "..R[4])
                guiSetText(GUIEditor.label[7], "Total Deaths: "..R[5])
                if R[5] <= 0 then R[5] = 10 end
                guiSetText(GUIEditor.label[8], "K/D Ratio: "..round(tonumber(R[4])/tonumber(R[5]), 2))
                guiSetText(GUIEditor.label[9], "Kill Assists: "..R[6])
                guiSetText(GUIEditor.label[10], "Shots Fired: "..R[7])
                guiSetText(GUIEditor.label[11], "Shots hit: "..R[8])
                if R[7] <= 0 then R[7] = 1 end
                guiSetText(GUIEditor.label[12], "Accuracy: "..round(((R[8]/R[7])*100), 2).."%")
                guiSetText(GUIEditor.label[13], "DMG: "..R[9])
                guiSetText(GUIEditor.label[14], "Kill Streak: "..R[10])
                guiSetText(GUIEditor.label[15], "Headshots: "..R[11])
                guiSetText(GUIEditor.label[17], "Total Deagle Kills: "..R[12])
                guiSetText(GUIEditor.label[18], "Total Sniper Kills: "..R[13])
                guiSetText(GUIEditor.label[19], "Total Shotgun Kills: "..R[14])
                guiSetText(GUIEditor.label[20], "Total Rifle Kills: "..R[15])
                guiSetText(GUIEditor.label[21], "Total Grenade Kills: "..R[16])
                guiSetText(GUIEditor.label[22], "Total Fist Kills: "..R[17])
                local T = convertTime(R[18])
                guiSetText(GUIEditor.label[24], "Time Played: "..T[1].."H "..T[2].."M")
                guiSetText(GUIEditor.label[25], "Total Wins: "..R[19])
                guiSetText(GUIEditor.label[26], "Total Loses: "..R[20])
                local imagePath
                if Rank < 10 then
                    imagePath = "Ranks/Rank_0"..Rank..".png"
                else
                    imagePath = "Ranks/Rank_"..Rank..".png"
                end
                guiStaticImageLoadImage(rankImage, imagePath)
            end
       
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...