Hi All!
I'm just starting to learn this C stuff, and need a little help with some examples. Would you be so kind as to post some example code to the follow questions?
Thanks!
1. I've been trying to filter out bots and admins from a OnClientPostAdminCheck(client) function. The current function is letting non-admins in along with admins... So, is this a problem with my code, or a error in the admflags?
Code:
if (IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ ... }
2. I'd like to create a server var that contains a server ip address and port of a css server. I'd like it to have a default value, and allow me to update the serverip/port, and retrieve it in code. I've been able to create it, ( but I'm not sure if I did it right ) but I'm having trouble with being able to retrieve it.
Code:
public OnPluginStart()
{
CreateConVar("server_address", "ip.ip.ip.ip:port", "Server redirect address:port", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}
Now, when I use 'SomeFunction("blah blah blah %s, %d ", server_address, server_address)' I get nothing in the string, and a large number in the digit fields. Now, I did try to break it apart to remove the ':' and use two seperate fields, but that didn't seem to work for me either...
The var is saved fine, and I can see it in the public vars, I just don't know how to properly retrieve it in code.
3. I'd like to grab a random user, and do some function on him. ( eg: kick )
But, I need the user to not be an admin, and I'd like to specify how many users to do this to. eg: kick 10 random non-admin users. Could someone please post an example of this sort of thing?
4. How do you print a line to the servers console? I'd like to put some information into the server console / server log.
5. This following function seems to be returning the number of admins, but it also is adding the number of bots... How do I filter this to not include bots? ( and how would I grab the userid's while I'm looping through the players? )
Code:
public chgetadmincount()
{
new max_clients = GetMaxClients();
new ch_total;
ch_total = 0;
for (new i=1; i<=max_clients; i++)
{
if (IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID)
{
ch_total++;
}
}
SetConVarInt(ch_admins, ch_total);
return ch_total;
}
Thanks so much for your assistance.
Chumly