Jump to content

Need some help with gui


ClanWpk

Recommended Posts

Posted
function createWelcomeWindow() 
  
        welcomeWindow = guiCreateWindow(174,173,713,431,"[FTS] Clan DM Server Welcome Window",false) 
             
            rulesLabel = guiCreateLabel(46,78,301,252,"Rules:",false,welcomeWindow) 
                guiLabelSetColor(rulesLabel,255,0,0) 
                guiLabelSetVerticalAlign(rulesLabel,"top") 
                guiLabelSetHorizontalAlign(rulesLabel,"left",true) 
                guiSetFont(rulesLabel,"default-bold-small") 
             
            noCheatingLabel = guiCreateLabel(-1,19,271,232,"-No cheating!",false,rulesLabel) 
                guiLabelSetColor(noCheatingLabel,0,255,0) 
                guiLabelSetVerticalAlign(noCheatingLabel,"top") 
                guiLabelSetHorizontalAlign(noCheatingLabel,"left",false) 
                 
            noSwearingLabel = guiCreateLabel(0,18,233,213,"-No swearing",false,noCheatingLabel) 
                guiLabelSetColor(noSwearingLabel,255,255,255) 
                guiLabelSetVerticalAlign(noSwearingLabel,"top") 
                guiLabelSetHorizontalAlign(noSwearingLabel,"left",false) 
                 
            beNiceLabel = guiCreateLabel(-1,21,186,190,"-Be nice to admins and others",false,noSwearingLabel) 
                guiLabelSetColor(beNiceLabel,255,255,255) 
                guiLabelSetVerticalAlign(beNiceLabel,"top") 
                guiLabelSetHorizontalAlign(beNiceLabel,"left",false) 
         
            websiteLabel = guiCreateLabel(137,24,429,54,"www.fts.vhost.lt",false,welcomeWindow) 
                guiLabelSetColor(websiteLabel,225,215,0) 
                guiLabelSetVerticalAlign(websiteLabel,"center") 
                guiLabelSetHorizontalAlign(websiteLabel,"center",false) 
                guiSetFont(websiteLabel,"sa-gothic") 
             
            acceptButton = guiCreateButton(47,401,617,21,"Accept the rules and continue!",false,welcomeWindow) 
             
            guiSetVisible(welcomeWindow,false) 
end 
addEventHandler("onClientGUIClick", acceptButton, clientAccept, false) 
function clientAccept(button,state) 
  
    if button == "left" and state == "up" then 
  
        guiSetInputEnabled(false) 
  
        guiSetVisible(welcomeWindow, false) 
  
        showCursor(false) 
    end 
end 
  
addEventHandler("onClientPlayerJoin", getResourceRootElement(getThisResource()),  
    function () 
        createWelcomeWindow() 
    end 
) 
  
addEventHandler("onClientPlayerJoin", getResourceRootElement(getThisResource()),  
    function () 
  
        createWelcomeWindow() 
  
  
                outputChatBox("Welcome to [FTS] Clan DD/DM Server!") 
  
            if (welcomeWindow ~= nil) then 
            guiSetVisible(welcomeWindow, true) 
        else 
  
            outputChatBox("An unexpected error has occurred and the welcome GUI has not been created.") 
            end  
  
            showCursor(true) 
  
            guiSetInputEnabled(false) 
    end 
) 

Error at line 36 -

addEventHandler("onClientGUIClick", acceptButton, clientAccept, false) 

With debugscript 3 ir says "Bad argument @ line 36 'addEventHandler'"

Need some help ;/

Posted

onClientPlayerJoin is not triggered for local player (see wiki), so you better use onClientResourceStart.

and you can't attach an event to an element which is not yet even created.

