proracer Posted January 22, 2011 Share Posted January 22, 2011 So have started making it.Only thing is it won't output the message in chatbox. ---- Clientsided function cgui() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 629,451 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) GUIEditor_Button = {} GUIEditor_Edit = {} GUIEditor_Grid = {} showCursor(true,true) PM_Main_Window = guiCreateWindow(X,Y,Width,Height,"PM System by Pr0RaC3R v0.1 Alpha",false) guiWindowSetSizable(PM_Main_Window,false) GUIEditor_Grid[1] = guiCreateGridList(9,20,611,206,false,PM_Main_Window) GUIEditor_Edit[1] = guiCreateEdit(9,226,611,141,"",false,PM_Main_Window) guiEditSetMaxLength(GUIEditor_Edit[1],100) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) GUIEditor_Button[1] = guiCreateButton(181,379,240,56,"Send message",false,PM_Main_Window) local column = guiGridListAddColumn(GUIEditor_Grid[1],"Player Name",0.2) if (column) then for id,player in ipairs (getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1],row,column,getPlayerName(player),false,false) end end end function playerPressButton (button,state,AbsoluteX,AbsoluteY) if (source == GUIEditor_Button[1]) then local text = guiGetText (GUIEditor_Edit[1]) outputChatBox(text) end end addCommandHandler("pm",cgui) I think the error should be between lines 27-33. Link to comment
Castillo Posted January 22, 2011 Share Posted January 22, 2011 try this o_o, ---- Clientsided function cgui() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 629,451 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) GUIEditor_Button = {} GUIEditor_Edit = {} GUIEditor_Grid = {} showCursor(true,true) PM_Main_Window = guiCreateWindow(X,Y,Width,Height,"PM System by Pr0RaC3R v0.1 Alpha",false) guiWindowSetSizable(PM_Main_Window,false) GUIEditor_Grid[1] = guiCreateGridList(9,20,611,206,false,PM_Main_Window) GUIEditor_Edit[1] = guiCreateEdit(9,226,611,141,"",false,PM_Main_Window) guiEditSetMaxLength(GUIEditor_Edit[1],100) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) GUIEditor_Button[1] = guiCreateButton(181,379,240,56,"Send message",false,PM_Main_Window) local column = guiGridListAddColumn(GUIEditor_Grid[1],"Player Name",0.2) if (column) then for id,player in ipairs (getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1],row,column,getPlayerName(player),false,false) end end end function playerPressButton (button,state,AbsoluteX,AbsoluteY) if (source == GUIEditor_Button[1]) then local text = guiGetText (GUIEditor_Edit[1]) outputChatBox(tostring(text)) end end addCommandHandler("pm",cgui) Link to comment
proracer Posted January 23, 2011 Author Share Posted January 23, 2011 Hmm it still doesn't work... no errors. Link to comment
Castillo Posted January 23, 2011 Share Posted January 23, 2011 uhm, where is the event handler for the button? Link to comment
proracer Posted January 23, 2011 Author Share Posted January 23, 2011 Yeah lol... forgot it when I was changing something in code.The new code says that I have bad argument in the onClientGUIClick event. ---- Clientsided function cgui() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 629,451 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) GUIEditor_Button = {} GUIEditor_Edit = {} GUIEditor_Grid = {} showCursor(true,true) PM_Main_Window = guiCreateWindow(X,Y,Width,Height,"PM System by Pr0RaC3R v0.1 Alpha",false) guiWindowSetSizable(PM_Main_Window,false) GUIEditor_Grid[1] = guiCreateGridList(9,20,611,206,false,PM_Main_Window) GUIEditor_Edit[1] = guiCreateEdit(9,226,611,141,"",false,PM_Main_Window) guiEditSetMaxLength(GUIEditor_Edit[1],100) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) GUIEditor_Button[1] = guiCreateButton(181,379,240,56,"Send message",false,PM_Main_Window) local column = guiGridListAddColumn(GUIEditor_Grid[1],"Player Name",0.2) if (column) then for id,player in ipairs (getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1],row,column,getPlayerName(player),false,false) addEventHandler("onClientGUIClick", GUIEditor_Button[1], playerPressButon) -- here is the event handler now end end end function playerPressButton (button,state,AbsoluteX,AbsoluteY) if (source == GUIEditor_Button[1]) then local text = guiGetText (GUIEditor_Edit[1]) outputChatBox(tostring(text)) end end addCommandHandler("pm",cgui) Link to comment
Castillo Posted January 23, 2011 Share Posted January 23, 2011 look carefully: addEventHandler("onClientGUIClick", GUIEditor_Button[1], playerPressButon) "BUTON" and must be: "BUTTON" Link to comment
proracer Posted January 23, 2011 Author Share Posted January 23, 2011 Oh jesus christ ^^ nice find thx it works now.I go sleep and later I'm gonna try that it outputs message to specific player Link to comment
proracer Posted January 23, 2011 Author Share Posted January 23, 2011 Can you guys give me any hint that when player selects specific player and types in edit box and presses the 'send message' button it outputs message to him.I have tried searching some resources and looking into admin panel of how "shout" function works but it's too complicated for me. Link to comment
SDK Posted January 23, 2011 Share Posted January 23, 2011 If you want it the easy way (server) use texts: https://wiki.multitheftauto.com/wiki/TextCreateTextItem Or use gui labels clientside. Ofc you first need to send the message to the server and then use one of these 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