OpenArena Message Boards

OpenArena Contributions => Development => Topic started by: corncobman on March 02, 2008, 01:16:24 PM



Title: Admin options
Post by: corncobman on March 02, 2008, 01:16:24 PM
I've written a few admin commands and stuff for my Quake 3 engine / mod.

Would you be interested if I "donated" my code to the OpenArena Project?

The admin stuff I have done is

admin / deadmin a particular player / client
mute / unmute a particular player / client
force team / unforce team for a particular player / client
slap (just a bit a joke, knock a player / client around)



Title: Re: Admin options
Post by: Cacatoes on March 04, 2008, 12:08:22 PM
That sounds interesting, maybe you could put the code available and GPL it (if not already)
I'm not dev so I can't tell you more ;)


Title: Re: Admin options
Post by: escapedturkey on March 10, 2008, 10:15:13 AM
It seems the the slap and mute one commands would lead to a lot of admin abuse. If I recall those kinds of commands are one of the reasons a few Jedi Academy mods are so disdained by the mature player community.

The /mute player (from one player to another) would be nice. The rest would probably be over-used by admins with superiority complexes.

Ideally what we need is a good admin mod, something very simple and open-source so others can build upon it.

The best features, to start, would be:

1. Ability to limit vote options.

2. Ability to limit vote ability -- i.e. after 3 callvotes you can no longer vote until the next map cycle.

3. A simple map-list via text file (map name, map name, map name, etc.)

4. Unlagged Option:

Documentation: http://alternatefire.planetquake.gamespy.com/unlagged_faq.html

Unlagged Source code: http://turkey.escapedturkey.net/unlagged/unlagged-2.01-src.zip

5.  IP bans via a text file.

6. Callvote kick/ban -- admin can set option so that when a player is kicked, his/her IP is banned for so many xx minutes.

7. Client-side /mute player (players can mute each other).

8. A reporting anti-cheat -- that basically keeps track of a player's statistics. If the player is getting say 90% accuracy or something beyond human means, it flags the player to a potentiall_cheat.txt for the admin to watch-over. Admin can adjust the anti-cheat accuracy threshold's reporting -- i.e. 80/90/95/99%, etc.

:)


Title: Re: Admin options
Post by: sago007 on March 10, 2008, 03:34:07 PM
Ok, I have recieved a personal messege about this and the some of it also found the way to another thread.

About the corncobman code:
Maybe you can post your mod with sourcecode, there are always someone that might find it useful.

About some of the escapedturkey ideas:

1. I miss that option too. In the old days it didn't take long until the gametime was unlimited, no frag limit and map void4.
I'm not sure about what the best solution for such an implementation would be.

3/5. It is possible with CVARs. Text files are not normally accessible from the game and I don't think it is a good idea to change that.

4. It can be as easy/hard as contacting Neil “haste” Toronto and ask him for permission (if his e-mail still works). Sure he has put the source up and instructions to implement them, but it is from before the GPL days.

8. A true 100% hit accuracy is possible if you camp with the Railgun in CTF on an unlagged server. Not to mention if you only use the gauntlet. If cheat is to be detected it should come from analyzing the log file. I know it is just a warning file but still.

And my own biggest wish:
I think more information in the log file would be nice. Unfortunately I don't see a conclusion of this thread: http://openarena.ws/board/index.php?topic=866.0 because it sounded like Czestmyr knew exactly what kind of information you need to get an useful log-file.


Title: Re: Admin options
Post by: escapedturkey on March 10, 2008, 03:44:29 PM
sago007,

I tried to compile the q3as source code -- mod -- for OA but it doesn't seem to like to work.

Edited: bg_public.h to have:

#define GAME_VERSION            "baseoa-1"

Then ran make.

However, I get this error after putting the file in baseoa and running:

./ioq3ded.i386 +set dedicated 2 +set ttycon 0 +set net_ip 72.5.249.2 +set net_port 27962 +set com_hunkmegs 256 +set sv_maxclients 32 +set logfile 3 +set fs_basepath /home/test/openarena +set fs_homepath /home/test/openarena +set sv_pure 1 +set vm_game 0 +set vm_cgame 0 +set vm_ui 0 +set fs_game baseoa +set +exec basic.cfg

Loading dll file qagame.
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so)...
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so) failed:
"/home/test/openarena/baseoa/qagamei386.so: cannot open shared object file: No such file or directory"
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so)...
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so) failed:
"/home/test/openarena/baseoa/qagamei386.so: cannot open shared object file: No such file or directory"
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so)...
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so) failed:
"/home/test/openarena/baseoa/qagamei386.so: cannot open shared object file: No such file or directory"
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so)...
Sys_LoadDll(/home/test/openarena/baseoa/qagamei386.so) failed:
"/home/test/openarena/baseoa/qagamei386.so: cannot open shared object file: No such file or directory"
Sys_LoadDll(qagame) failed dlopen() completely!
Failed to load dll, looking for qvm.
Loading vm file vm/qagame.qvm...
VM file qagame compiled to 1138100 bytes of code
qagame loaded in 2684064 bytes on the hunk