so place you addEventHandler after you created the acceptButton element.

  
function createWelcomeWindow() 
      welcomeWindow = guiCreateWindow(174,173,713,431,"[FTS] Clan DM Server Welcome Window",false) 
            rulesLabel = guiCreateLabel(46,78,301,252,"Rules:",false,welcomeWindow) 
                guiLabelSetColor(rulesLabel,255,0,0) 
                guiLabelSetVerticalAlign(rulesLabel,"top") 
                guiLabelSetHorizontalAlign(rulesLabel,"left",true) 
                guiSetFont(rulesLabel,"default-bold-small") 
            
            noCheatingLabel = guiCreateLabel(-1,19,271,232,"-No cheating!",false,rulesLabel) 
                guiLabelSetColor(noCheatingLabel,0,255,0) 
                guiLabelSetVerticalAlign(noCheatingLabel,"top") 
                guiLabelSetHorizontalAlign(noCheatingLabel,"left",false) 
                
            noSwearingLabel = guiCreateLabel(0,18,233,213,"-No swearing",false,noCheatingLabel) 
                guiLabelSetColor(noSwearingLabel,255,255,255) 
                guiLabelSetVerticalAlign(noSwearingLabel,"top") 
                guiLabelSetHorizontalAlign(noSwearingLabel,"left",false) 
                
            beNiceLabel = guiCreateLabel(-1,21,186,190,"-Be nice to admins and others",false,noSwearingLabel) 
                guiLabelSetColor(beNiceLabel,255,255,255) 
                guiLabelSetVerticalAlign(beNiceLabel,"top") 
                guiLabelSetHorizontalAlign(beNiceLabel,"left",false) 
        
            websiteLabel = guiCreateLabel(137,24,429,54,"www.fts.vhost.lt",false,welcomeWindow) 
                guiLabelSetColor(websiteLabel,225,215,0) 
                guiLabelSetVerticalAlign(websiteLabel,"center") 
                guiLabelSetHorizontalAlign(websiteLabel,"center",false) 
                guiSetFont(websiteLabel,"sa-gothic") 
            
            acceptButton = guiCreateButton(47,401,617,21,"Accept the rules and continue!",false,welcomeWindow) 
            addEventHandler("onClientGUIClick", acceptButton, clientAccept, false) --here 
            guiSetVisible(welcomeWindow,false) 
end 
  
function clientAccept(button,state) 
    if button == "left" and state == "up" then 
        guiSetInputEnabled(false) 
        guiSetVisible(welcomeWindow, false) 
        showCursor(false) 
    end 
end 
  
addEventHandler("onClientResourceStart", getRootElement(), 
    function () 
        createWelcomeWindow() 
        -- addEventHandler("onClientGUIClick", acceptButton, clientAccept, false) -- or here 
        outputChatBox("Welcome to [FTS] Clan DD/DM Server!") 
        if (welcomeWindow ~= nil) then 
            guiSetVisible(welcomeWindow, true) 
        else 
            outputChatBox("An unexpected error has occurred and the welcome GUI has not been created.") 
        end 
        showCursor(true) 
        guiSetInputEnabled(false) 
    end 
) 

Posted

put your addEventHandler AFTER creating the button.

now you are defining function (not firing it up!)

then adding event handler to unexisting element

then defining another function

adding some handlers (in one you are firing the function that creates the gui)

edit: xbost was faster..

Posted

OK now, but there are 2 problems - first the resource start on every new map and second that if you click on button mouse and everything is gone, but not the gui. What to do?

Posted (edited)

--misleading info deleted

EDIT2: now i really see i need to sleep more, ty varez :D

Edited by Guest
Posted

My other GUI:

function createWelcomeWindow() 
GUIEditor_Window[1] = guiCreateWindow(208,127,669,520,".: ..:: ...::: Welcome to [FTS] Clan DD/DM Server :::... ::.. :.",false) 
  
GUIEditor_Button[2] = guiCreateButton(50,481,574,20,"I accept Rules and I want to continue!",false,GUIEditor_Window[1]) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientAccept, false) --here 
  
GUIEditor_TabPanel[1] = guiCreateTabPanel(70,115,531,323,false,GUIEditor_Window[1]) 
  
