2019-01-19 04:50:25 +00:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the file LICENSE attached with the sources for usage details.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
|
2019-01-29 02:40:14 +00:00
|
|
|
|
|
|
|
void Empty(void) {}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_ClientConnect(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
bprint(PRINT_HIGH, sprintf("%s connected\n", self.netname));
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_ClientDisconnect(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
bprint(PRINT_HIGH, sprintf("%s disconnected\n", self.netname));
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_ClientKill(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_PlayerPreThink(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_PlayerPostThink(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-21 02:00:14 +00:00
|
|
|
self.SendFlags = 1;
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_RunClientCommand(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-21 02:00:14 +00:00
|
|
|
Footsteps_Update();
|
|
|
|
QPhysics_Run(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Game_DecodeChangeParms(void)
|
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
player pl = (player)self;
|
2019-01-21 02:00:14 +00:00
|
|
|
g_landmarkpos[0] = parm1;
|
|
|
|
g_landmarkpos[1] = parm2;
|
|
|
|
g_landmarkpos[2] = parm3;
|
2019-01-29 02:40:14 +00:00
|
|
|
pl.angles[0] = parm4;
|
|
|
|
pl.angles[1] = parm5;
|
|
|
|
pl.angles[2] = parm6;
|
|
|
|
pl.velocity[0] = parm7;
|
|
|
|
pl.velocity[1] = parm8;
|
|
|
|
pl.velocity[2] = parm9;
|
|
|
|
pl.items = parm10;
|
|
|
|
pl.activeweapon = parm11;
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_SetChangeParms(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
player pl = (player)self;
|
2019-01-21 02:00:14 +00:00
|
|
|
parm1 = g_landmarkpos[0];
|
|
|
|
parm2 = g_landmarkpos[1];
|
|
|
|
parm3 = g_landmarkpos[2];
|
2019-01-29 02:40:14 +00:00
|
|
|
parm4 = pl.angles[0];
|
|
|
|
parm5 = pl.angles[1];
|
|
|
|
parm6 = pl.angles[2];
|
|
|
|
parm7 = pl.velocity[0];
|
|
|
|
parm8 = pl.velocity[1];
|
|
|
|
parm9 = pl.velocity[2];
|
|
|
|
parm10 = pl.items;
|
|
|
|
parm11 = pl.activeweapon;
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_PutClientInServer(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
if (self.classname != "player") {
|
|
|
|
spawnfunc_player();
|
|
|
|
}
|
|
|
|
player pl = (player)self;
|
2019-01-19 04:50:25 +00:00
|
|
|
|
2019-01-29 02:40:14 +00:00
|
|
|
entity spot;
|
2019-01-19 04:50:25 +00:00
|
|
|
|
2019-01-29 02:40:14 +00:00
|
|
|
pl.classname = "player";
|
|
|
|
pl.health = self.max_health = 100;
|
|
|
|
//forceinfokey( self, "*dead", "0" );
|
|
|
|
pl.takedamage = DAMAGE_YES;
|
|
|
|
pl.solid = SOLID_SLIDEBOX;
|
|
|
|
pl.movetype = MOVETYPE_WALK;
|
|
|
|
pl.flags = FL_CLIENT;
|
|
|
|
pl.viewzoom = 1.0;
|
|
|
|
setmodel(pl, "models/player.mdl");
|
|
|
|
setsize(pl, VEC_HULL_MIN, VEC_HULL_MAX);
|
|
|
|
pl.view_ofs = VEC_PLAYER_VIEWPOS;
|
|
|
|
pl.velocity = [0,0,0];
|
|
|
|
pl.frame = 1;
|
|
|
|
pl.SendEntity = Player_SendEntity;
|
|
|
|
pl.customphysics = Empty;
|
|
|
|
pl.vPain = Player_Pain;
|
|
|
|
pl.vDeath = Player_Death;
|
|
|
|
forceinfokey(pl, "*spec", "0" );
|
|
|
|
|
|
|
|
if ( cvar( "sv_playerslots" ) == 1 ) {
|
|
|
|
Game_DecodeChangeParms();
|
2019-01-19 04:50:25 +00:00
|
|
|
if (startspot) {
|
2019-01-29 02:40:14 +00:00
|
|
|
setorigin(pl, Landmark_GetSpot());
|
2019-01-19 04:50:25 +00:00
|
|
|
} else {
|
2019-01-29 02:40:14 +00:00
|
|
|
spot = find(world, classname, "info_player_start");
|
|
|
|
setorigin(pl, spot.origin);
|
|
|
|
pl.angles = spot.angles;
|
|
|
|
pl.fixangle = TRUE;
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
2019-01-29 02:40:14 +00:00
|
|
|
} else {
|
|
|
|
spot = Spawn_SelectRandom("info_player_deathmatch");
|
|
|
|
setorigin(pl, spot.origin);
|
|
|
|
pl.angles = spot.angles;
|
|
|
|
pl.fixangle = TRUE;
|
|
|
|
|
|
|
|
pl.ammo_9mm = 68;
|
|
|
|
Weapons_AddItem(pl, WEAPON_CROWBAR);
|
|
|
|
Weapons_AddItem(pl, WEAPON_GLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SV_SendChat(entity eSender, string sMessage, entity eEnt, float fType)
|
|
|
|
{
|
|
|
|
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET );
|
|
|
|
WriteByte( MSG_MULTICAST, fType == 0 ? EV_CHAT:EV_CHAT_TEAM );
|
|
|
|
WriteByte( MSG_MULTICAST, num_for_edict( eSender ) - 1 );
|
|
|
|
WriteByte( MSG_MULTICAST, eSender.team );
|
|
|
|
WriteString( MSG_MULTICAST, sMessage );
|
|
|
|
if (eEnt) {
|
|
|
|
msg_entity = eEnt;
|
|
|
|
multicast( [0,0,0], MULTICAST_ONE );
|
|
|
|
} else {
|
|
|
|
multicast( [0,0,0], MULTICAST_ALL );
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_ParseClientCommand(string cmd)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
2019-01-29 02:40:14 +00:00
|
|
|
tokenize( cmd );
|
|
|
|
|
|
|
|
/*if ( argv( 1 ) == "timeleft" ) {
|
|
|
|
float fTimeLeft = cvar( "mp_timelimit" ) - ( time / 60 );
|
|
|
|
Vox_Singlecast( self, sprintf( "we have %s minutes remaining", Vox_TimeToString( fTimeLeft ) ) );
|
|
|
|
return;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
string chat = substring( cmd, 4, strlen( cmd ) - 4 );
|
|
|
|
|
|
|
|
// Players talk to players, spectators to spectators.
|
|
|
|
if ( argv( 0 ) == "say" ) {
|
|
|
|
localcmd( sprintf( "echo %s: %s\n", self.netname, chat ) );
|
|
|
|
SV_SendChat( self, chat, world, 0 );
|
|
|
|
return;
|
|
|
|
} else if ( argv( 0 ) == "say_team" ) {
|
|
|
|
localcmd( sprintf( "echo [TEAM %d] %s: %s\n", self.team, self.netname, chat ) );
|
|
|
|
for ( entity eFind = world; ( eFind = find( eFind, classname, "player" ) ); ) {
|
|
|
|
if ( eFind.team == self.team ) {
|
|
|
|
SV_SendChat( self, chat, eFind, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
clientcommand(self, cmd);
|
2019-01-19 04:50:25 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 02:00:14 +00:00
|
|
|
void Game_SetNewParms(void)
|
2019-01-19 04:50:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|