Source code for Q3AS:

http://turkey.escapedturkey.net/q3as/q3as-source.zip

http://turkey.escapedturkey.net/q3as/

Perhaps snippets of Q3AS code can be used to make a good admin mod?

Q3AS has a lot of features I mentioned. Perhaps an all in one admin mod with your elimination code in it too. :)

Here's the unlagged source code http://turkey.escapedturkey.net/unlagged/unlagged-2.01-src.zip

He released it to the public. :)



Title: Re: Admin options
Post by: corncobman on March 11, 2008, 10:06:14 AM
Ok, I'll post my code a little later. I might try and adapt it so it works with OpenArena.

5 - I have some code from the QuakeSrc forums that does this

6 - I also created a kickban command that kicks and bans a player at the same time, but a time limited ban could be quite useful.

7 - that's a very good idea.



Title: Re: Admin options
Post by: iLeft.bye on March 11, 2008, 06:06:49 PM
donate code? o_O


Title: Re: Admin options
Post by: corncobman on March 12, 2008, 06:51:43 AM
in q_shared.c add

Code:
int CCM_stricmpn(const char *s1, const char *s2, int n) 
{
int c1, c2;

if ( s1 == NULL ) {
if ( s2 == NULL )
return 0;
else
return -1;
}
    else if ( s2 == NULL )
return 1;

do {
c1 = *s1++;
c2 = *s2++;

if (!n--) {
return 0; // strings are equal until end point
}

if (c1 != c2) {
if(c2 == '*')
{
c2 = *s2++;

if(!c2)
return 0;

do
{
c1 = *s1++;

if (c1 >= 'a' && c1 <= 'z') {
c1 -= ('a' - 'A');
}
if (c2 >= 'a' && c2 <= 'z') {
c2 -= ('a' - 'A');
}

if(c1 == c2)
{
break;
}
}
while(c1 && (c2 != c1));

return -1;
}
else if(c2 == '?')
{
c1 = *s1++;
c2 = *s2++;
continue;
}
else
{
if (c1 >= 'a' && c1 <= 'z') {
c1 -= ('a' - 'A');
}
if (c2 >= 'a' && c2 <= 'z') {
c2 -= ('a' - 'A');
}
if (c1 != c2) {
return c1 < c2 ? -1 : 1;
}
}
}
} while (c1);

return 0;
}

int CCM_stricmp (const char *s1, const char *s2) {
char string[MAX_STRING_CHARS];
Q_strncpyz(string, s1, sizeof(string));
Q_CleanStr(string);

return (s1 && s2) ? CCM_stricmpn (string, s2, 99999) : -1;
}

This is a Q_stricmp that handles wildcards (* and ?) and ignores color codes in names.

In q_shared.h add

int      CCM_stricmp (const char *s1, const char *s2);
int      CCM_stricmpn (const char *s1, const char *s2, int n);


Then in g_local.h add

qboolean   admin;

to the clientSession_t struct

then in g_svcmd.c add

Code:
/* 
=================
Svcmd_Admin_f
=================
*/
void Svcmd_Admin_f(void) {

char player[MAX_STRING_TOKENS];
char  *ipnum;
char  userinfo[MAX_INFO_STRING];
gentity_t *ent;
int i;
qboolean found = qfalse;

if (trap_Argc() < 2)
{
Com_Printf( "Usage: admin <player>\n" );
return;
}

trap_Argv( 1, player, sizeof( player ) );

for(i = 0; i < MAX_CLIENTS; i++)
{
ent = &g_entities[i];
if(ent && ent->client && ent->inuse)
{
if( CCM_stricmp(ent->client->pers.netname, player ) == 0 )
{
trap_GetUserinfo( ent->client->ps.clientNum, userinfo, sizeof( userinfo ) );
ipnum = Info_ValueForKey( userinfo, "ip" );

found = qtrue;

if(ent->client->sess.admin)
{
Com_Printf( "%s^7 is already an admin\n", ent->client->pers.netname );
continue;
}

if(ent->r.svFlags & SVF_BOT)
{
Com_Printf( "%s^7 is a bot\n", ent->client->pers.netname );
continue;
}

ent->client->sess.admin = qtrue;
trap_SendServerCommand( -1,va("cp \"%s\n^3has become an admin!\n\"", ent->client->pers.netname));
G_LogPrintf( "%s^7 %s has become an admin\n", ent->client->pers.netname, ipnum);

Info_SetValueForKey(userinfo, "admins", "1");
trap_SetUserinfo(ent-g_entities, userinfo);
ClientUserinfoChanged( ent-g_entities );
}
}
}

if(!found)
Com_Printf( "No such player: %s^7\n", player );
}

