PrivateKiller Posted October 28, 2014 Share Posted October 28, 2014 Hello! I have a problem. I don't know how to merge this, to make it work. I'm using it in serverside. Please help me function Advertisment(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} for index, player in ipairs ( players ) do outputChatBox( "Advertisment from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 0, 190, 40) end end addCommandHandler( "ad", Advertisment ) GUIEditor = { button = {}, window = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(455, 192, 343, 133, "Advert cost 500€. Click button below to buy it!", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.memo[1] = guiCreateMemo(20, 38, 304, 58, "", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(65, 102, 219, 21, "Buy Advert!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") end ) Link to comment
manve1 Posted October 28, 2014 Share Posted October 28, 2014 I'm using it in serverside. Please help me GUI is clientside. Link to comment
PrivateKiller Posted October 28, 2014 Author Share Posted October 28, 2014 I'm using it in serverside. Please help me GUI is clientside. Serverside: function Advertisment(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} for index, player in ipairs ( players ) do outputChatBox( "Advertisment from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 0, 190, 40) end end addCommandHandler( "ad", Advertisment ) Client: GUIEditor = { button = {}, window = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(455, 192, 343, 133, "Advert cost 500€. Click button below to buy it!", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.memo[1] = guiCreateMemo(20, 38, 304, 58, "", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(65, 102, 219, 21, "Buy Advert!", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") end ) What now? Help me please Link to comment
PrivateKiller Posted October 28, 2014 Author Share Posted October 28, 2014 What I need to do now? Anyone? I'm beginner at lua scripting, so, i need help. Link to comment
Moderators IIYAMA Posted October 28, 2014 Moderators Share Posted October 28, 2014 Study triggerClientEvent, which is about communication between serverside to clientside. https://wiki.multitheftauto.com/wiki/TriggerClientEvent Watch the examples with care. Link to comment
PrivateKiller Posted October 30, 2014 Author Share Posted October 30, 2014 I watched some turtorials, and that's all what I did, but gui still won't open. Help please? Client= GUIEditor = { button = {}, window = {}, memo = {} } function initGUI( ) btnOutput = guiCreateButton(65, 102, 219, 21, "Buy Advert!", true) addEventHandler ("inClientGUIClick", btnOutput, outputEditBox, false ) editBox=guiCreateEdit(20, 38, 304, 58, "Type your advert here", true) guiEditSetMaxLength ( editBox, 30 ) end addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource()),initGUI ) function outputEditBox ( button ) if button = "left" then local text = guiGetText ( editBox ) outputChatBox ( text ) end end function() GUIEditor.window[1] = guiCreateWindow(455, 192, 343, 133, "Advert cost 500. Click button below to buy it!", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.memo[1] = guiCreateMemo(20, 38, 304, 58, "", false, GUIEditor.window[1]) btnOutput = guiCreateButton(65, 102, 219, 21, "Buy Advert!", true) guiSetFont(GUIEditor.button[1], "default-bold-small") end ) Serverside= function Advertisment(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} for index, player in ipairs ( players ) do outputChatBox( "Advertisment from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 0, 190, 40) end end addCommandHandler( "ad", Advertisment ) Link to comment
Castillo Posted October 30, 2014 Share Posted October 30, 2014 "inClientGUIClick" such event does not exist. And you have a function to create GUI code without a event handler. Why do you even have two set of GUI code anyway? Link to comment
PrivateKiller Posted October 30, 2014 Author Share Posted October 30, 2014 https://wiki.multitheftauto.com/wiki/OnClientGUIClick I'm beginner at programming, and I still don't uderstand it very well, so... I was looking at that link ^^, and tryed to fix it Link to comment
PrivateKiller Posted October 30, 2014 Author Share Posted October 30, 2014 "inClientGUIClick" such event does not exist.And you have a function to create GUI code without a event handler. Why do you even have two set of GUI code anyway? How can I make it work then? Link to comment
Woovie Posted October 31, 2014 Share Posted October 31, 2014 "inClientGUIClick" such event does not exist.And you have a function to create GUI code without a event handler. Why do you even have two set of GUI code anyway? How can I make it work then? https://wiki.multitheftauto.com/wiki/OnClientGUIClick Link to comment
PrivateKiller Posted November 1, 2014 Author Share Posted November 1, 2014 "inClientGUIClick" such event does not exist. I don't get it... Seems that will not happen anything with my wish to learn scripting... I thought that someone will give me an example how to do it, or something like that... Link to comment
manve1 Posted November 1, 2014 Share Posted November 1, 2014 Take a look at the difference between the codes (test my code and check if that is what you wanted, if it is then go to wiki and read about the functions). Your client side: GUIEditor = { button = {}, window = {}, memo = {} } function initGUI( ) btnOutput = guiCreateButton(65, 102, 219, 21, "Buy Advert!", true) addEventHandler ("inClientGUIClick", btnOutput, outputEditBox, false ) editBox=guiCreateEdit(20, 38, 304, 58, "Type your advert here", true) guiEditSetMaxLength ( editBox, 30 ) end addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource()),initGUI ) function outputEditBox ( button ) if button = "left" then local text = guiGetText ( editBox ) outputChatBox ( text ) end end function() GUIEditor.window[1] = guiCreateWindow(455, 192, 343, 133, "Advert cost 500. Click button below to buy it!", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.memo[1] = guiCreateMemo(20, 38, 304, 58, "", false, GUIEditor.window[1]) btnOutput = guiCreateButton(65, 102, 219, 21, "Buy Advert!", true) guiSetFont(GUIEditor.button[1], "default-bold-small") end ) Your server side: function Advertisment(thePlayer, commandName, ...) local players = getElementsByType("player") local playerName = getPlayerName ( thePlayer ) local chatContent = {...} for index, player in ipairs ( players ) do outputChatBox( "Advertisment from " .. playerName.. ": " ..table.concat ( chatContent, " "), player, 0, 190, 40) end end addCommandHandler( "ad", Advertisment ) My client side: function GUI() Window = guiCreateWindow(455, 192, 343, 133, "Advert costs 500. Click the button below to buy it!", false) guiWindowSetSizable(Window, false) guiSetAlpha(Window, 1.00) Memo = guiCreateMemo(20, 38, 304, 58, "", false, Window) Button = guiCreateButton(65, 102, 219, 21, "Buy Advert!", false, Window) guiSetFont(Button, "default-bold-small") showCursor(true) addEventHandler("onClientGUIClick",Button,buttonClick,false) end addCommandHandler("ad",GUI) function buttonClick() if getPlayerMoney(localPlayer) >= 500 then local memoText = guiGetText(Memo) triggerServerEvent("AD",localPlayer,localPlayer,memoText) guiSetVisible(Window,false) showCursor(false) else outputChatBox("#0000FF[AD]#00FF00 You need more money.",0,255,0,true) end end My server side: addEvent("AD",true) addEventHandler("AD",getRootElement(), function (p,text) setPlayerMoney(p,getPlayerMoney(p)-500) outputChatBox("#0000FF[AD] #FFFFFF"..getPlayerName(p)..": #00FF00"..text,root,0,255,0,true) end ) Link to comment
PrivateKiller Posted November 1, 2014 Author Share Posted November 1, 2014 Hell no! God still loves me! Hihi, thanks manve1. I was looking for that ye... Link to comment
manve1 Posted November 1, 2014 Share Posted November 1, 2014 Hell no! God still loves me! Hihi, thanks manve1. I was looking for that ye... No problem, but study what i have changed and what I've kept. Link to comment
PrivateKiller Posted November 1, 2014 Author Share Posted November 1, 2014 Hell no! God still loves me! Hihi, thanks manve1. I was looking for that ye... No problem, but study what i have changed and what I've kept. Of course! I'm reading mta wiki all day and study how to use some mail functions (most used)... 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