GUIEditor_Tab[1] = guiCreateTab("Rules",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[1] = guiCreateMemo(20,21,212,258,"-Cheating\n\n-Swearing\n\n-Spamming\n\n-Faking nicks",false,GUIEditor_Tab[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
  
GUIEditor_Memo[2] = guiCreateMemo(298,20,212,258,"-Having Fun\n\n-Reading Rules on welcome window\n\n-Using our Userpanel",false,GUIEditor_Tab[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
  
GUIEditor_Label[1] = guiCreateLabel(25,5,202,19,"NOT TO DO",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,0,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
  
GUIEditor_Label[2] = guiCreateLabel(302,4,172,20,"TO DO",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,255,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
  
GUIEditor_Tab[2] = guiCreateTab("Progress of server",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[3] = guiCreateMemo(24,24,484,253,"2010 November 9:\n-Added new Welcome Window\n-IP changed to 46.4.193.42:22003\n\n2010 November 8:\n-Bought VPS, started new project which implements CS 1.6 and MTA\n\n2010 October 8:\n-Bought Server, started to host 24/7\n\n",false,GUIEditor_Tab[2]) 
guiMemoSetReadOnly(GUIEditor_Memo[3],true) 
  
GUIEditor_Tab[3] = guiCreateTab("About Clan",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[4] = guiCreateMemo(20,17,493,262,"Server owner:\n\nBleidex~[LTU]\n\n[FTS] Leader:                             [FTS] Co-Leader:\n\nReD_PiT                                     AnoN\n\n                                                 LT-V14",false,GUIEditor_Tab[3]) 
guiMemoSetReadOnly(GUIEditor_Memo[4],true) 
  
GUIEditor_Tab[4] = guiCreateTab("About Script",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[5] = guiCreateMemo(13,14,143,269,"Commands:\n\n/lol\n/omfg\n/afk\n/back\n/hi\n/bye\nand so on...",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[5],true) 
  
GUIEditor_Memo[6] = guiCreateMemo(200,14,138,268,"Gamble Commands:\n\n/roll\n/spin (number) (cash)",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[6],true) 
  
GUIEditor_Memo[7] = guiCreateMemo(379,14,138,270,"More to come....",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[7],true) 
  
GUIEditor_Label[3] = guiCreateLabel(70,445,530,30,"NOT READDING RULES DOES NOT HELP YOU",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"center") 
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"center",false) 
guiSetFont(GUIEditor_Label[3],"default-bold-small") 
  
GUIEditor_Label[4] = guiCreateLabel(155,32,347,80,"www.fts.vhost.lt",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,200) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"center") 
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"center",false) 
guiSetFont(GUIEditor_Label[4],"sa-gothic") 
  
GUIEditor_Label[5] = guiCreateLabel(492,499,170,14,"Created By Bleidex~[LTU]",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[5],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false) 
  
end 
  
function clientAccept(button,state) 
    if button == "left" and state == "up" then 
        guiSetInputEnabled(false) 
        guiSetVisible(GUIEditor_Window[1], false) 
        showCursor(false) 
    end 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function () 
        createWelcomeWindow() 
        -- addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientAccept, false) -- or here 
        outputChatBox("Welcome to [FTS] Clan DD/DM Server!") 
        if (GUIEditor_Window[1] ~= nil) then 
            guiSetVisible(GUIEditor_Window[1], true) 
        else 
            outputChatBox("An unexpected error has occurred and the welcome GUI has not been created.") 
        end 
        showCursor(true) 
        guiSetInputEnabled(false) 
    end 
) 

with debugscript 3 it shows error on line 2 (a nil value)

on connect just window comes up, but nothing else

Posted

copy exact error,

and show which line is your line 2,

because in this script line 2 creates the window, and you said it's failing - but somehow windows shows up, so i bet something is different in lines count on forums..

Posted

i bet GUIEditor_Window is not declared as a table, so it causes "attempt to index" error.

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Memo = {} 
GUIEditor_Label = {} 
  
function createWelcomeWindow() 
GUIEditor_Window[1] = guiCreateWindow(208,127,669,520,".: ..:: ...::: Welcome to [FTS] Clan DD/DM Server :::... ::.. :.",false) 
  
GUIEditor_Button[2] = guiCreateButton(50,481,574,20,"I accept Rules and I want to continue!",false,GUIEditor_Window[1]) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientAccept, false) --here 
  
GUIEditor_TabPanel[1] = guiCreateTabPanel(70,115,531,323,false,GUIEditor_Window[1]) 
  
GUIEditor_Tab[1] = guiCreateTab("Rules",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[1] = guiCreateMemo(20,21,212,258,"-Cheating\n\n-Swearing\n\n-Spamming\n\n-Faking nicks",false,GUIEditor_Tab[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
  
GUIEditor_Memo[2] = guiCreateMemo(298,20,212,258,"-Having Fun\n\n-Reading Rules on welcome window\n\n-Using our Userpanel",false,GUIEditor_Tab[1]) 
guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
  
GUIEditor_Label[1] = guiCreateLabel(25,5,202,19,"NOT TO DO",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,0,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
  
GUIEditor_Label[2] = guiCreateLabel(302,4,172,20,"TO DO",false,GUIEditor_Tab[1]) 
guiLabelSetColor(GUIEditor_Label[2],0,255,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
  
GUIEditor_Tab[2] = guiCreateTab("Progress of server",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[3] = guiCreateMemo(24,24,484,253,"2010 November 9:\n-Added new Welcome Window\n-IP changed to 46.4.193.42:22003\n\n2010 November 8:\n-Bought VPS, started new project which implements CS 1.6 and MTA\n\n2010 October 8:\n-Bought Server, started to host 24/7\n\n",false,GUIEditor_Tab[2]) 
guiMemoSetReadOnly(GUIEditor_Memo[3],true) 
  
GUIEditor_Tab[3] = guiCreateTab("About Clan",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[4] = guiCreateMemo(20,17,493,262,"Server owner:\n\nBleidex~[LTU]\n\n[FTS] Leader:                             [FTS] Co-Leader:\n\nReD_PiT                                     AnoN\n\n                                                 LT-V14",false,GUIEditor_Tab[3]) 
guiMemoSetReadOnly(GUIEditor_Memo[4],true) 
  
GUIEditor_Tab[4] = guiCreateTab("About Script",GUIEditor_TabPanel[1]) 
  
GUIEditor_Memo[5] = guiCreateMemo(13,14,143,269,"Commands:\n\n/lol\n/omfg\n/afk\n/back\n/hi\n/bye\nand so on...",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[5],true) 
  
GUIEditor_Memo[6] = guiCreateMemo(200,14,138,268,"Gamble Commands:\n\n/roll\n/spin (number) (cash)",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[6],true) 
  
GUIEditor_Memo[7] = guiCreateMemo(379,14,138,270,"More to come....",false,GUIEditor_Tab[4]) 
guiMemoSetReadOnly(GUIEditor_Memo[7],true) 
  
GUIEditor_Label[3] = guiCreateLabel(70,445,530,30,"NOT READDING RULES DOES NOT HELP YOU",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,0,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"center") 
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"center",false) 
guiSetFont(GUIEditor_Label[3],"default-bold-small") 
  
GUIEditor_Label[4] = guiCreateLabel(155,32,347,80,"www.fts.vhost.lt",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],0,0,200) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"center") 
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"center",false) 
guiSetFont(GUIEditor_Label[4],"sa-gothic") 
  
GUIEditor_Label[5] = guiCreateLabel(492,499,170,14,"Created By Bleidex~[LTU]",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[5],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[5],"left",false) 
  
end 
  
function clientAccept(button,state) 
    if button == "left" and state == "up" then 
        guiSetInputEnabled(false) 
        guiSetVisible(GUIEditor_Window[1], false) 
        showCursor(false) 
    end 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function () 
        createWelcomeWindow() 
        outputChatBox("Welcome to [FTS] Clan DD/DM Server!") 
        if (GUIEditor_Window[1] ~= nil) then 
            guiSetVisible(GUIEditor_Window[1], true) 
        else 
            outputChatBox("An unexpected error has occurred and the welcome GUI has not been created.") 
        end 
        showCursor(true) 
        guiSetInputEnabled(false) 
    end 
) 

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