PDA

View Full Version : Players online


Neverminddw
12-29-2016, 06:01
Hi, I tried all my skills on making this plugin, but I failed ( thoo Im not good player enough ).
So I'm requesting help from you.

Can you make a plugin that shows how many players are online on the ride side with HUD, green color.
Like: Players online: 12/32.

4ever16
12-29-2016, 06:41
Exists already just search.
Server stats or something.
Try search more i have found this plugin before.

OciXCrom
12-29-2016, 07:09
#include <amxmodx>

new g_iObject
new g_iMaxPlayers

public plugin_init()
{
register_plugin("Players Online", "1.0", "OciXCrom")
g_iObject = CreateHudSyncObj()
g_iMaxPlayers = get_maxplayers()
set_task(1.0, "DisplayPlayers", .flags = "b")
}

public DisplayPlayers()
{
set_hudmessage(0, 255, 0, 0.9, 0.2, 0, 0.1, 1.0, 0.1, 0.1, -1)
ShowSyncHudMsg(0, g_iObject, "Players Online: %i/%i", get_playersnum(), g_iMaxPlayers)
}

Neverminddw
12-29-2016, 14:55
Thanks a lot OciXCrom :)

4ever16
12-30-2016, 16:11
Works perfect thanks oxi.

I have sv_maxvisibleplayers 2 so in the server browser i can see only 2 slots and only 2 people can connect.

How do i replace get_maxplayers to get_maxvisibleplayers so that plugin works corectly?

EFFx
12-30-2016, 16:46
Its not your thread.

4ever16
12-30-2016, 17:04
Its not your thread.

So i need to create a new one? lol
I need same shit but little different.

OciXCrom
12-30-2016, 18:09
Simply get the cvar number.

4ever16
12-31-2016, 11:53
Simply get the cvar number.
What? You are talking to a normal person who cant code or understand code.

OciXCrom
12-31-2016, 13:12
So, you're saying all of us scripters are crazy?

Remove the line that contains g_iMaxPlayers in plugin_init().
Add plugin_cfg() and inside it g_iMaxPlayers = get_cvar_num("sv_maxvisibleplayers")

Try first, ask for help later.

4ever16
01-05-2017, 02:41
OciXCrom, can you explain so normal person who cant code understand?
Like re-write the code so i see the whole .sma in plain eye?

OciXCrom
01-05-2017, 07:33
If a normal code can't code, it doesn't mean he can't understand a simple task.

1. Remove THE LINE that CONTAINS g_iMaxPlayers in plugin_init()
- Translation: select the entire line with your mouse button and delete it with the DELETE button.
2. Add the plugin_cfg() function, which means write public plugin_cfg() outside of all functions (opened and closed with { } ), and inside it (open the function with { ) add g_iMaxPlayers = get_cvar_num("sv_maxvisibleplayers"), then close the function with }.

Just TRY it - it won't explode. Post what you have done if you have problems.

4ever16
01-05-2017, 08:00
Nice, what did you try to do with your answer? Explain more simple? I can say that your last answer was harder to understand than the first one and i didnt even understand the first one.

You cant think that others will understand just cause you understand.
You must also understand that english isnt my strong side.

Just re-write the code please.

Edit. I tryed is this correct? I will compile and see but now you see that i tryed.
It doesnt feel correct cause this: ShowSyncHudMsg(0, g_iObject, "Players Online: %i/%i", get_playersnum(), g_iMaxPlayers)
Edit 2. Maybe correct cause: g_iMaxPlayers = get_cvar_num("sv_maxvisibleplayers")

You see i understand more when i see the code in plain text.

#include <amxmodx>

new g_iObject
new g_iMaxPlayers

public plugin_init()
{
register_plugin("Players Online", "1.0", "OciXCrom")
g_iObject = CreateHudSyncObj()

set_task(1.0, "DisplayPlayers", .flags = "b")
}

public DisplayPlayers()
{
set_hudmessage(0, 255, 0, 0.9, 0.2, 0, 0.1, 1.0, 0.1, 0.1, -1)
ShowSyncHudMsg(0, g_iObject, "Players Online: %i/%i", get_playersnum(), g_iMaxPlayers)
}

plugin_cfg()
{
g_iMaxPlayers = get_cvar_num("sv_maxvisibleplayers")
}

When i compile it compiles but i get this error.
warning 203: symbol is never used: "plugin_cfg"

In the server it says Players online 7/0 it doesnt get sv_maxvisibleplayers

OciXCrom
01-05-2017, 08:56
I don't think it can be any more simple than that. Others will never understand if they don't try, so you should try do to something simple like this in order to learn for future things, instead of asking same questions over and over again. It wasn't that hard, was it? Your code is correct, but the only problem is you forgot to add public in front of plugin_cfg().

4ever16
01-05-2017, 09:30
He he ok.
Thanks!

Yeah ok i learned a little bit today.