Jump to content

PM System (Tables)


WolfPire

Recommended Posts

So i'm having some problems with tables as whenever i click in another player. The tab will create itself 2 times aswell as the memo.

So this is obviously a problem with tables, i'm not an expert with them at all and i wish you guys could lend me a hand on this one, Thanks in advance =)

Client

MainFor = {} 
tabpFor = {} 
tabFor = {} 
ChatMeFor = {} 
  
MainFor[localPlayer] = guiCreateWindow(278, 10, 513, 391, "Endless Night Life - PM System", false) 
guiWindowSetSizable(MainFor[localPlayer], false) 
  
MsgM = guiCreateMemo(11, 320, 367, 62, "", false, MainFor[localPlayer]) 
SendB = guiCreateButton(382, 321, 122, 59, "Send / Enviar", false, MainFor[localPlayer]) 
guiSetProperty(SendB, "NormalTextColour", "FFAAAAAA") 
PlayerGL = guiCreateGridList(379, 45, 125, 269, false, MainFor[localPlayer]) 
tabpFor[localPlayer] = guiCreateTabPanel(9, 21, 495, 20, false, MainFor[localPlayer]) 
guiSetVisible(MainFor[localPlayer], false) 
PM = false 
  
function bindPM() 
    bindKey("F5", "down", 
        function() 
            if PM == false then 
                PM = true 
                showCursor(true) 
                guiSetVisible(MainFor[localPlayer], true) 
                guiSetInputMode("no_binds") 
                PlayerC = guiGridListAddColumn(PlayerGL, "Players", 0.9) 
                for id, player in pairs(getElementsByType("player")) do 
                row = guiGridListAddRow ( PlayerGL ) 
                guiGridListSetItemText ( PlayerGL, row, PlayerC, getPlayerName ( player ), false, false ) 
                end 
                elseif PM == true then 
                PM = false 
                guiSetInputMode("allow_binds") 
                showCursor(false) 
                guiGridListRemoveRow(PlayerGL, row) 
                guiGridListRemoveColumn(PlayerGL, PlayerC) 
                guiSetVisible(MainFor[localPlayer], false) 
            end 
        end 
    ) 
end 
  
addEventHandler("onClientResourceStart", root, bindPM) 
  
function createChat() 
    if not tabFor[playerDat] then 
        if not ChatMeFor[playerDat] then 
            playerName = guiGridListGetItemText ( PlayerGL, guiGridListGetSelectedItem ( PlayerGL ), 1 ) 
            playerDat = getPlayerFromName(playerName) 
            outputChatBox(tostring(localPlayer)) 
            outputChatBox(tostring(playerDat)) 
            playerName = guiGridListGetItemText ( PlayerGL, guiGridListGetSelectedItem ( PlayerGL ), 1 ) 
            tabFor[localPlayer] = guiCreateTab ( playerName, tabpFor[localPlayer] ) 
            ChatMeFor[localPlayer] = guiCreateMemo(10, 44, 366, 269, "", false, MainFor[localPlayer]) 
            guiMemoSetReadOnly ( ChatMeFor[localPlayer], true ) 
            tabFor[playerDat] = guiCreateTab ( playerName, tabpFor[playerDat] ) 
            ChatMeFor[playerDat] = guiCreateMemo(10, 44, 366, 269, "", false, MainFor[playerDat]) 
            guiMemoSetReadOnly ( ChatMeFor[playerDat], true ) 
        end 
        else 
        outputChatBox("You're already talking with that person!", 255, 0 ,0) 
    end 
end 
  
addEventHandler("onClientGUIClick", PlayerGL, createChat, false) 
  
function sendMsg() 
    playerName = guiGridListGetItemText ( PlayerGL, guiGridListGetSelectedItem ( PlayerGL ), 1 ) 
    playerDat = getPlayerFromName(playerName) 
    Msg = guiGetText(MsgM) 
    guiSetText (ChatMeFor[localPlayer], guiGetText ( ChatMeFor[localPlayer] )..""..getPlayerName ( localPlayer )..": "..Msg ) 
    guiSetText(ChatMeFor[playerDat], ChatMeFor[playerDat] .."".. playerName ..": "..Msg ) 
end 
  
addEventHandler("onClientGUIClick", SendB, sendMsg, false) 

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