Forum

> > CS2D > Scripts > Player List On Menu/Serveraction.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Player List On Menu/Serveraction.

9 replies
To the start Previous 1 Next To the start

old Player List On Menu/Serveraction.

Rygna
User Off Offline

Quote
Hello.
Can you help me?
How to make "Player List on Menu/Serveraction"

and, they can kick/ban player from Menu.
for admin only.

I try this Code >

But that code is too much line needed.
i need simple code and easy to use.

Thanks!
#SorryForMyEnglish.

old Re: Player List On Menu/Serveraction.

GeoB99
Moderator Off Offline

Quote
@user Gaios: I don't see anything that it is hard or difficult to comprehend the functionality of this. The main core to display player's names is relatively simple by itself as you can see in this example below form this script:
1
2
3
4
5
6
7
function exist(a)
	if player(a, 'exists') then
		return player(a, 'name')
	else
		return "None"
	end
end
Less lines of code and the logic is pretty easy to understand. It just basically checks if the player whether exists in the server or not. If the condition is true then the function will end by returning the player's name to administration menu otherwise it'll not. This, of course, in order to be displayed you must shall copy the function name and paste it through the menu page parameter.

P.S: And frankly, I'd rather not suggest HC Admin script especially if you want to look at the code. It'll melt the brain of those who are beginners on how the HC Admin code stylized is.

@user Rygna: Your code has plenty of elseif statements which this is it make your code longer and sometimes a kind of frustration to read. Instead of checking the buttons with many separated elseif statements, just compare the total number of buttons on a single line, pretty much like this for example:
1
2
if b >= 1 and b <= 8 then
	k(pl)
What it actually does in words: it compares from the first and the last number whereas the last line is the k function which pl is the id of player. Note that this must be pasted inside the first Kill page menu because obviously the k(pl) is for killing a player related when the command is parsed. You have to do that every time by changing the total number of buttons and its specific function.

In this way, you'll achieve less stress and it is much easier than adding bunch of elseif statements. Haven't tested it though but I think it'll do the trick.

old Re: Player List On Menu/Serveraction.

Yates
Reviewer Off Offline

Quote
@user GeoB99: Always return false with these kind of functions, this way you can simply do:

1
2
3
if (exists(id)) then
 name = exists(id)
end

You can shorten it even more if you want. Could even be a one liner.

old Re: Player List On Menu/Serveraction.

Yates
Reviewer Off Offline

Quote
@user Rainoth: I honestly have forgotten how Lua would do it, I haven't coded Lua in a long time sadly.

I presume it should look more like this:
1
local name = exists(id) or "" -- Or whatever value you have in mind
exists(id) or "" may also have to be put in brackets to stop Lua from whining, not sure, like I said - it's been a long time.

user Mami Tomoe has written
How will it look inside a menu function?

Well you wouldn't need to set the local name variable, it was just an example of why you should always (in most cases) return false in custom functions which would normally return a value.

So, what the OP put in his code at the top would remain the same, simply exists(id)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview