Replace this with your client code:
local GUIEditor = {
label = {},
}
local newmsg =
{
show = false,
tick = getTickCount ( ),
showtime = 5000
}
addEventHandler("onClientResourceStart", resourceRoot,
function()
yourGui = guiCreateWindow(405, 62, 682, 451, "privát beszélgetés by turbesz", false)
guiWindowSetSizable(yourGui, false)
close = guiCreateButton(646, 20, 26, 26, "X", false, yourGui)
guiSetProperty(close, "NormalTextColour", "FFFF0000")
bb = guiCreateButton(658, 33, 172, 22, "Privát beszélgetés", false)
guiSetVisible(bb,true)
grdPlayers = guiCreateGridList(0.0991,0.2449,0.8108,0.6968, true, yourGui)
colPlayers = guiGridListAddColumn(grdPlayers, "Játékosok", 0.85)
guiSetVisible(yourGui,false)
GUIEditor.label[1] = guiCreateLabel(24, 22, 620, 82, "Szia, üdvözöllek a FullFunPlay egyedi Privát üzenet rendszerében! \"{SMILIES_PATH}/icon_wink.gif\" alt=\"\" title=\"Wink\" /> \n\nVálassz ki valakit, és kattints duplán (kétszer) a nevére, utána megnyillik a csevegő ablak, ahol nyugodtan, mindenki hátamögött (kivéve turbeszt persze:3) beszélhettek a pucér nagy mellű nőkről, vagy akármiről, ez whatever.", false, yourGui)
guiLabelSetHorizontalAlign(GUIEditor.label[1], "left", true)
-- events
addEventHandler("onClientGUIClick",bb,clickButtonBB,false)
addEventHandler ( "onClientGUIClick", close, Bezaras,false)
end
)
-- add all players to your gridlist
function addPlayersToGridlist()
guiGridListClear(grdPlayers)
local players = getElementsByType("player")
for index, player in pairs(players) do
local row = guiGridListAddRow(grdPlayers)
local name = getPlayerName(player)
guiGridListSetItemText(grdPlayers, row,1, name, false, false)
end
end
-- open the Gui when the player click bb button
function clickButtonBB()
if not guiGetVisible (yourGui) then
guiSetVisible(yourGui,true)
showCursor(true)
addPlayersToGridlist()
else
guiSetVisible(yourGui,false)
showCursor(false)
end
end
-- close the gui when the player click the close button
function Bezaras()
if guiGetVisible (yourGui) then
guiSetVisible(yourGui, false)
showCursor ( false )
end
end
function buildChatWindow(ply)
local x,y = guiGetScreenSize()
local width,height = 300,250
x = x*.5
y = y*.5
chat[ply] = {}
chat[ply].wnd = guiCreateWindow(337,277,395,252, getPlayerName(ply), false)
chat[ply].img = guiCreateStaticImage(0.0228,0.0754,0.9544,0.8889,"image/shruk.png",true,chat[ply].wnd)
chat[ply].memo = guiCreateMemo(0.043,0.1746,0.9089,0.623, "", true, chat[ply].wnd)
chat[ply].edit = guiCreateEdit(0.043,0.8214,0.7089,0.1111, "", true, chat[ply].wnd)
chat[ply].btnX = guiCreateButton(0.9215,0.0754,0.0557,0.0794, "X", true, chat[ply].wnd)
chat[ply].btnSend = guiCreateButton(0.757,0.8135,0.2127,0.1429, "Küldés", true, chat[ply].wnd)
guiSetProperty(chat[ply].img,"Disabled","true")
guiMemoSetReadOnly(chat[ply].memo, true)
guiWindowSetSizable(chat[ply].wnd, false)
guiSetProperty(chat[ply].wnd, "RollUpEnabled", "true")
guiSetProperty(chat[ply].wnd, "Dragable", "true")
end
function sendChatMessage(ply)
outputDebugString("sendChatMessage: " .. tostring(ply))
if chat[ply] and isElement(chat[ply].wnd) then
local newText = guiGetText(chat[ply].edit)
if newText and string.len(newText) > 0 then
local oldText = guiGetText(chat[ply].memo)
if not oldText then oldText = "" end
oldText = oldText .. getPlayerName(g_LocalPlayer) .. ": " .. newText .. "\n"
guiSetText(chat[ply].memo, oldText)
guiSetText(chat[ply].edit, "")
guiMemoSetCaretIndex(chat[ply].memo, string.len(oldText))
triggerServerEvent("onGUIPrivateMessage", g_LocalPlayer, ply,newText)
end
end
end
function recieveChatMessage(ply, msg)
outputDebugString("recieveChatMessage: " .. msg)
if not chat[ply] then
buildChatWindow(ply)
end
end
newmsg.show = true
newmsg.tick = getTickCount()
guiSetText(newmsg.lbl, getPlayerName(ply) .. ": " .. msg .. "\n")
guiSetText(newmsg.lbl, "Üzenet tőle " .. getPlayerName(ply) .. "\n")
outputChatBox("Üzeneted érkezett. Nyomj F3-at hogy megnézd.",255,255,255,true)
local sound = playSound("GatkResalh~.mp3",false)
setSoundVolume(sound, 0.2)
event_player_join = function()
--outputDebugString("onClientPlayerJoin")
addPlayersToGridlist(source)
end
event_player_quit = function()
--outputDebugString("onClientPlayerQuit")
removePlayerFromGridList(source)
destroyChatWindow(source)
end
event_gui_doubleclick = function(button, state, absx, absy)
if button == "left" and state == "up" then
if source == grdPlayers then
local row, col = guiGridListGetSelectedItem(grdPlayers)
--outputDebugString("double clicked row: "..tostring(row))
if row == -1 or col == -1 then return end
local name = guiGridListGetItemText(grdPlayers, row, col)
local ply = getPlayerFromName(name)
if not chat[ply] then
buildChatWindow(ply)
end
guiBringToFront(chat[ply].wnd)
end
end
end
event_gui_accepted = function(element)
local parent = getElementParent(source)
if parent ~= false then
local ply = getPlayerFromName(guiGetText(parent))
if ply then
if element == chat[ply].edit then
sendChatMessage(ply)
end
end
end
end
event_render = function()
if newmsg.show == true then
if getTickCount() > newmsg.tick + newmsg.showtime then
anims.nmfadeout:play()
anims.nmtextout:play()
newmsg.show = false
end
end
end
addEvent("onPrivateChatSent", true)
addEventHandler("onPrivateChatSent", g_Root, recieveChatMessage)
addEventHandler("onClientResourceStart", g_ResourceRoot, event_resource_start)
addEventHandler("onClientResourceStop", g_ResourceRoot, event_resource_stop)
addEventHandler("onClientGUIDoubleClick", g_ResourceRoot, event_gui_doubleclick)
addEventHandler("onClientGUIClick", g_ResourceRoot, event_gui_click)
addEventHandler("onClientGUIAccepted", g_ResourceRoot, event_gui_accepted)
addEventHandler("onClientPlayerJoin", g_Root, event_player_join)
addEventHandler("onClientPlayerQuit", g_Root, event_player_quit)
addEventHandler("onClientRender", g_Root, event_render)