Jump to content

Question guiGridList


WASSIm.

Recommended Posts

hi guys

i have question. how make if player create event add in guiGridList exmple "WASSIm. he is created event [2013:8:6][4:05:30]"

addEventHandler ( "onClientGUIClick", root,  
function ( )  
    if ( source == GUIEditor.button[1] ) then 
        triggerServerEvent ( "onCreateEvent", getRootElement(), localPlayer) 
        local row = guiGridListAddRow ( GUIEditor.gridlist[1] )  
        column = guiGridListAddColumn(GUIEditor.gridlist[1], "Lest event created", 0.9) 
    end 
end) 

Link to comment
local year = getRealTime()["year"] + 1900 
local month = getRealTime()["month"] + 1 
local monthday = getRealTime()["monthday"] 
  
local hour = getRealTime()["hour"] 
local minute = getRealTime()["minute"] 
local second = getRealTime()["second"] 

Link to comment
local year = getRealTime()["year"] + 1900 
local month = getRealTime()["month"] + 1 
local monthday = getRealTime()["monthday"] 
  
local hour = getRealTime()["hour"] 
local minute = getRealTime()["minute"] 
local second = getRealTime()["second"] 

i know howa make date but how make if player click button (GUIEditor.button[1]) created in guiGridList exmple "WASSIm. he is created event"

Link to comment
Use:
guiGridListAddRow 
guiGridListSetItemText 

can give exmple ?

i want learn it. i know all GUI but this i don't understand it

addEventHandler ( "onClientGUIClick", button, function ( ) 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        local row = guiGridListAddRow ( grid ) 
        guiGridListSetItemText ( grid, row, 1, getPlayerName ( player ), false, false ) 
    end 
end ) 

Link to comment

thx i make it

but its add just for one

k4g0.png

addEventHandler ( "onClientGUIClick", root,  
function ( )  
    if ( source == GUIEditor.button[1] ) then 
        triggerServerEvent ( "onCreateEvent", getRootElement(), localPlayer)  
        local year = getRealTime()["year"] + 1900 
        local month = getRealTime()["month"] + 1 
        local monthday = getRealTime()["monthday"] 
        local hour = getRealTime()["hour"] 
        local minute = getRealTime()["minute"] 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, "["..hour..":"..minute.."-"..monthday.."."..month.."."..year.."] "..getPlayerName(localPlayer).." created event ", true, true ) 
        end 
end 
) 

Link to comment

Try this:

addEventHandler ( "onClientGUIClick", root, 
function ( ) 
    if ( source == GUIEditor.button[1] ) then 
        triggerServerEvent ( "onCreateEvent", getRootElement(), localPlayer) 
        local year = getRealTime()["year"] + 1900 
        local month = getRealTime()["month"] + 1 
        local monthday = getRealTime()["monthday"] 
        local hour = getRealTime()["hour"] 
        local minute = getRealTime()["minute"] 
        row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, "["..hour..":"..minute.."-"..monthday.."."..month.."."..year.."] "..getPlayerName(localPlayer).." created event ", false, false ) 
    end 
end 
) 

Link to comment
thx i make it

but its add just for one

k4g0.png

addEventHandler ( "onClientGUIClick", root,  
function ( )  
    if ( source == GUIEditor.button[1] ) then 
        triggerServerEvent ( "onCreateEvent", getRootElement(), localPlayer)  
        local year = getRealTime()["year"] + 1900 
        local month = getRealTime()["month"] + 1 
        local monthday = getRealTime()["monthday"] 
        local hour = getRealTime()["hour"] 
        local minute = getRealTime()["minute"] 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, "["..hour..":"..minute.."-"..monthday.."."..month.."."..year.."] "..getPlayerName(localPlayer).." created event ", true, true ) 
        end 
end 
) 

Thats because you need to loop a table, and create a row every index.
Link to comment
now working but show just what i create i want all player

Because that code is clientside, if you want to show all players whenever any player to create an event, you can use triggerServerEvent or setElementData and put the player name who created the event, then add it in gridList with guiGridListAddRow and guiGridListSetItemText.

Edit:

  
addEventHandler ( "onClientGUIClick", root, 
function ( ) 
    if ( source == GUIEditor.button[1] ) then 
        --triggerServerEvent ( "onCreateEvent", getRootElement(), localPlayer) 
        setElementData(GUIEditor.gridlist[1], "curEventAuthor", getPlayerName(localPlayer)) 
    end 
end 
) 
  
addEvent("addNewRow") 
addEventHandler("addNewRow", root, 
function(playerName) 
    local year = getRealTime()["year"] + 1900 
    local month = getRealTime()["month"] + 1 
    local monthday = getRealTime()["monthday"] 
    local hour = getRealTime()["hour"] 
    local minute = getRealTime()["minute"] 
    local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
    guiGridListSetItemText(GUIEditor.gridlist[1], row, column, "["..hour..":"..minute.."-"..monthday.."."..month.."."..year.."] "..playerName.." created event ", false, false) 
end) 
  
addEventHandler( "onClientElementDataChange", root, 
function (dataName, oldValue) 
    if (dataName == "curEventAuthor") then 
        local playerName = getElementData(source, dataName) 
        triggerEvent("addNewRow", root, playerName) 
    end 
end 
) 
  
local _setElementData = setElementData 
function setElementData(elem, theKey, value) 
    if (theKey == "curEventAuthor") then 
        if (getElementData(GUIEditor.gridlist[1], "curEventAuthor") == value) then 
            triggerEvent("addNewRow", root, value) 
        end 
    end 
    _setElementData(elem, theKey, value) 
end 
  

Try it.

Link to comment

i get idea i make log event with xml and working. how make show all log in guiGridList ?

make this ?

        local xmlfile = xmlLoadFile ( "eventlog.xml" ) 
        if xmlfile then 
            local NewNode = xmlNodeGetChildren( xmlfile) 
            for i,node in pairs(NewNode) do 
                local text = xmlNodeGetValue(node) 
                guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, text, false, false ) 
            end 
        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...