Mann56 Posted May 19, 2015 Posted May 19, 2015 Hey there, I need some help i have created a gridlist which gets all player names but i can't figure out how to send the selected player the message . I used the following function. pmer = localPlayer selectedPlayer = guiGridListGetSelectedItem(gridThing) guiSetInputEnabled(true) pmto = getPlayerFromName(selectedPlayer) text = guiGetText(editBox) outputChatBox("[PM] -> "..selectedPlayer.." : "..text.."",localPlayer,255,255,0) outputChatBox("[PM] -> "..pmer.." : "..text.."",selectedPlayer,255,255,0) As i am alone on my local i exactly dont know will it work but is the function guiGridListGetSelectedItem ok? As there is no related function other than this. I would look for some help.... Thanks...
Walid Posted May 19, 2015 Posted May 19, 2015 no, you need to use guiGridListGetItemText. local playerName = guiGridListGetItemText(gridThing,row,Column) local player = getPlayerFromName(playerName) if player then end and the outputChatBox must be server side.
Mann56 Posted May 19, 2015 Author Posted May 19, 2015 no, you need to use guiGridListGetItemText. local playerName = guiGridListGetItemText(gridThing,row,Column) local player = getPlayerFromName(playerName) if player then end and the outputChatBox must be server side. Thanks the functions were a bit complicated by names and so i must trigger sver event?
Walid Posted May 19, 2015 Posted May 19, 2015 Thanks the functions were a bit complicated by names and so i must trigger sver event? Yeh, example function SendMessage () local row,column = guiGridListGetSelectedItem (gridThing) if row == -1 then return end if row and column and row >=0 and column >=0 then local playerName = guiGridListGetItemText(gridThing,row,colmun) local player = getPlayerFromName(playerName) if player then local text = guiGetText(editBox) if text then triggerServerEvent( "onPlayerSendPM", localPlayer,text, player) guiSetText (editBox, "" ) end end end end
Mann56 Posted May 19, 2015 Author Posted May 19, 2015 Dude the trigger server event has 4 args? Edit : Dude ain't working here's my code: Client: local pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) gridThing = guiCreateGridList(12, 29, 331, 468, false, pmWindow) column = guiGridListAddColumn(gridThing, "Name", 0.9) editBox = guiCreateEdit(15, 510, 291, 29, "", false, pmWindow) closeButton = guiCreateButton(315, 509, 28, 30, "Send", false, pmWindow) guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") guiSetVisible(pmWindow, false) showCursor(false) local pmEnabled = false function dxText () if not pmEnabled then return end dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender", root, dxText) function togglePM () pmEnabled = not pmEnabled guiSetVisible(pmWindow, pmEnabled) showCursor(pmEnabled) end bindKey("F3","up", togglePM) function showDxText() addEventHandler("onClientRender", root, function() dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), function () for i,v in pairs(getElementsByType("player")) do row = guiGridListAddRow(gridThing) guiGridListSetItemText ( gridThing, row, column, getPlayerName ( v ), false, false ) end end ) function SendMessage () pmer = localPlayer local row,column = guiGridListGetSelectedItem (gridThing) if row == -1 then return end if row and column and row >=0 and column >=0 then local playerName = guiGridListGetItemText(gridThing,row,colmun) local player = getPlayerFromName(playerName) if player then local text = guiGetText(editBox) if text then triggerServerEvent( "onPlayerSendPM", localPlayer,text, player) guiSetText (editBox, "" ) end end end end addEventHandler("onClientGuiClick",closeButton,SendMessage) Server addEvent("onPlayerSendPm",true) addEventHandler("onPlayerSendPm",resourceRoot, function (text,player,) outputChatBox("[PM] -> "..player.." : "..text.."",client,255,255,0) outputChatBox("[PM] -> "..pmer.." : "..text.."",player,255,255,0) end )
Walid Posted May 19, 2015 Posted May 19, 2015 Many things wrong in your code pmer it's not defined here
Mann56 Posted May 19, 2015 Author Posted May 19, 2015 Many things wrong in your codepmer it's not defined here it's defined in client
Walid Posted May 19, 2015 Posted May 19, 2015 it's defined in client are you serious so why you use it server side ??? anyways try this -- Client side local pmEnabled = false addEventHandler("onClientResourceStart",resourceRoot, function () pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) gridThing = guiCreateGridList(12, 29, 331, 468, false, pmWindow) column = guiGridListAddColumn(gridThing, "Name", 0.9) editBox = guiCreateEdit(15, 510, 291, 29, "", false, pmWindow) closeButton = guiCreateButton(315, 509, 28, 30, "Send", false, pmWindow) guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") guiSetVisible(pmWindow, false) showCursor(false) addEventHandler("onClientGuiClick",closeButton,SendMessage,false) end ) function dxText () if not pmEnabled then return end dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender", root, dxText) function togglePM () pmEnabled = not pmEnabled guiSetVisible(pmWindow, pmEnabled) showCursor(pmEnabled) for i,v in pairs(getElementsByType("player")) do local row = guiGridListAddRow(gridThing) guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) end end bindKey("F3","up", togglePM) function SendMessage () local row,column = guiGridListGetSelectedItem (gridThing) if row == -1 then return end if row and column and row >=0 and column >=0 then local playerName = guiGridListGetItemText(gridThing,row,colmun) local player = getPlayerFromName(playerName) if player then local text = guiGetText(editBox) if text =~ "" then triggerServerEvent( "onPlayerSendPM",resourceRoot,text, player) guiSetText (editBox, "" ) end end end end -- Server side addEvent("onPlayerSendPm",true) addEventHandler("onPlayerSendPm",resourceRoot, function (text,player) outputChatBox("[PM] -> "..getPlayerName(player).." : "..text.."",client,255,255,0) outputChatBox("[PM] -> "..getPlayerName(client).." : "..text.."",player,255,255,0) end )
Mann56 Posted May 19, 2015 Author Posted May 19, 2015 Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c
Walid Posted May 19, 2015 Posted May 19, 2015 (edited) Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c simply you need to use "guiGridListClear()" before you add player names inside the gridlist. Edited May 19, 2015 by Guest
Mann56 Posted May 19, 2015 Author Posted May 19, 2015 Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c simply you do use "guiGridListClear()" before you add player names inside the gridlist. oh, i gotta go through all gui functions
Walid Posted May 19, 2015 Posted May 19, 2015 oh, i gotta go through all gui functions function togglePM () pmEnabled = not pmEnabled guiSetVisible(pmWindow, pmEnabled) showCursor(pmEnabled) guiGridListClear (gridThing) for i,v in pairs(getElementsByType("player")) do local row = guiGridListAddRow(gridThing) guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) end end bindKey("F3","up", togglePM)
Mann56 Posted May 20, 2015 Author Posted May 20, 2015 oh, i gotta go through all gui functions function togglePM () pmEnabled = not pmEnabled guiSetVisible(pmWindow, pmEnabled) showCursor(pmEnabled) guiGridListClear (gridThing) for i,v in pairs(getElementsByType("player")) do local row = guiGridListAddRow(gridThing) guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) end end bindKey("F3","up", togglePM) Working now nvm there were some spelling mistakes LOL
Walid Posted May 20, 2015 Posted May 20, 2015 Working now nvm there were some spelling mistakes LOL there is many thig wrong in your code. sorry i don't have time to fix them all
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