Jump to content

guiGridListGetItem issue


Recommended Posts

function attivaSceltaPersonaggi() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    local sx, sy = screenWidth/1440, screenHeight/900 
    listapersonaggi = guiCreateGridList(360*sx, 185*sy, 320*sx, 168*sy, false) 
    guiGridListSetSelectionMode(listapersonaggi, 2) 
    guiSetVisible(listapersonaggi, false) 
    creapgbutt = guiCreateButton(360*sx, 366*sy, 120*sx, 80*sy, "Crea Personaggio", false) 
    eliminapgbutt = guiCreateButton(560*sx, 368*sy, 120*sx, 80*sy, "Elimina Personaggio", false) 
    selezionapgbutt = guiCreateButton(460*sx, 500*sy, 150*sx, 50*sy, "SELEZIONA", false) 
    guiSetVisible(creapgbutt, false) 
    guiSetVisible(eliminapgbutt, false) 
    guiSetVisible(selezionapgbutt, false) 
    addEventHandler("onClientGUIClick", selezionapgbutt, spawnaPg, false) 
    addEventHandler("onClientGUIClick", creapgbutt, creaPg, false) 
end 
  
addEvent("onSceltaPersonaggioAttiva", true) 
addEventHandler("onSceltaPersonaggioAttiva", getRootElement(), attivaSceltaPersonaggi) 
function spawnaPg(button, state, absoluteX, absoluteY) -- Funzione invio spawn Personaggio SERVER 
    --outputChatBox(itemselezionato) 
    local riga, colonna = guiGridListGetSelectedItem ( listapersonaggi ) 
    local itemselezionato = guiGridListGetItemText ( listapersonaggi, riga, colonna ) 
    if button == "left" then 
        if state == "up" then 
            outputChatBox(riga .. colonna) 
            if riga ~= -1 and colonna ~= -1 then 
                outputChatBox(itemselezionato) 
                disattivaSelezionePersonaggio() 
                showCursor(false) 
                stopSound(logintheme) 
                triggerServerEvent("spawnaPersonaggio", localPlayer, itemselezionato) 
            else 
                outputChatBox("ERROR: Niente selezionato.") 
            end 
        end 
    end 
end 

Edited by Guest
Link to comment

I know that and i asking you to show the server side as you're doing trigger from the server to the client side and from client side to server side of course this will affect the client side if you doing it wrong, also column is not defined and i can't see the function disattivaSelezionePersonaggio and where are you adding any row in the gird list.

Link to comment
function spawnaPersonaggioF(itemselezionato) 
    --print(itemselezionato) 
    --outputChatBox(itemselezionato) 
    --if client then 
        --if source == sourceRoot then 
            print("lezzetti") 
            setPlayerName(client, itemselezionato) 
            spawnPlayer(client, 0.0, 0.0, 4.0) 
            fadeCamera(client, true) 
            setCameraTarget(client) 
        --end 
    --end 
end 
  
addEvent("spawnaPersonaggio", true) 
addEventHandler("spawnaPersonaggio", root, spawnaPersonaggioF) 

Link to comment

Client-side:

function attivaSceltaPersonaggi() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    local sx, sy = screenWidth/1440, screenHeight/900 
    listapersonaggi = guiCreateGridList(360*sx, 185*sy, 320*sx, 168*sy, false) 
    guiGridListSetSelectionMode(listapersonaggi, 2) 
    guiSetVisible(listapersonaggi, false) 
    creapgbutt = guiCreateButton(360*sx, 366*sy, 120*sx, 80*sy, "Crea Personaggio", false) 
    eliminapgbutt = guiCreateButton(560*sx, 368*sy, 120*sx, 80*sy, "Elimina Personaggio", false) 
    selezionapgbutt = guiCreateButton(460*sx, 500*sy, 150*sx, 50*sy, "SELEZIONA", false) 
    guiSetVisible(creapgbutt, false) 
    guiSetVisible(eliminapgbutt, false) 
    guiSetVisible(selezionapgbutt, false) 
    addEventHandler("onClientGUIClick", selezionapgbutt, spawnaPg, false) 
    addEventHandler("onClientGUIClick", creapgbutt, creaPg, false) 
end 
  
addEvent("onSceltaPersonaggioAttiva", true) 
addEventHandler("onSceltaPersonaggioAttiva", getRootElement(), attivaSceltaPersonaggi) 
function spawnaPg(button, state, absoluteX, absoluteY) -- Funzione invio spawn Personaggio SERVER 
    --outputChatBox(itemselezionato) 
    local riga, colonna = guiGridListGetSelectedItem ( listapersonaggi ) 
    local itemselezionato = guiGridListGetItemText ( listapersonaggi, riga, colonna ) 
    if button == "left" then 
        if state == "up" then 
            outputChatBox("Riga: " .. riga .. " Colonna: " .. colonna) 
            if riga ~= -1 and colonna ~= -1 then 
                outputChatBox(itemselezionato) 
                disattivaSelezionePersonaggio() 
                showCursor(false) 
                stopSound(logintheme) 
                triggerServerEvent("spawnaPersonaggio", localPlayer, itemselezionato) 
            else 
                outputChatBox("ERROR: Niente selezionato.") 
            end 
        end 
    end 
end 

Server-side:

function spawnaPersonaggioF(itemselezionato) 
    --print(itemselezionato) 
    --outputChatBox(itemselezionato) 
    --if client then 
        --if source == sourceRoot then 
            print("test") 
            setPlayerName(client, itemselezionato) 
            spawnPlayer(client, 0.0, 0.0, 4.0) 
            fadeCamera(client, true) 
            setCameraTarget(client) 
        --end 
    --end 
end 
  
addEvent("spawnaPersonaggio", true) 
addEventHandler("spawnaPersonaggio", root, spawnaPersonaggioF) 

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...