Jump to content

[Help] onPlayerJoin panel


Hunter567T

Recommended Posts

Posted

I am trying to make a panel that appears when a player connects to a server. But when someone connects it is not appearing..

Code:

Client

  
local resX, resY = guiGetScreenSize() 
  
function createGUI(thePlayer) 
    cWindow =   guiCreateWindow((resX/2)-315,(resY/2)-100,629,200,"Welcome Panel By Hunter567T",false) 
    message =   guiCreateButton(0,0.1,2, 0.9,"............",true,cWindow) 
    close =     guiCreateButton(0.4,0.825,0.213,0.1,"Close",true,cWindow) 
    addEventHandler("onClientGUIClick", close, closeCgui, false) 
    guiSetVisible (cWindow, false) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),createGUI) 
  
function openGUI(thePlayer) 
    if (cWindow ~= nil) then 
        guiSetVisible(cWindow, true) 
        showCursor(true) 
    end 
end 
addEvent("makeGUI", true) 
addEventHandler("makeGUI", getLocalPlayer(), openGUI) 
  
function closeCgui() 
    guiSetVisible (cWindow, false) 
    showCursor(false) 
end 
  

Server

  
  
function GUIness(source) 
        triggerClientEvent(source, "makeGUI", root) 
    end 
addEvent("onPlayerJoin", true ) 
addEventHandler("onPlayerJoin", GUIness) 
  

Commander of the CIT SWAT Team.

Posted

In the server-side instead of addEvent and then addEventHandler you should have;

addEventHandler("onPlayerJoin",getRootElement(),GUIness) 

Retired

Posted

triggering client event from server side on onPlayerJoin event will fail - players join imediately, but need to download and start resources - which takes time.

Why don't you just show gui from clientside? ( onClientResourceStart attached to getResourceRootElement(getThisResource()) )

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
triggering client event from server side on onPlayerJoin event will fail - players join imediately, but need to download and start resources - which takes time.

Why don't you just show gui from clientside? ( onClientResourceStart attached to getResourceRootElement(getThisResource()) )

That's what he's doing but for some reason he hides it just after creating it...

Posted

oh, tbh, i just checked his 2nd script (server side)..

so well, im confused..

but at least 1st part of my previous post - its true ;p

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
triggering client event from server side on onPlayerJoin event will fail - players join imediately, but need to download and start resources - which takes time.

Why don't you just show gui from clientside? ( onClientResourceStart attached to getResourceRootElement(getThisResource()) )

Everything fromt the client is there only thing i removed is the text in the message ( "..........." ) im confused as well now.. Also would onPlayerLogin instead of onPlayerJoin help?

Commander of the CIT SWAT Team.

Posted

just remove

  
guiSetVisible (cWindow, false) 
  

from client,

and remove whole server-side - you dont need it!

onPlayerLogin COULD help you, but afaik its possible to login before all resources are downloaded (via console) - so its not reliable..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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