Jump to content

Triggin to serverside from client and trigger back client


villr

Recommended Posts

Posted

Hello everyone.. again, now my problem is that i want to trigger from my gui when u click an button, so it looks up to serverside if an player already rent an boat and then if they already did it, nothing should happend.

I already got an code but idk how to fix the triggers to fit the gui code :/

Any tips?

Client

elseif (source == rentbutton) then 
triggerServerEvent("gotBoatRented", getLocalPlayer()) 

function gotBoatRented(state) 
outputChatBox (state) 
return state 
end 
addEvent("gotBoatRented", true) 
addEventHandler("gotBoatRented", getRootElement(),gotBoatRented) 

-- Server

addEvent("gotBoatRented", true) 
addEventHandler("gotBoatRented",  getRootElement(), 
function () 
    state = false 
    for k,v in ipairs(reefers) do 
        local rentowner = getElementData(v,"rentowner") 
        if rentowner == getAccountName(getPlayerAccount(source)) then    
            state = true 
            outputChatBox ("true") 
        end 
    end 
    outputChatBox(state) 
    triggerClientEvent ( source, "gotBoatRented", getRootElement(), state ) 
end 
) 

This is what i started on but idk how to make it work..

Posted

Sorry, I'm confused here,

you got events and one looks like it's client-sided and the other looks like it's server-sided.

Can you post the codes in a whole lua block(


).

ad this script isn't good enough, PM me if your want help from there.

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