Simple UI to DISPLAY SERVER RULES
0

9 posts in this topic

Recommended Posts

I've written some (non-functional) code that i'm currently getting a run time error on.  The code should display a window, and inside it is the text for my favourite server's rules.  

It runs on the event OnGameStart, so it will pop up every time the player first joins a server.  Nobody should have an excuse for not knowing the rules, and certainly not reading them with this nifty UI.

 

Shame it doesn't work.  I'll keep working on it, if anyone out there spots any glaring errors, let me know.  

 


require 'ui/uiHelpers'

------------------------------------------------------------------------
-- Creating a window with some text in it
------------------------------------------------------------------------

clickCounter = 0;

-- UI objects
    mywindow = 
    {    

        x = 500,
        y = 500,
        width = 300,
        height = 300,        
        hasClose = true;
        
    };    
    
    
    mygenericelement = 
    {        
        x=550,
        y=550,
        width=320,
        height=320,
        render = function(element)
            element:DrawTextCentre("Test Test Test Test Test Test", 150, 100, 1, 0, 0, 1);
        end;        
    }

function DisplayServerRules()
    
    LuaUI.createWindow(mywindow);
    element = LuaUI.createElement(mygenericelement);
    
end


Events.OnGameStart.Add(DisplayServerRules());

 

Edited by Nbane

Share this post


Link to post
Share on other sites

Hi Nbane, all the code you wrote isn't Lua code PZ will recognize. If you want to create a window you have to use the PZ-way for doing so. Look at "media/lua/client/ISUI" for all the windows PZ is using and take a look at some of them.

 

You can instantiate a new window with e.g. ISWindow.lua.

Share this post


Link to post
Share on other sites

Why dont you want to use ServerWelcomeMessage to show rules of your server, write down your rules and everytime someone enters your server they will see it? if you only want

14 hours ago, Nbane said:

It runs on the event OnGameStart, so it will pop up every time the player first joins a server.  Nobody should have an excuse for not knowing the rules, and certainly not reading them with this nifty UI.

 

Edited by Larnest

Share this post


Link to post
Share on other sites
On 10/15/2017 at 12:01 AM, Larnest said:

Why dont you want to use ServerWelcomeMessage to show rules of your server, write down your rules and everytime someone enters your server they will see it? if you only want

 

Nobody reads that

Share this post


Link to post
Share on other sites
9 hours ago, Paul Redeker said:

Nobody reads that

then nobody will look for some pop-up screen, everyone will close it as soon as it will show up and will never ask what was inside it, but ServerWelcomeMessage will always will be visible in chat

Share this post


Link to post
Share on other sites
13 hours ago, Larnest said:

then nobody will look for some pop-up screen, everyone will close it as soon as it will show up and will never ask what was inside it, but ServerWelcomeMessage will always will be visible in chat

Disagree.  A large pop up that covers the majority of the screen and has to be closed will be read.  And the excuse of "I didn't see it" is also taken away. 

Share this post


Link to post
Share on other sites
19 hours ago, Paul Redeker said:

Disagree.  A large pop up that covers the majority of the screen and has to be closed will be read.  And the excuse of "I didn't see it" is also taken away. 

ok, you close this pop-up then you are in situation that you need to check the rules, and you cant find them, because pop-up screen is closed, best you will have to disconnect form server enter server and then read the rules, but if it will be in ServerWelcomeMessage then you will have to only open chat window and thats all

Share this post


Link to post
Share on other sites

I failed to create even the most basic UI.  The code has no comments.  The boiler code is completely commentless.  I couldn't get through it at all.  I was looking in the right place but it was just too much without remarks/comments humanising the java.  

Share this post


Link to post
Share on other sites

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
0