Jump to content

Return true or false from server function


Tails

Recommended Posts

Hello fellow MTA scripters,

I've just made a function called checkPrivileges, it's server-side and it's all working just fine. However I'm trying to use it in the client-side code below and of course it won't work this way. So my question is, what is the best way of retrieving the state of checkPrivileges to the client, in something like below?

I've already tried stuff like: state = triggerServerEvent( etc... but unfortunately it's not that simple. Any help is appreciated!

for i,v in pairs(myColshape) do 
    local name = getPlayerName(v) 
    if checkPrivileges(v) then 
        userlist:AddItem(users,i..". "..name,name,0,200,0) 
    else 
        userlist:AddItem(users,i..". "..name,name,255,255,255) 
    end 
end 

Link to comment

you can also use attachElements[wiki] to the body and work around with several troubles with animations and offsets to get it working.triggerServerEvent and triggerClientEvent both return either true or false - depending on whether the event was successfully reached or not.

So if you use triggerServerEvent to try and find out whether a certain player belongs to a certain group or not is not gonna be very useful if you try and use the state of the trigger. So long as the event is successfully triggered - it would always return true for you, whether the player is in that ACL group or not.

So like Noki said, you'll need to use triggerClientEvent.

Client -> Server -> Client

Link to comment

triggerServerEvent and triggerClientEvent both return either true or false - depending on whether the event was successfully reached or not.

So if you use triggerServerEvent to try and find out whether a certain player belongs to a certain group or not is not gonna be very useful if you try and use the state of the trigger. So long as the event is successfully triggered - it would always return true for you, whether the player is in that ACL group or not.

So like Noki said, you'll need to use triggerClientEvent.

Client -> Server -> Client

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