Jump to content

Playerlist [Gridlist]


FSXTim

Recommended Posts

Guest Guest4401
How can I get the selected player (function/event)?
guiGridListGetSelectedItem 
guiGridListGetItemText 
getPlayerFromName -- to get player element from the selected item (string) 

Link to comment

try:

function whatever ( ) 
    if ( source == yourGridVariable ) 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 
                --whatever 
            end 
        end 
    end 
end 
addEventHandler ( "onClientGUIClick", root, whatever ) 

Link to comment

Thanks, sir!

I'm alone on my server, so I cannot test the script, is it correct?

(!)clientside(!)

function msgToPlayer (state) 
    if state == "left" then 
        if source == GUIEditor_ButtonSenden then 
            row, col = guiGridListGetSelectedItem ( source ) 
            if ( row and col and row ~= -1 and col ~= -1 ) then 
                local playername = guiGridListGetItemText (GUIEditor_Grid[1], row, col) 
                local targetPlayer = getPlayerFromName (playername)           
                if targetPlayer then 
                    local localp = getLocalPlayer() 
                    local memoText = guiGetText(GUIEditor_MemoText) 
                    if memoText ~= "" and memoText:len() > 1 then 
                        outputChatBox("SMS von #FFFFFF"..localp..": #FF8C00"..memoText.."", targetPlayer, 255, 140, 0, true) 
                    else 
                        outputChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) 
                    end  
                end  
            end  
        end 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), msgToPlayer)  

Greets

Link to comment
Guest Guest4401

It's not correct

                        outputChatBox("SMS von #FFFFFF"..localp..": #FF8C00"..memoText.."", targetPlayer, 255, 140, 0, true) 

There is no visibleTo argument in outputChatBox if used clientside.

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