Jump to content

[HELP]Stats System


Chris!i!

Recommended Posts

Hi,i have a problem with scripting if anyone can help me i will thanks him alot.in this script there is Nickname and team and ping and kills and deaths and T/D Ratio and more i need them to work i made the GUI and all things expect these its like NickName : it still "" the name dont appear i tried my best and didnt worked so i deleted it ad posteed it at forum so the community can help me thats the code :

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(347, 48, 473, 581, "Stats", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.gridlist[1] = guiCreateGridList(280, 26, 183, 545, false, GUIEditor.window[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Players", 0.9) 
        GUIEditor.label[1] = guiCreateLabel(11, 38, 259, 30, "NickName : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 78, 259, 30, "Team : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[3] = guiCreateLabel(11, 118, 259, 30, "Ping : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[4] = guiCreateLabel(11, 158, 259, 30, "Kills : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[5] = guiCreateLabel(10, 198, 259, 30, "Deaths : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[6] = guiCreateLabel(10, 238, 259, 30, "K/D Ratio : \"\"", false, GUIEditor.window[1])  
        GUIEditor.label[7] = guiCreateLabel(10, 278, 259, 30, "Money : \"\"", false, GUIEditor.window[1])        
    end 
) 
  
  
function list() 
    guiGridListClear(GUIEditor.gridlist[1]) 
    if (guiGridListClear) then 
    for id, players in ipairs (getElementsByType("player")) do 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, (getPlayerName(players)), false, false) 
        guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 255, 255, 0, 255 ) 
    end 
end 
end 
addEventHandler("onClientPlayerJoin", getRootElement(), list) 
addEventHandler("onClientPlayerQuit", getRootElement(), list) 
addEventHandler("onClientPlayerChangeNick", getRootElement(), list) 
addEventHandler("onClientResourceStart", getRootElement(), list) 
  
function PanelShow () 
getVisible = guiGetVisible (GUIEditor.window[1]) 
if (getVisible == true) then 
guiSetVisible (GUIEditor.window[1], false) 
showCursor (false) 
elseif (getVisible == false) then    
showCursor (true) 
guiSetVisible (GUIEditor.window[1], true) 
guiSetInputEnabled(false) 
end 
end 
bindKey("F5", "down", PanelShow) 
  

Link to comment

addEventHandler('onClientElementDataChange',root, 
    function (  ) 
        local gKillsClient = getElementData ( localPlayer,'Kills' ) or 'N/A' 
            guiSetText ( yourLabel,'Total  Kills : '..gKillsClient ) 
    end 
) 

Change yourLabel to the label name you got .

Link to comment
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(347, 48, 473, 581, "Stats", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.gridlist[1] = guiCreateGridList(280, 26, 183, 545, false, GUIEditor.window[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Players", 0.9) 
        GUIEditor.label[1] = guiCreateLabel(11, 38, 259, 30, "NickName : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 78, 259, 30, "Team : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[3] = guiCreateLabel(11, 118, 259, 30, "Ping : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[4] = guiCreateLabel(11, 158, 259, 30, "Kills : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[5] = guiCreateLabel(10, 198, 259, 30, "Deaths : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[6] = guiCreateLabel(10, 238, 259, 30, "K/D Ratio : \"\"", false, GUIEditor.window[1])  
        GUIEditor.label[7] = guiCreateLabel(10, 278, 259, 30, "Money : \"\"", false, GUIEditor.window[1])    
    end 
) 
  
  
function list() 
    guiGridListClear(GUIEditor.gridlist[1]) 
    if (guiGridListClear) then 
    for id, players in ipairs (getElementsByType("player")) do 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, (getPlayerName(players)), false, false) 
        guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 255, 255, 0, 255 ) 
    end 
end 
end 
addEventHandler("onClientPlayerJoin", getRootElement(), list) 
addEventHandler("onClientPlayerQuit", getRootElement(), list) 
addEventHandler("onClientPlayerChangeNick", getRootElement(), list) 
addEventHandler("onClientResourceStart", getRootElement(), list) 
  
function PanelShow () 
    getVisible = guiGetVisible (GUIEditor.window[1]) 
    if (getVisible == true) then 
        guiSetVisible (GUIEditor.window[1], false) 
        showCursor (false) 
    elseif (getVisible == false) then  
        showCursor (true) 
        guiSetVisible (GUIEditor.window[1], true) 
        guiSetInputEnabled(false) 
    end 
end 
bindKey("F5", "down", PanelShow) 
  
function setStats ( ) 
    if ( source == GUIEditor.gridlist[1] ) then 
        row, col = guiGridListGetSelectedItem ( source ) 
        if ( row and col and row ~= -1 and col ~= -1 ) then 
            local playername = guiGridListGetItemText ( source, row, col ) 
            local thePlayer = getPlayerFromName ( playername ) 
            if ( thePlayer ) then 
                local tm1 = getPlayerTeam ( thePlayer ) 
                local tm2 = getTeamName ( tm1 ) 
                local ping = getPlayerPing ( thePlayer ) 
                local money = getPlayerMoney ( thePlayer ) 
                guiSetText ( GUIEditor.label[1], "Nickname: ".. playername ) 
                guiSetText ( GUIEditor.label[2], "Team: ".. tm2 ) 
                guiSetText ( GUIEditor.label[3], "Ping: ".. ping ) 
                guiSetText ( GUIEditor.label[7], "Money: ".. money ) 
            end 
        end 
    end 
end 
addEventHandler ( "onClientGUIDoubleClick", root, setStats ) 
  
    addEventHandler('onClientElementDataChange',root, 
        function (  ) 
            local gKillsClient = getElementData ( localPlayer,'Kills' ) or 'N/A' 
                guiSetText ( GUIEditor.label[4], "Kills: "..gKillsClient ) 
        end 
    ) 

Link to comment

--ClientSide

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(347, 48, 473, 581, "Stats", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.gridlist[1] = guiCreateGridList(280, 26, 183, 545, false, GUIEditor.window[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Players", 0.9) 
        GUIEditor.label[1] = guiCreateLabel(11, 38, 259, 30, "NickName : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 78, 259, 30, "Team : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[3] = guiCreateLabel(11, 118, 259, 30, "Ping : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[4] = guiCreateLabel(11, 158, 259, 30, "Kills : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[5] = guiCreateLabel(10, 198, 259, 30, "Deaths : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[6] = guiCreateLabel(10, 238, 259, 30, "K/D Ratio : \"\"", false, GUIEditor.window[1]) 
        GUIEditor.label[7] = guiCreateLabel(10, 278, 259, 30, "Money : \"\"", false, GUIEditor.window[1])   
    end 
) 
  
  
function list() 
    guiGridListClear(GUIEditor.gridlist[1]) 
    if (guiGridListClear) then 
    for id, players in ipairs (getElementsByType("player")) do 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, (getPlayerName(players)), false, false) 
        guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 255, 255, 0, 255 ) 
    end 
end 
end 
addEventHandler("onClientPlayerJoin", getRootElement(), list) 
addEventHandler("onClientPlayerQuit", getRootElement(), list) 
addEventHandler("onClientPlayerChangeNick", getRootElement(), list) 
addEventHandler("onClientResourceStart", getRootElement(), list) 
  
function PanelShow () 
    getVisible = guiGetVisible (GUIEditor.window[1]) 
    if (getVisible == true) then 
        guiSetVisible (GUIEditor.window[1], false) 
        showCursor (false) 
    elseif (getVisible == false) then 
        showCursor (true) 
        guiSetVisible (GUIEditor.window[1], true) 
        guiSetInputEnabled(false) 
    end 
end 
bindKey("F5", "down", PanelShow) 
  
function setStats ( ) 
    if ( source == GUIEditor.gridlist[1] ) then 
        row, col = guiGridListGetSelectedItem ( source ) 
        if ( row and col and row ~= -1 and col ~= -1 ) then 
            local playername = guiGridListGetItemText ( source, row, col ) 
            local thePlayer = getPlayerFromName ( playername ) 
            if ( thePlayer ) then 
                local tm1 = getPlayerTeam ( thePlayer ) 
                local tm2 = getTeamName ( tm1 ) 
                local ping = getPlayerPing ( thePlayer ) 
                local money = getPlayerMoney ( thePlayer ) 
                local gKillsClient = getElementData ( localPlayer,'Kills' ) or 'N/A' 
                guiSetText ( GUIEditor.label[1], "Nickname: ".. playername ) 
                guiSetText ( GUIEditor.label[2], "Team: ".. tm2 ) 
                guiSetText ( GUIEditor.label[3], "Ping: ".. ping ) 
                guiSetText ( GUIEditor.label[7], "Money: ".. money ) 
                guiSetText ( GUIEditor.label[4], "Kills: "..gKillsClient ) 
            end 
        end 
    end 
end 
Link to comment

I dont know why sometimes it happens i pressed on my self nothing of my info came D: now i made a button called Refresh can u tell me how to do it like when he press refresh all his info reset i dont mean it reset his account just his info in the GUI any help thanks alot.

Link to comment
Lol nvm we forgot addEventHandler ( "onClientGUIDoubleClick", root, setStats ), any way the script didnt worked Kills still N/A i killed my brother 2 times i didnt got Kills: 2

you need to make a code if you killed someone add + 1 kills

by

  
setElementData ( killer, 'Kills', +1 ) 
Link to comment

---ServerSide

  
addEventHandler ( 'onPlayerWasted', resourceRoot, 
function (_, attacker ) 
if ( attacker ) and ( attacker ~= source ) then 
local nData = getElementData ( attacker, 'Kills' ) 
if ( nData == false ) or ( nData == nil ) then 
    nData = 0 
end 
nData = nData +1  
setElementData ( attacker, 'Kills', nData ) 
  end 
end 
) 
Link to comment
No offence, but there goes another change of learning how to do it by yourself.

i dont think he will manage to do it , they all want ready scripts , i will Only help him in this Code , if he made another topic

for " ready scripts" i won't help him .

Edited by Guest
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...