Jump to content

Help with the playerStatus screen


Recommended Posts

Hi, I've been trying to figure out a way to make this work out, but I need some help. 

 

I'm trying to add a custom button to the client table. So far is working just fine.

 

http://i.imgur.com/1W16cJ5.jpg

 

Despite all that, I've been unable to add it to every instance of every player in the server.

This button shows only for admins and only in the people that are not admins (just like the ban/kick button).

 

I've been trying to use this piece of code to add it to every instance of the player, but I haven't been able to get it to work.

AddGlobalClassPostConstruct("screens/playerstatusscreen", "playerStatus", function(self)	local ClientObjs = GLOBAL.TheNet:GetClientTable()	self.blocklist = self.root:AddChild(ScrollableList(ClientObjs, 380, 370, 60, 5, blockConstructor, nil, nil, nil, nil, nil, -15))end)

I'm new to lua, so maybe I'm missing some simple, dumb, crucial fact. Please don't be mean.

 

I'm new to lua, so maybe I'm missing some simple, dumb, crucial fact. Please don't be mean.

Link to comment
Share on other sites

@DarkXero Sorry, I forgot to explain myself.

 

I made this mode specifically for the server I play to protect from griefers. We could put a password as well, but still we would like to meet new people.

 

So what this mod does is create a property for every non admin player that stops them from using a hammer, stealing from chest, lit stuff on fire... you get the idea.

 

I added a function to make it work by console, but I would like to make it simpler to use by just adding a button near the name in the tab menu that does all the work.

 

So what I was trying to do is to implement the button so that it creates one for every instance of Player in the server

 

Hope that clears it.

Link to comment
Share on other sites

The new button would block, and unblock people respectively. (Sorry, can't find the edit button on the post)

 

EDIT: Nvm, Apparently, I need to have 5 post minimun to edit my previous post, so yeah.

Edited by CremeLover
Link to comment
Share on other sites

@CremeLover, ok, I looked into this. Do it like this

local Text = GLOBAL.require("widgets/text")local ImageButton = GLOBAL.require("widgets/imagebutton")local PopupDialogScreen = GLOBAL.require "screens/popupdialog"AddGlobalClassPostConstruct("screens/playerstatusscreen", "playerStatus", function(self)    local old = self.scroll_list.constructor    self.scroll_list.constructor = function(v, i)        local ret = old(v, i)        if not (v.userid == GLOBAL.ThePlayer.userid) then            local displayName = self:GetDisplayName(v)            ret.block = ret:AddChild(ImageButton("images/scoreboard.xml", "banhammer.tex", "banhammer.tex", "banhammer.tex", "banhammer.tex"))            ret.block:SetPosition(220, 3 , 0)            ret.block.label = ret.block:AddChild(Text(GLOBAL.UIFONT, 25, GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.BAN))            ret.block.label:SetPosition(3, 33, 0)            ret.block.label:Hide()                    ret.block.OnGainFocus =                        function()                            ret.block.label:Show()                            GLOBAL.TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/click_mouseover")                            ret.block:SetScale(1.1)                        end                    ret.block.OnLoseFocus =                        function()                            ret.block.label:Hide()                            ret.block:SetScale(1)                        end                    ret.block:SetOnClick(                        function()                            GLOBAL.TheFrontEnd:PushScreen(                                PopupDialogScreen(                                    GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.BANCONFIRM_TITLE.." "..displayName,                                    GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.BANCONFIRM_BODY.." "..displayName.."?",                                    {                                        {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.OK, cb = function() print("Hello", v.userid) GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end},                                        {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.CANCEL, cb = function() GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end}                                    }                            ))                        end)        end        return ret    endend)

This is the basics, I guess. I copied the ban button and appended it as an extra button.

 

It should appear on anybody who isn't you (different userids).

 

You want to turn

print("Hello", v.userid)

into a SendModRPC that executes when reaches your server, you execute your function.

Link to comment
Share on other sites

@DarkXero Thank you so much for your help, seriously, I couldn't figure out that one.

 

I wasn't aware that you could just access the paramethers like that, it saves me alot of trouble. Im asumming it will also work if I use another paramethers of the same function such as itempadding or updatefn?

 

Now, I came across another problem, which I still can't get across. When I try to modify the properties from the individual players of the list (block them in this case), I can't get it to change the state of the player (probably because I'm trying to access the data from a table, instead of the actual entity).

 

I tried TheNet:GetClientTable() to get the player data, but obviously is another table, so it raises the same problem again.

 

Also, something I should've done in the first time, I attach the code. Sorry for giving you the trouble of doing all the interface of your own and thanks again.

modmain.lua

Edited by CremeLover
Link to comment
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
 Share

×
  • Create New...