Jump to content

Client and Server outputChatBox


28WL

Recommended Posts

Hi. How I can make outputChatBox in client when for example the player click on the button (marketplace-shop item) and he gets a message that he bough something or he need money?

CLIENT:

function Buy_1 () 
    if getElementData(getLocalPlayer(),"Money") >= 1000 then 
        triggerServerEvent("Trigger_Buy_1_True",getLocalPlayer()) 
        setElementData(getLocalPlayer(),"Money",(getElementData(getLocalPlayer(),"Money") or 0)-1000) 
        setElementData(getLocalPlayer(),"Chips", 1) 
    else 
        triggerServerEvent("Trigger_Buy_1_False",getLocalPlayer()) 
end 

Can someone help me? I want only to see by myself if I buy it. Now it shows that for everyone, so...

SERVER:

function Script_Buy_1_True ( source ) 
    local source = playersource 
        outputChatBox("You have bought a (Chips) for a (Money).", playersource, 255, 255, 255, true) 
end 
addEvent("Trigger_Buy_1_True",true) 
addEventHandler("Trigger_Buy_1_True",getRootElement(),Script_Buy_1_True) 
  
function Script_Buy_1_False ( source ) 
    local source = playersource 
        outputChatBox("You don't have enough (Money) to buy a (Chips).", playersource, 255, 255, 255, true) 
end 
addEvent("Trigger_Buy_1_False",true) 
addEventHandler("Trigger_Buy_1_False",getRootElement(),Script_Buy_1_False) 

Link to comment

You don't have to trigger it. If you use outputChatBox clientside it will be showed only to localPlayer.

function Buy_1 () 
    if getElementData(getLocalPlayer(),"Money") >= 1000 then 
        setElementData(getLocalPlayer(),"Money",(getElementData(getLocalPlayer(),"Money") or 0)-1000) 
        setElementData(getLocalPlayer(),"Chips", 1) 
        outputChatBox("You have bought a (Chips) for a (Money).", 255, 255, 255, true) 
    else 
        outputChatBox("You don't have enough (Money) to buy a (Chips).", 255, 255, 255, true) 
    end 
end 

Link to comment
function Script_Buy_1_True() 
    outputChatBox("You have bought a (Chips) for a (Money).", client, 255, 255, 255, true) 
end 
addEvent("Trigger_Buy_1_True",true) 
addEventHandler("Trigger_Buy_1_True", getRootElement(), Script_Buy_1_True) 
  
function Script_Buy_1_False() 
    outputChatBox("You don't have enough (Money) to buy a (Chips).", client, 255, 255, 255, true) 
end 
addEvent("Trigger_Buy_1_False",true) 
addEventHandler("Trigger_Buy_1_False", getRootElement(), Script_Buy_1_False) 

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