mirror of
https://git.code.sf.net/p/quake/prozac-qfcc
synced 2024-11-27 14:32:03 +00:00
Initial commit of UserInfoCallback and setinfokey stuff. color,
skin, and team are all set using setinfokey. You are no longer kicked for changing them. And the callback happily rejects every attempted change from the client (for skin and color atleast).
This commit is contained in:
parent
f009263dc2
commit
9977533035
3 changed files with 123 additions and 65 deletions
1
defs.qc
1
defs.qc
|
@ -841,6 +841,7 @@ float(string s) stof = #81; // convert string to float
|
|||
void(vector where, float set) multicast = #82; // sends the temp message to a set
|
||||
// of clients, possibly in PVS or PHS
|
||||
#endif
|
||||
void (entity ent, string key, string value) setinfokey = #102;
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
|
86
tfort.qc
86
tfort.qc
|
@ -1735,11 +1735,11 @@ void(entity p) TeamFortress_SetSkin =
|
|||
else
|
||||
p.skin = p.playerclass;
|
||||
|
||||
st = "base"; // just in case
|
||||
|
||||
#ifdef QUAKE_WORLD
|
||||
if (p.skin != #PC_UNDEFINED)
|
||||
{
|
||||
stuffcmd(p, "skin ");
|
||||
|
||||
//WK Figure out what Mr.Custom Should look like
|
||||
if (p.playerclass == #PC_CUSTOM && p.undercover_skin == 0)
|
||||
{
|
||||
|
@ -1749,95 +1749,95 @@ void(entity p) TeamFortress_SetSkin =
|
|||
if ( p.team_no == 4)
|
||||
{
|
||||
if ( p.skin == #PC_SCOUT )
|
||||
stuffcmd(p, #TEAM4_SCOUT_SKIN);
|
||||
st = #TEAM4_SCOUT_SKIN;
|
||||
else if ( p.skin == #PC_SNIPER )
|
||||
stuffcmd(p, #TEAM4_SNIPER_SKIN);
|
||||
st = #TEAM4_SNIPER_SKIN;
|
||||
else if ( p.skin == #PC_SOLDIER )
|
||||
stuffcmd(p, #TEAM4_SOLDIER_SKIN);
|
||||
st = #TEAM4_SOLDIER_SKIN;
|
||||
else if ( p.skin == #PC_DEMOMAN )
|
||||
stuffcmd(p, #TEAM4_DEMOMAN_SKIN);
|
||||
st = #TEAM4_DEMOMAN_SKIN;
|
||||
else if ( p.skin == #PC_MEDIC )
|
||||
stuffcmd(p, #TEAM4_MEDIC_SKIN);
|
||||
st = #TEAM4_MEDIC_SKIN;
|
||||
else if ( p.skin == #PC_HVYWEAP )
|
||||
stuffcmd(p, #TEAM4_HVYWEAP_SKIN);
|
||||
st = #TEAM4_HVYWEAP_SKIN;
|
||||
else if ( p.skin == #PC_PYRO )
|
||||
stuffcmd(p, #TEAM4_PYRO_SKIN);
|
||||
st = #TEAM4_PYRO_SKIN;
|
||||
else if ( p.skin == #PC_SPY )
|
||||
stuffcmd(p, #TEAM4_SPY_SKIN);
|
||||
st = #TEAM4_SPY_SKIN;
|
||||
else if ( p.skin == #PC_ENGINEER )
|
||||
stuffcmd(p, #TEAM4_ENGINEER_SKIN);
|
||||
st = #TEAM4_ENGINEER_SKIN;
|
||||
}
|
||||
else if ( p.team_no == 3)
|
||||
{
|
||||
if ( p.skin == #PC_SCOUT )
|
||||
stuffcmd(p, #TEAM3_SCOUT_SKIN);
|
||||
st = #TEAM3_SCOUT_SKIN;
|
||||
else if ( p.skin == #PC_SNIPER )
|
||||
stuffcmd(p, #TEAM3_SNIPER_SKIN);
|
||||
st = #TEAM3_SNIPER_SKIN;
|
||||
else if ( p.skin == #PC_SOLDIER )
|
||||
stuffcmd(p, #TEAM3_SOLDIER_SKIN);
|
||||
st = #TEAM3_SOLDIER_SKIN;
|
||||
else if ( p.skin == #PC_DEMOMAN )
|
||||
stuffcmd(p, #TEAM3_DEMOMAN_SKIN);
|
||||
st = #TEAM3_DEMOMAN_SKIN;
|
||||
else if ( p.skin == #PC_MEDIC )
|
||||
stuffcmd(p, #TEAM3_MEDIC_SKIN);
|
||||
st = #TEAM3_MEDIC_SKIN;
|
||||
else if ( p.skin == #PC_HVYWEAP )
|
||||
stuffcmd(p, #TEAM3_HVYWEAP_SKIN);
|
||||
st = #TEAM3_HVYWEAP_SKIN;
|
||||
else if ( p.skin == #PC_PYRO )
|
||||
stuffcmd(p, #TEAM3_PYRO_SKIN);
|
||||
st = #TEAM3_PYRO_SKIN;
|
||||
else if ( p.skin == #PC_SPY )
|
||||
stuffcmd(p, #TEAM3_SPY_SKIN);
|
||||
st = #TEAM3_SPY_SKIN;
|
||||
else if ( p.skin == #PC_ENGINEER )
|
||||
stuffcmd(p, #TEAM3_ENGINEER_SKIN);
|
||||
st = #TEAM3_ENGINEER_SKIN;
|
||||
}
|
||||
else if ( p.team_no == 2)
|
||||
{
|
||||
if ( p.skin == #PC_SCOUT )
|
||||
stuffcmd(p, #TEAM2_SCOUT_SKIN);
|
||||
st = #TEAM2_SCOUT_SKIN;
|
||||
else if ( p.skin == #PC_SNIPER )
|
||||
stuffcmd(p, #TEAM2_SNIPER_SKIN);
|
||||
st = #TEAM2_SNIPER_SKIN;
|
||||
else if ( p.skin == #PC_SOLDIER )
|
||||
stuffcmd(p, #TEAM2_SOLDIER_SKIN);
|
||||
st = #TEAM2_SOLDIER_SKIN;
|
||||
else if ( p.skin == #PC_DEMOMAN )
|
||||
stuffcmd(p, #TEAM2_DEMOMAN_SKIN);
|
||||
st = #TEAM2_DEMOMAN_SKIN;
|
||||
else if ( p.skin == #PC_MEDIC )
|
||||
stuffcmd(p, #TEAM2_MEDIC_SKIN);
|
||||
st = #TEAM2_MEDIC_SKIN;
|
||||
else if ( p.skin == #PC_HVYWEAP )
|
||||
stuffcmd(p, #TEAM2_HVYWEAP_SKIN);
|
||||
st = #TEAM2_HVYWEAP_SKIN;
|
||||
else if ( p.skin == #PC_PYRO )
|
||||
stuffcmd(p, #TEAM2_PYRO_SKIN);
|
||||
st = #TEAM2_PYRO_SKIN;
|
||||
else if ( p.skin == #PC_SPY )
|
||||
stuffcmd(p, #TEAM2_SPY_SKIN);
|
||||
st = #TEAM2_SPY_SKIN;
|
||||
else if ( p.skin == #PC_ENGINEER )
|
||||
stuffcmd(p, #TEAM2_ENGINEER_SKIN);
|
||||
st = #TEAM2_ENGINEER_SKIN;
|
||||
}
|
||||
else // if ( p.team_no == 1)
|
||||
{
|
||||
if ( p.skin == #PC_SCOUT )
|
||||
stuffcmd(p, #TEAM1_SCOUT_SKIN);
|
||||
st = #TEAM1_SCOUT_SKIN;
|
||||
else if ( p.skin == #PC_SNIPER )
|
||||
stuffcmd(p, #TEAM1_SNIPER_SKIN);
|
||||
st = #TEAM1_SNIPER_SKIN;
|
||||
else if ( p.skin == #PC_SOLDIER )
|
||||
stuffcmd(p, #TEAM1_SOLDIER_SKIN);
|
||||
st = #TEAM1_SOLDIER_SKIN;
|
||||
else if ( p.skin == #PC_DEMOMAN )
|
||||
stuffcmd(p, #TEAM1_DEMOMAN_SKIN);
|
||||
st = #TEAM1_DEMOMAN_SKIN;
|
||||
else if ( p.skin == #PC_MEDIC )
|
||||
stuffcmd(p, #TEAM1_MEDIC_SKIN);
|
||||
st = #TEAM1_MEDIC_SKIN;
|
||||
else if ( p.skin == #PC_HVYWEAP )
|
||||
stuffcmd(p, #TEAM1_HVYWEAP_SKIN);
|
||||
st = #TEAM1_HVYWEAP_SKIN;
|
||||
else if ( p.skin == #PC_PYRO )
|
||||
stuffcmd(p, #TEAM1_PYRO_SKIN);
|
||||
st = #TEAM1_PYRO_SKIN;
|
||||
else if ( p.skin == #PC_SPY )
|
||||
stuffcmd(p, #TEAM1_SPY_SKIN);
|
||||
st = #TEAM1_SPY_SKIN;
|
||||
else if ( p.skin == #PC_ENGINEER )
|
||||
stuffcmd(p, #TEAM1_ENGINEER_SKIN);
|
||||
st = #TEAM1_ENGINEER_SKIN;
|
||||
}
|
||||
|
||||
if ( p.skin == #PC_CIVILIAN )
|
||||
stuffcmd(p, "base\n"); // Need a civilian skin
|
||||
}
|
||||
else
|
||||
{
|
||||
stuffcmd(p, "skin base\n"); //WK Need a custom skin, or fake it
|
||||
st = "base\n"; // Need a civilian skin
|
||||
}
|
||||
stuffcmd(p, "skin ");
|
||||
stuffcmd(p, st);
|
||||
stuffcmd(p, "\n");
|
||||
setinfokey(p, "skin", st);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
101
tforttm.qc
101
tforttm.qc
|
@ -207,10 +207,11 @@ void(entity p) SetTeamName =
|
|||
{
|
||||
local string st;
|
||||
|
||||
stuffcmd(p, "team ");
|
||||
st = GetTeamName(p.team_no);
|
||||
stuffcmd(p, "team ");
|
||||
stuffcmd(p, st);
|
||||
stuffcmd(p, "\n");
|
||||
setinfokey(p, "team", st);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -295,7 +296,11 @@ float(float tno) TeamFortress_TeamSet =
|
|||
// color command works.
|
||||
makeImmune(self,time+10);
|
||||
//self.immune_to_check = time + 10;
|
||||
|
||||
// FOO
|
||||
tc = TeamFortress_TeamGetColor(tno) - 1;
|
||||
st = ftos(tc);
|
||||
setinfokey(self, "color", st);
|
||||
/*
|
||||
// Set the player's color
|
||||
stuffcmd(self, "color ");
|
||||
tc = TeamFortress_TeamGetColor(tno) - 1;
|
||||
|
@ -306,7 +311,7 @@ float(float tno) TeamFortress_TeamSet =
|
|||
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
|
||||
*/
|
||||
self.team_no = tno;
|
||||
self.lives = TeamFortress_TeamGetLives(tno);
|
||||
|
||||
|
@ -334,6 +339,12 @@ float(float tno) TeamFortress_TeamSet =
|
|||
bprint(#PRINT_HIGH, st);
|
||||
bprint(#PRINT_HIGH, ".\n");
|
||||
|
||||
//FOO
|
||||
tc = TeamFortress_TeamGetColor(tno) - 1;
|
||||
st = ftos(tc);
|
||||
setinfokey(self, "topcolor", st);
|
||||
setinfokey(self, "bottomcolor", st);
|
||||
|
||||
// Set the player's color
|
||||
stuffcmd(self, "color ");
|
||||
tc = TeamFortress_TeamGetColor(tno) - 1;
|
||||
|
@ -348,7 +359,7 @@ float(float tno) TeamFortress_TeamSet =
|
|||
self.team_no = tno;
|
||||
// Prevent the cheatchecking mechanism from nabbing them b4 the
|
||||
// color command works.
|
||||
makeImmune(self,time+10);
|
||||
// makeImmune(self,time+10);
|
||||
//self.immune_to_check = time + 10;
|
||||
self.lives = TeamFortress_TeamGetLives(tno);
|
||||
|
||||
|
@ -447,10 +458,12 @@ void() TeamFortress_CheckTeamCheats =
|
|||
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
setinfokey(self, "topcolor", st);
|
||||
setinfokey(self, "bottomcolor", st);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -466,10 +479,12 @@ void() TeamFortress_CheckTeamCheats =
|
|||
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
setinfokey(self, "topcolor", st);
|
||||
setinfokey(self, "bottomcolor", st);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
@ -496,10 +511,12 @@ void() TeamFortress_CheckTeamCheats =
|
|||
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
setinfokey(self, "topcolor", st);
|
||||
setinfokey(self, "bottomcolor", st);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -520,10 +537,12 @@ void() TeamFortress_CheckTeamCheats =
|
|||
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
setinfokey(self, "topcolor", st);
|
||||
setinfokey(self, "bottomcolor", st);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -542,9 +561,9 @@ void() TeamFortress_CheckTeamCheats =
|
|||
{
|
||||
TeamFortress_SetSkin(self);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
}
|
||||
|
||||
if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_skin != 0)
|
||||
|
@ -597,9 +616,9 @@ void() TeamFortress_CheckTeamCheats =
|
|||
|
||||
TeamFortress_SetSkin(self);
|
||||
|
||||
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
|
||||
sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
|
||||
stuffcmd(self, "disconnect\n");
|
||||
// bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
|
||||
// sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
|
||||
// stuffcmd(self, "disconnect\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -628,6 +647,44 @@ void() TeamFortress_CheckTeamCheats =
|
|||
}
|
||||
};
|
||||
|
||||
void(string key, string value) UserInfoCallback =
|
||||
{
|
||||
local string oldval;
|
||||
local string st;
|
||||
oldval = infokey(self, key);
|
||||
|
||||
if(value == oldval) // generic reject
|
||||
{
|
||||
bprint(#PRINT_MEDIUM, "[oldval (" + key + ")(" + value + ")(" + oldval + ")]\n");
|
||||
return 1; // rejected!
|
||||
}
|
||||
|
||||
if (key == "topcolor" || key == "bottomcolor")
|
||||
{
|
||||
// no changing colors allowed
|
||||
st = infokey(self, "bottomcolor"); // make sure top is same as bottom
|
||||
setinfokey(self, "topcolor", st);
|
||||
stuffcmd(self, "color ");
|
||||
stuffcmd(self, st);
|
||||
stuffcmd(self, "\n");
|
||||
bprint(#PRINT_MEDIUM, "[color (" + key + ")(" + value + ")(" + oldval + ")]\n");
|
||||
return 1;
|
||||
}
|
||||
else if (key == "skin")
|
||||
{
|
||||
stuffcmd(self, "skin ");
|
||||
stuffcmd(self, oldval);
|
||||
stuffcmd(self, "\n");
|
||||
bprint(#PRINT_MEDIUM, "[skin (" + key + ")(" + value + ")(" + oldval + ")]\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bprint(#PRINT_MEDIUM, "[default (" + key + ")(" + value + ")(" + oldval + ")]\n");
|
||||
return 0; // accept everything else
|
||||
}
|
||||
};
|
||||
|
||||
//=========================================================================
|
||||
// Increase the score of a team
|
||||
void(float tno, float scoretoadd) TeamFortress_TeamIncreaseScore =
|
||||
|
|
Loading…
Reference in a new issue