Turbesz Posted July 22, 2016 Share Posted July 22, 2016 codes: --client bb = guiCreateButton(999, 0, 99, 35, "Privát üzenetek", false) guiSetVisible(bb,true) --- DONT TRY TO COPY LITTLE BITCH g_LocalPlayer = getLocalPlayer() g_Root = getRootElement() g_ThisResource = getThisResource() g_ResourceRoot = getResourceRootElement(getThisResource()) chat = {} -- table to store chat windows in newmsg = {show=false, tick=getTickCount(), showtime=5000, img=nil, lbl=nil } -- new msg table anims = {} function buildPlayerList() local x,y = guiGetScreenSize() local width,height = 175,350 x = x-width y = (y-height)/2 newmsg.img = guiCreateStaticImage(681.0000,134.0000, 42.0000,34.0000, "image/chat-icon.png", false) -- mail message icon newmsg.lbl = guiCreateLabel(553.0000,175.0000, 244.0000, 19.0000, "", false) guiLabelSetColor(newmsg.lbl,0, 170, 255) guiLabelSetHorizontalAlign(newmsg.lbl, "right", true) guiSetAlpha(newmsg.img, 0) --guiSetAlpha(newmsg.lbl, 0) wndPlayers = guiCreateWindow(-1,256,222,343, "Privát üzenetek", false) fond = guiCreateStaticImage(0.0405,0.0525,0.9189,0.9213,"image/mtalogo.png",true,wndPlayers) grdPlayers = guiCreateGridList(0.0991,0.2449,0.8108,0.6968, true, wndPlayers) colPlayers = guiGridListAddColumn(grdPlayers, "Játékosok", 0.85) local players = getElementsByType("player") for k,v in ipairs(players) do addPlayerToList(v) end guiSetProperty(fond,"Disabled","true") guiWindowSetSizable(wndPlayers, false) guiSetProperty(wndPlayers, "RollUpEnabled", "true") guiSetProperty(wndPlayers, "Dragable", "true") guiSetAlpha(wndPlayers, 0) --[[ local x,y = guiGetPosition(newmsg.img) outputDebugString("guigetPostions: " ..tostring(x).." "..tostring(y)) local scrx,scry = guiGetScreenSize() anims.nmslidein = Animation.create(newmsg.img, Animation.presets.guiMove(x,y))--, 1000,false, scrx,scry, false)) anims.nmslideout = Animation.create(newmsg.img, Animation.presets.guiMove(scrx,scry))--, 1000,false, x,y, false)) ]] --bindKey("F3", "down", togglePmGui) end function addPlayerToList(ply) --outputDebugString("addPlayerToList:" ..getPlayerName(ply)) local row = guiGridListAddRow(grdPlayers) local name = getPlayerName(ply) guiGridListSetItemText(grdPlayers,row,colPlayers, name, false, false) end function removePlayerFromList(ply) --outputDebugString("removePlayerFromList:" ..getPlayerName(ply)) local name=getPlayerName(ply) for row=0,guiGridListGetRowCount(grdPlayers) do if guiGridListGetItemText(grdPlayers, row, colPlayers) == name then guiGridListRemoveRow(grdPlayers, row) outputDebugString("remove row" ..tostring(row)) end end 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 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) anims.nmfadein:play() anims.nmtextin:play() --anims.nmslidein:play() local oldText = guiGetText(chat[ply].memo) if not oldText then oldText = "" end oldText = oldText .. getPlayerName(ply) .. ": " .. msg .. "\n" guiSetText(chat[ply].memo, oldText) guiMemoSetCaretIndex(chat[ply].memo, string.len(oldText)) end event_resource_start = function(res) buildPlayerList() end event_player_join = function() --outputDebugString("onClientPlayerJoin") addPlayerToList(source) end event_player_quit = function() --outputDebugString("onClientPlayerQuit") removePlayerFromList(source) destroyChatWindow(source) end event_gui_click = function(button, state, absx, absy) if button == "left" and state == "up" then if getElementType(source) == "gui-button" then local parent = getElementParent(source) if parent ~= false then local ply = getPlayerFromName(guiGetText(parent)) if ply then if source == chat[ply].btnX then destroyChatWindow(ply) guiSetInputEnabled(false) elseif source == chat[ply].btnSend then sendChatMessage(ply) guiSetInputEnabled(false) end end end elseif getElementType(source) == "gui-edit" then local parent = getElementParent(source) if parent ~= false then local ply = getPlayerFromName(guiGetText(parent)) if source == chat[ply].edit then guiSetInputEnabled(true) end end else guiSetInputEnabled(false) end end 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) guiSetVisible(wndPlayers,false) addEventHandler("onClientGUIClick",root, function () if source == bb then guiSetVisible(wndPlayers,true) end end ) --server addEvent("onGUIPrivateMessage", true) addEventHandler("onGUIPrivateMessage", getRootElement(), function(toplayer, text) triggerClientEvent(toplayer, "onPrivateChatSent", source, source, text) end ) what wrong?:c Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now