Jump to content

Advertisment Gui


PrivateKiller

Recommended Posts

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
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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...