prozac-qfcc/admin.qc

516 lines
13 KiB
C++
Raw Normal View History

2001-07-17 05:58:10 +00:00
/*
Functions handling TeamFortress Administration for Net Servers
!NOTE! parm15 is used to pass admin status across maps
*/
#include "defs.qh"
2001-07-17 05:58:10 +00:00
#ifdef QUAKE_WORLD
//Goes for whole file
float() Admin_is_Disabled =
{
local string st;
st = infokey(world, "no_admin");
if (st == "1" || st == "on")
{
sprint(self, PRINT_HIGH, "All admin actions are disabled.\n");
return TRUE;
2001-07-17 05:58:10 +00:00
}
return FALSE;
2001-07-17 05:58:10 +00:00
};
float(entity theAdmin) HasValidAdminTarget =
{
if (theAdmin.admin_kick.classname != "player") {
sprint(theAdmin, PRINT_HIGH, "No user selected!\n");
2001-07-17 05:58:10 +00:00
theAdmin.admin_kick = world;
return FALSE;
2001-07-17 05:58:10 +00:00
}
if (theAdmin.admin_kick.has_disconnected) {
sprint(theAdmin, PRINT_HIGH, "User has disconnected!\n");
2001-07-17 05:58:10 +00:00
theAdmin.admin_kick = world;
return FALSE;
2001-07-17 05:58:10 +00:00
}
return TRUE;
2001-07-17 05:58:10 +00:00
};
float(entity person) Is_Admin =
{
local string pass;
if (person.admin_flag == TRUE) //I am admin :)
return TRUE;
2001-07-17 05:58:10 +00:00
else
{
pass = infokey(world, "adminpwd");
if (pass != string_null)
{
if (infokey(person, "adminpwd") == pass)
{
person.admin_flag = TRUE;
2001-07-17 05:58:10 +00:00
stuffcmd(person, "setinfo adminpwd \"\"\n"); //Remove from info
return TRUE;
2001-07-17 05:58:10 +00:00
}
}
}
person.admin_flag = FALSE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
void(entity person) Check_Admin_Password =
{
if (person.admin_flag)
{
sprint(person, PRINT_HIGH, "You already have access as admin!\n");
2001-07-17 05:58:10 +00:00
stuffcmd(person, "setinfo adminpwd \"\"\n"); //Remove from info
return;
}
local string pass;
pass = infokey(world, "adminpwd");
if (pass != string_null)
{
if (infokey(person, "adminpwd") == pass)
{
person.admin_flag = TRUE;
2001-07-17 05:58:10 +00:00
stuffcmd(person, "setinfo adminpwd \"\"\n"); //Remove from info
sprint(person, PRINT_HIGH, "Admin password correct...\n");
2001-07-17 05:58:10 +00:00
return;
}
}
RPrint(person.netname);
RPrint(" requests admin password check with an incorrect or inexistent password set.\n");
};
void() Admin_Kick_Cycle =
{
if (!Is_Admin(self)) //If not an admin go away
{
sprint(self, PRINT_HIGH, "You are not allowed to use the 'get' command\n");
2001-07-17 05:58:10 +00:00
return;
}
if (Admin_is_Disabled())
return;
local entity te;
local float num;
local float loopc;
loopc = 0;
num = FALSE;
2001-07-17 05:58:10 +00:00
te = world;
te = find(self.admin_kick, classname, "player");
while (te != world && num == FALSE)
2001-07-17 05:58:10 +00:00
{
num = TRUE;
2001-07-17 05:58:10 +00:00
if (te.has_disconnected)
num = FALSE;
2001-07-17 05:58:10 +00:00
if (self.admin_kick==te)
num = FALSE;
2001-07-17 05:58:10 +00:00
if (num == FALSE) te = find(te, classname, "player");
2001-07-17 05:58:10 +00:00
}
//te = world;
/*while (num == FALSE && loopc < 32)
2001-07-17 05:58:10 +00:00
{
num = TRUE;
2001-07-17 05:58:10 +00:00
te = checkclient();
if (te.classname != "player")
num = FALSE;
2001-07-17 05:58:10 +00:00
else if (te.has_disconnected)
num = FALSE;
2001-07-17 05:58:10 +00:00
//- OfN -//
else if (!te)
num = FALSE;
2001-07-17 05:58:10 +00:00
if (self.admin_kick==te)
num = FALSE;
2001-07-17 05:58:10 +00:00
loopc = loopc + 1;
}*/
//if (loopc >= 32) {
if (te == world) {
sprint(self, PRINT_HIGH, "No Clients Found!\n");
2001-07-17 05:58:10 +00:00
self.admin_kick=world;
} else {
self.admin_kick = te; //Set current selected person
//sprint(self, PRINT_HIGH, "You can type <20><><EFBFBD><EFBFBD> or <20><><EFBFBD> to throw them out. Type <20><><EFBFBD> again to select someone else.");
sprint(self, PRINT_HIGH, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
sprint(self, PRINT_HIGH, self.admin_kick.netname);
sprint(self, PRINT_HIGH, "\n");
2001-07-17 05:58:10 +00:00
}
};
void() Admin_Kick_Person =
{
if (!Is_Admin(self)) //If not an admin go away
{
sprint(self, PRINT_HIGH, "You are not allowed to use the 'kick' command\n");
2001-07-17 05:58:10 +00:00
return;
}
if (Admin_is_Disabled())
return;
if (self.admin_kick != world) //Bad
{
//WK Add checks so that it doesn't crash the server!
/*if (self.admin_kick.classname != "player") {
self.admin_kick = world;
return;
}
if (self.admin_kick.has_disconnected) {
self.admin_kick = world;
return;
}*/
if (!HasValidAdminTarget(self))
return;
bprint(PRINT_HIGH, self.admin_kick.netname);
bprint(PRINT_HIGH, " has been kicked by the admin ");
bprint(PRINT_HIGH, self.netname);
bprint(PRINT_HIGH, "\n");
2001-07-17 05:58:10 +00:00
stuffcmd(self.admin_kick, "disconnect\n"); //Kick them!
self.admin_kick = world; //Clear it //WK BUG! Used to be ==
}
else
sprint(self, PRINT_HIGH, "No target client selected!\n");
2001-07-17 05:58:10 +00:00
};
//WK Same code as Bloggy's, but with some happy code for banning
void() Admin_Ban_Person =
{
local string foo;
if (!Is_Admin(self)) //If not an admin go away
{
sprint(self, PRINT_HIGH, "You are not allowed to use the 'ban' command\n");
2001-07-17 05:58:10 +00:00
return;
}
if (Admin_is_Disabled())
return;
if (self.admin_kick != world) //Bad
{
//WK Add checks so that it doesn't crash the server!
/*if (self.admin_kick.classname != "player") {
self.admin_kick = world;
return;
}
if (self.admin_kick.has_disconnected) {
self.admin_kick = world;
return;
}*/
if (!HasValidAdminTarget(self))
return;
bprint(PRINT_HIGH, self.admin_kick.netname);
bprint(PRINT_HIGH, " has been BANNED by the admin ");
bprint(PRINT_HIGH, self.netname);
bprint(PRINT_HIGH, "\n");
2001-07-17 05:58:10 +00:00
foo = infokey(self.admin_kick,"ip");
localcmd("addip ");
localcmd(foo);
localcmd("\n");
stuffcmd(self.admin_kick, "disconnect\n"); //Kick them!
self.admin_kick = world; //Clear it //WK BUG! Used to be ==
}
else
sprint(self, PRINT_HIGH, "No target client selected!\n");
2001-07-17 05:58:10 +00:00
};
void (entity player) RemoveHolo;
float (float tno) TeamFortress_TeamGetLives;
void(entity p) SetTeamName;
//- OfN - my evil addition to the admin stuff
void() Admin_Cmd =
{
local string st;
if (!Is_Admin(self)) //If not an admin go away
{
sprint(self, PRINT_HIGH, "You are not allowed to use the 'cmnd' command\n");
2001-07-17 05:58:10 +00:00
return;
}
if (Admin_is_Disabled())
return;
if (self.admin_kick != world) //Bad
{
//WK Add checks so that it doesn't crash the server!
/*if (self.admin_kick.classname != "player") {
sprint(self, PRINT_HIGH, "No user selected!\n");
2001-07-17 05:58:10 +00:00
self.admin_kick = world;
return;
}
if (self.admin_kick.has_disconnected) {
sprint(self, PRINT_HIGH, "User has disconnected!\n");
2001-07-17 05:58:10 +00:00
self.admin_kick = world;
return;
}*/
if (!HasValidAdminTarget(self))
return;
st = infokey(self, "cmnd");
if (st == string_null)
{
sprint(self, PRINT_HIGH, "You have no CMND set!\n");
2001-07-17 05:58:10 +00:00
}
else if (st == "curse")
{
local float tf;
local string st2;
tf = 0;
st2 = infokey(world, "curse");
if (st2 == string_null)
tf = stof(st2);
bprint(PRINT_HIGH,"The admin ");
bprint(PRINT_HIGH,self.netname);
bprint(PRINT_HIGH," curses ");
bprint(PRINT_HIGH,self.admin_kick.netname);
bprint(PRINT_HIGH,"\n");
2001-07-17 05:58:10 +00:00
createBastard(self.admin_kick,tf);
}
else if (st == "gimmedat")
{
sprint(self.admin_kick,PRINT_HIGH,"If you are using this to cheat, you are LAME!\n");
2001-07-17 05:58:10 +00:00
self.admin_kick.money = 99999;
}
else if (st == "team1" || st == "team2" || st == "team3" || st == "team4")
{
local float targetteam, tc, tc2;
2001-07-17 05:58:10 +00:00
local string st2;
if (st == "team1")
targetteam = 1;
else if (st == "team2")
targetteam = 2;
else if (st == "team3")
{
if (number_of_teams < 3)
{
sprint(self,PRINT_HIGH,"No team 3 on this map!\n");
2001-07-17 05:58:10 +00:00
return;
}
targetteam = 3;
}
else
{
if (number_of_teams < 4)
{
sprint(self,PRINT_HIGH,"No team 4 on this map!\n");
2001-07-17 05:58:10 +00:00
return;
}
targetteam = 4;
}
if (self.admin_kick.team_no == targetteam)
{
st = ftos(targetteam);
sprint(self,PRINT_HIGH,"Player ");
sprint(self,PRINT_HIGH,self.admin_kick.netname);
sprint(self,PRINT_HIGH," is already on team ");
sprint(self,PRINT_HIGH,st);
sprint(self,PRINT_HIGH,"!\n");
2001-07-17 05:58:10 +00:00
return;
}
if (self.admin_kick.playerclass == PC_UNDEFINED)
2001-07-17 05:58:10 +00:00
{
sprint(self,PRINT_HIGH,"Player ");
sprint(self,PRINT_HIGH,self.admin_kick.netname);
sprint(self,PRINT_HIGH," is observing the game\n");
2001-07-17 05:58:10 +00:00
return;
}
if (self.admin_kick.done_custom & CUSTOM_BUILDING)
2001-07-17 05:58:10 +00:00
{
sprint(self,PRINT_HIGH,"Player ");
sprint(self,PRINT_HIGH,self.admin_kick.netname);
sprint(self,PRINT_HIGH," is still customizing\n");
2001-07-17 05:58:10 +00:00
return;
}
local entity oself;
oself = self;
self = self.admin_kick;
if (self.has_holo > 0 ) RemoveHolo(self);
kill_my_demon();//FIXED?
DetonateMines(self);
//RemoveArmyTimer();
DetonateAllGuns();
self = oself;
// Set the player's color
tc = TeamGetColor (targetteam) - 1;
tc2 = TeamGetNiceColor (targetteam);
SetPlayerColor (self, tc, tc2);
2001-07-17 05:58:10 +00:00
self.admin_kick.team_no = targetteam;
makeImmune(self.admin_kick,time+15);
self.admin_kick.lives = TeamFortress_TeamGetLives(targetteam);
SetTeamName(self.admin_kick);
bprint(PRINT_HIGH,"Player ");
bprint(PRINT_HIGH,self.admin_kick.netname);
bprint(PRINT_HIGH," is assigned to ");
2001-07-17 05:58:10 +00:00
if (targetteam == 1)
bprint(PRINT_HIGH,"team 1\n");
2001-07-17 05:58:10 +00:00
else if (targetteam == 2)
bprint(PRINT_HIGH,"team 2\n");
2001-07-17 05:58:10 +00:00
else if (targetteam == 3)
bprint(PRINT_HIGH,"team 3\n");
else bprint(PRINT_HIGH,"team 4\n");
2001-07-17 05:58:10 +00:00
oself = self;
self = self.admin_kick;
PutClientInServer();
self = oself;
return; // job done!
}
else
{
stuffcmd(self.admin_kick,st); // execute command
stuffcmd(self.admin_kick,"\n");
sprint(self,PRINT_HIGH, "Command '");
sprint(self,PRINT_HIGH, st);
sprint(self,PRINT_HIGH, "' has been executed for ");
sprint(self, PRINT_HIGH, self.admin_kick.netname);
sprint(self, PRINT_HIGH, "\n");
2001-07-17 05:58:10 +00:00
}
}
else
sprint(self, PRINT_HIGH, "No target client selected!\n");
2001-07-17 05:58:10 +00:00
};
void() Admin_Call_Ceasefire =
{
local string st;
if (!Is_Admin(self)) //If not an admin go away
{
sprint(self, PRINT_HIGH, "You are not allowed to use the 'ceasefire' command\n");
2001-07-17 05:58:10 +00:00
return;
}
if (Admin_is_Disabled())
return;
st = infokey(world, "ceasefire");
if (st == "on")
{
localcmd("localinfo ceasefire \"off\"\n"); //Turn it off
//bprint(PRINT_HIGH, self.netname);
bprint(PRINT_HIGH, "The game resumes now...\n");
2001-07-17 05:58:10 +00:00
}
else
{
localcmd("localinfo ceasefire \"on\"\n"); //Turn it off
bprint(PRINT_HIGH, self.netname);
bprint(PRINT_HIGH, " forced a ceasefire.\n");
2001-07-17 05:58:10 +00:00
}
};
//contains the list of impulses that can be used during ceasefire
//returns TRUE if its good
float(float inp) Good_Impulse =
{
if (inp == TF_MEDIC_HELPME ||
inp == TF_TAUNT ||
inp == TF_TAUNT2 ||
inp == TF_TAUNT3 ||
inp == TF_TAUNT4 ||
inp == TF_TAUNT5 ||
inp == TF_ADMIN_KICK_CYCLE ||
inp == TF_ADMIN_KICK_PERSON ||
inp == TF_ADMIN_BAN_PERSON ||
inp == TF_STATUS_QUERY ||
inp == TF_ADMIN_CEASEFIRE ||
inp == TF_DISPLAYLOCATION ||
inp == TF_STATUS_QUERY ||
inp == TF_HELP_MAP ||
inp == TF_INVENTORY ||
inp == TF_SHOWTF ||
inp == FLAG_INFO ||
inp == I_CHEAT_ONE ||
inp == I_CHEAT_TWO ||
inp == I_CHEAT_THREE ||
inp == IMPULSE_DEBUG || //- OfN -
inp == IMPULSE_UPDATEINFO || //- OfN -
inp == IMPULSE_CHECKADMIN || //- OfN -
inp == IMPULSE_STUFFCMD) //- OfN -
return TRUE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
//contains the list of impulses that can be used during ceasefire
//returns TRUE if its good
float(float inp) Good_Impulse_OnMenu =
{
if (/*inp == TF_MEDIC_HELPME ||
inp == TF_TAUNT ||
inp == TF_TAUNT2 ||
inp == TF_TAUNT3 ||
inp == TF_TAUNT4 ||
inp == TF_TAUNT5 ||*/
inp == TF_ADMIN_KICK_CYCLE ||
inp == TF_ADMIN_KICK_PERSON ||
inp == TF_ADMIN_BAN_PERSON ||
inp == TF_STATUS_QUERY ||
inp == TF_ADMIN_CEASEFIRE ||
inp == TF_DISPLAYLOCATION ||
inp == TF_STATUS_QUERY ||
inp == TF_HELP_MAP ||
inp == TF_INVENTORY ||
inp == TF_SHOWTF ||
inp == FLAG_INFO ||
inp == I_CHEAT_ONE ||
inp == I_CHEAT_TWO ||
inp == I_CHEAT_THREE ||
inp == IMPULSE_DEBUG || //- OfN -
inp == IMPULSE_UPDATEINFO || //- OfN -
inp == IMPULSE_CHECKADMIN || //- OfN -
inp == IMPULSE_STUFFCMD) //- OfN -
return TRUE;
return FALSE;
2001-07-17 05:58:10 +00:00
};
#endif