/*
=================
Svcmd_AdminClient_f
=================
*/
void Svcmd_AdminClient_f(void) {

char arg[MAX_STRING_TOKENS];
char  *ipnum;
char  userinfo[MAX_INFO_STRING];
gentity_t *ent;
int clientNum;

if (trap_Argc() < 2)
{
Com_Printf( "Usage: adminclient <clientnum>\n" );
return;
}

trap_Argv( 1, arg, sizeof( arg ) );

clientNum = atoi(arg);
ent = &g_entities[clientNum];
if(ent && ent->client && ent->inuse)
{
trap_GetUserinfo( ent->client->ps.clientNum, userinfo, sizeof( userinfo ) );
ipnum = Info_ValueForKey( userinfo, "ip" );

if(ent->client->sess.admin)
{
Com_Printf( "%s^7 is already an admin\n", ent->client->pers.netname );
return;
}

if(ent->r.svFlags & SVF_BOT)
{
Com_Printf( "%s^7 is a bot\n", ent->client->pers.netname );
return;
}

ent->client->sess.admin = qtrue;
trap_SendServerCommand( -1,va("cp \"%s\n^3has become an admin!\n\"", ent->client->pers.netname));
G_LogPrintf( "%s^7 %s has become an admin\n", ent->client->pers.netname, ipnum);
ClientUserinfoChanged( ent-g_entities );
}
else{
Com_Printf( "No such client: %i^7\n", clientNum );
}
}

/*
=================
Svcmd_DeAdmin_f
=================
*/
void Svcmd_DeAdmin_f(void) {

char player[MAX_STRING_TOKENS];
char  *ipnum;
char  userinfo[MAX_INFO_STRING];
gentity_t *ent;
int i;
qboolean found = qfalse;

if (trap_Argc() < 2)
{
Com_Printf( "Usage: deadmin <player>\n" );
return;
}

trap_Argv( 1, player, sizeof( player ) );

for(i = 0; i < MAX_CLIENTS; i++)
{
ent = &g_entities[i];
if(ent && ent->client && ent->inuse)
{
if( CCM_stricmp(ent->client->pers.netname, player ) == 0 )
{
trap_GetUserinfo( ent->client->ps.clientNum, userinfo, sizeof( userinfo ) );
ipnum = Info_ValueForKey( userinfo, "ip" );

found = qtrue;

if(!ent->client->sess.admin)
{
Com_Printf( "%s is not an admin\n", ent->client->pers.netname );
continue;
}

ent->client->sess.admin = 0;
trap_SendServerCommand( -1,va("cp \"%s\n^3is no longer an admin!\n\"", ent->client->pers.netname));
G_LogPrintf( "%s^7 %s is no longer an admin", ent->client->pers.netname, ipnum);
Info_SetValueForKey(userinfo, "admins", "0");
trap_SetUserinfo(ent-g_entities, userinfo);
ClientUserinfoChanged( ent-g_entities );
}
}
}

if(!found)
Com_Printf( "No such player: %s^7\n", player );
}

/*
=================
Svcmd_DeAdminClient_f
=================
*/
void Svcmd_DeAdminClient_f(void) {

char arg[MAX_STRING_TOKENS];
char  *ipnum;
char  userinfo[MAX_INFO_STRING];
gentity_t *ent;
int clientNum;

if (trap_Argc() < 2)
{
Com_Printf( "Usage: deadminclient <clientnum>\n" );
return;
}

trap_Argv( 1, arg, sizeof( arg ) );

clientNum = atoi(arg);
ent = &g_entities[clientNum];
if(ent && ent->client && ent->inuse)
{
trap_GetUserinfo( ent->client->ps.clientNum, userinfo, sizeof( userinfo ) );
ipnum = Info_ValueForKey( userinfo, "ip" );

if(!ent->client->sess.admin)
{
Com_Printf( "%s^7 is not an admin\n", ent->client->pers.netname );
return;
}

ent->client->sess.admin = 0;
trap_SendServerCommand( -1,va("cp \"%s\n^3is no longer an admin!\n\"", ent->client->pers.netname));
G_LogPrintf( "%s^7 %s is no longer an admin\n", ent->client->pers.netname, ipnum);
ClientUserinfoChanged( ent-g_entities );
}
else{
Com_Printf( "No such client: %i^7\n", clientNum );
}
}

That's basically it for the admin command


Title: Re: Admin options
Post by: beast on March 12, 2008, 02:09:33 PM
If you can, you should probably post the code changes as a diff file...


Title: Re: Admin options
Post by: fromhell on March 13, 2008, 12:27:39 PM
If you can, you should probably become my new coder


Title: Re: Admin options
Post by: Crash!!! on March 13, 2008, 01:37:50 PM
How about you keep the old coder too and you have 2x the coder!


Title: Re: Admin options
Post by: iLeft.bye on March 13, 2008, 04:36:52 PM
How about you keep the old coder too and you have 2x the coder!

old coder is old


Title: Re: Admin options
Post by: escapedturkey on March 13, 2008, 05:50:47 PM
Unlagged code is now GPL.

http://turkey.escapedturkey.net/unlagged/unlagged-2.01-src-gpl.zip