Jump to content

all players see the gui


-stolka-

Recommended Posts

why when i open the GUI every player see it?

function arrestGui ( arrest ) 
    outputChatBox ( "client arrest " .. arrest ) 
      guiSetVisible(windowArrest, true) 
      showCursor(true) 
      guiSetText ( GUIEditor_Label[2],"arrests:"..arrest ) 
end 
addEvent( "onArrestRequest", true ) 
addEventHandler( "onArrestRequest", getRootElement(), arrestGui ) 

Link to comment
function arrestGui ( player, arrest ) 
    if ( player == localPlayer ) then 
        outputChatBox ( "client arrest " .. arrest ) 
        guiSetVisible(windowArrest, true) 
        showCursor(true) 
        guiSetText ( GUIEditor_Label[2],"arrests:"..arrest ) 
    end 
end 
addEvent( "onArrestRequest", true ) 
addEventHandler( "onArrestRequest", getRootElement(), arrestGui ) 

Just then you tigger to open gui use double the player ellement example:

triggerClientEvent( "onArrestRequest", player, player, arrest ) 

Link to comment
function showArrest ( playerSource ) 
local arrest = getElementData(playerSource, "arrest") 
if not arrest then 
outputChatBox("you dont have any arrest",playerSource) 
else 
outputChatBox("arrest: "..arrest,playerSource) 
    triggerClientEvent( "onArrestRequest",getRootElement(), arrest ) 
end 
end 
addCommandHandler ( "arrest", showArrest ) 

Link to comment
triggerClientEvent( "onArrestRequest",source, arrest ) 

not working

this is my client side function

    function arrestGui ( arrest ) 
       if ( player == localPlayer ) then 
            outputChatBox ( "client arrest " .. arrest ) 
            guiSetVisible(windowArrest, true) 
            showCursor(true) 
            guiSetText ( GUIEditor_Label[2],"arrests:"..arrest ) 
       end 
    end 
    addEvent( "onArrestRequest", true ) 
    addEventHandler( "onArrestRequest", getRootElement(), arrestGui ) 

Link to comment

function arrestGui ( arrest ) 
    outputChatBox ( "client arrest " .. arrest ) 
        guiSetVisible(windowArrest, true) 
            showCursor(true) 
                guiSetText ( GUIEditor_Label[2],"arrests:"..arrest ) 
    end 
addEvent( "onArrestRequest", true ) 
addEventHandler( "onArrestRequest", getRootElement(), arrestGui ) 
Link to comment

You don't need server side, it can be done client side.

function arrestGui() 
    local arrest = getElementData(localPlayer, "arrest") 
    if arrest then 
        outputChatBox("arrest: "..arrest) 
        guiSetVisible(windowArrest, true) 
        showCursor(true) 
        guiSetText(GUIEditor_Label[2], "arrests: "..arrest) 
    else 
        outputChatBox("you don't have any arrest") 
    end 
end 
addCommandHandler("arrest", arrestGui) 

Link to comment

You all using it wrong way.

Syntax:

bool triggerClientEvent ( [element sendTo=getRootElement()], string name, element theElement, [arguments...] ) 

The first argument is 'sendTo' that mean who you want trigger to, if you haven't specific the sendTo it will be root by default (for all).

While the third argument will be the source of the event at the client side (every event have source isn't it? the same with custom events).

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