Example #1
0
static PyObject *playerIpLong(PyObject *self, PyObject *args)
{
	int cn;
	server::clientinfo *ci;
	if(!PyArg_ParseTuple(args, "i", &cn))
		return 0;
	ci = server::getinfo(cn);
	if(!ci)
	{
		PyErr_SetString(PyExc_ValueError, "Invalid cn specified");
		return 0;
	}
	return Py_BuildValue("k", getclientip(ci->clientnum));
}
Example #2
0
			return;
		}

		if(ci->state.aitype != AI_NONE)
		{
			// todo: error
			intret(RINT_ERROR);
			return;
		}

		sendf(*cn, 1, "ris", N_SERVMSG, msg);
	}

	void playersessionid(int *cn)
	{
		CN_INFO_RET(getclientip(ci->sessionid))
	}

	void playeriplong(int *cn)
	{
		CN_INFO_RET(getclientip(ci->clientnum))
	}

	void playerkick(int *cn)
	{
		server::clientinfo *ci = server::getinfo(*cn);

		if(!ci)
		{
			// todo: some error mechanism
			intret(RINT_ERROR);
Example #3
0
ICOMMAND(addbot, "i", (int* s),aiman::addai(clamp(*s, 1, 101), 4));
ICOMMAND(delbot, "", (),aiman::deleteai());
ICOMMAND(map, "s", (char* map),changemap(map,gamemode));
ICOMMAND(mode, "i", (int* mode),gamemode=*mode);
ICOMMAND(gamespeed, "i", (int* speed),changegamespeed(*speed));
ICOMMAND(kick, "i", (int* victim),{addban(getclientip(*victim), 4*60*60000);disconnect_client(*victim, DISC_KICK);});
ICOMMAND(quit, "i", (int* code),exit(*code));
ICOMMAND(intermission, "", (),startintermission());
ICOMMAND(recorddemo, "i", (int *val), demonextmatch = *val!=0);

int parseplayer(const char *arg){
    char *end;
    int n = strtol(arg, &end, 10);
    if(*arg && !*end){
        if(!clients.inrange(n)) return -1;
        return n;
    }
    // try case sensitive first
    loopv(clients){
        clientinfo *o = clients[i];
        if(!strcmp(arg, o->name)) return o->clientnum;
    }
    // nothing found, try case insensitive
    loopv(clients){
        clientinfo *o = clients[i];
        if(!strcasecmp(arg, o->name)) return o->clientnum;
    }
    return -1;
}
void togglespectator(int val, const char *who){
    int spectator=parseplayer(who);