Jump to content

trigger client event from server


A3kri

Recommended Posts

Hellow ..

I made gui and i can make it visible using the F7. I want it to be visible using triggerClientEvent ..

so I make onPlayerSpawn and the event gets triggered

addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(166, 96, 545, 402, "credits", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(16, 31, 152, 127, "banshee.png", false, GUIEditor.window[1]) 
 end 
) 
  
bindKey('F7','down', 
    function () 
        guiSetVisible ( GUIEditor.window[1],not guiGetVisible ( GUIEditor.window[1] ) ); 
        showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) 
  end 
) 

this is the client sided.

function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    triggerClientEvent ( "onGreeting", getRootElement(), "Hello World!" ) --wiki 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

and this is the server sided

I used wiki but couldn't get it.

Link to comment
addEvent ( "startWindow", true ) 
addEventHandler("startWindow", root, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(166, 96, 545, 402, "credits", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(16, 31, 152, 127, "banshee.png", false, GUIEditor.window[1]) 
 end 
) 
  
-- server  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    triggerClientEvent ( "startWindow", source ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

what are you trying to do with the bindKey exactly?

Link to comment
  • Moderators
addEvent ( "startWindow", true ) 
addEventHandler("startWindow", root, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(166, 96, 545, 402, "credits", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(16, 31, 152, 127, "banshee.png", false, GUIEditor.window[1]) 
 end 
) 
  
-- server  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    triggerClientEvent ( "startWindow", source ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

what are you trying to do with the bindKey exactly?

guiSetVisible(GUIEditor.window[1],false) 

Will make the window hidden.

And table "GUIEditor" must be defined.

Link to comment
addEvent ( "startWindow", true ) 
addEventHandler("startWindow", root, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(166, 96, 545, 402, "credits", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(16, 31, 152, 127, "banshee.png", false, GUIEditor.window[1]) 
 end 
) 
  
-- server  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    triggerClientEvent ( "startWindow", source ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

what are you trying to do with the bindKey exactly?

thnx, I used your serversided function, that what I needed x.x

I used F7 to show/~ the gui

Link to comment
addEvent ( "startWindow", true ) 
addEventHandler("startWindow", root, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(166, 96, 545, 402, "credits", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(16, 31, 152, 127, "banshee.png", false, GUIEditor.window[1]) 
 end 
) 
  
-- server  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    triggerClientEvent ( "startWindow", source ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

what are you trying to do with the bindKey exactly?

thnx, I used your serversided function, that what I needed x.x

I used F7 to show/~ the gui

If you do experience everyone viewing the GUI in your server, you could add an extra argument before the event.

"triggerClientEvent ( "startWindow", source )" > " triggerClientEvent ( source, "startWindow", root source )

or something like that.

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