mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-02-11 14:34:22 +00:00
Fix mp3 player.
This commit is contained in:
parent
23e2d00ae9
commit
d600d214ce
@ -100,6 +100,23 @@ void __CmdFunc_ToggleServerBrowser( void )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __MsgFunc_PlayMP3( const char *pszName, int iSize, void *pbuf )
|
||||||
|
{
|
||||||
|
char cmd[64];
|
||||||
|
|
||||||
|
BEGIN_READ( pbuf, iSize );
|
||||||
|
|
||||||
|
sprintf( cmd, "sound/mp3/%s", READ_STRING() );
|
||||||
|
gEngfuncs.pfnPrimeMusicStream( cmd, 1 );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __CmdFunc_StopMP3( void )
|
||||||
|
{
|
||||||
|
gEngfuncs.pfnPrimeMusicStream( 0, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
// TFFree Command Menu Message Handlers
|
// TFFree Command Menu Message Handlers
|
||||||
int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf )
|
int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf )
|
||||||
{
|
{
|
||||||
@ -183,6 +200,9 @@ void CHud::Init( void )
|
|||||||
// VGUI Menus
|
// VGUI Menus
|
||||||
HOOK_MESSAGE( VGUIMenu );
|
HOOK_MESSAGE( VGUIMenu );
|
||||||
|
|
||||||
|
HOOK_MESSAGE( PlayMP3 );
|
||||||
|
HOOK_COMMAND( "stopmp3", StopMP3 );
|
||||||
|
|
||||||
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
|
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
|
||||||
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round
|
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round
|
||||||
hud_textmode = CVAR_CREATE ( "hud_textmode", "0", FCVAR_ARCHIVE );
|
hud_textmode = CVAR_CREATE ( "hud_textmode", "0", FCVAR_ARCHIVE );
|
||||||
|
@ -23,16 +23,13 @@
|
|||||||
class CTriggerCommand : public CPointEntity
|
class CTriggerCommand : public CPointEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Spawn(void);
|
void Spawn();
|
||||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||||
|
|
||||||
private:
|
|
||||||
void PlayMP3(CBaseEntity* pClient, const char* song);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_ENTITY_TO_CLASS(trigger_command, CTriggerCommand);
|
LINK_ENTITY_TO_CLASS( trigger_command, CTriggerCommand )
|
||||||
|
|
||||||
void CTriggerCommand::Spawn(void)
|
void CTriggerCommand::Spawn()
|
||||||
{
|
{
|
||||||
pev->solid = SOLID_NOT;
|
pev->solid = SOLID_NOT;
|
||||||
pev->movetype = MOVETYPE_NONE;
|
pev->movetype = MOVETYPE_NONE;
|
||||||
@ -40,61 +37,18 @@ void CTriggerCommand::Spawn(void)
|
|||||||
pev->frame = 0;
|
pev->frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTriggerCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
void CTriggerCommand::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||||
{
|
{
|
||||||
if (!pActivator || !pActivator->IsNetClient())
|
char cmd[64];
|
||||||
|
|
||||||
|
if( !pActivator || !pActivator->IsPlayer() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char* command = STRING(pev->netname);
|
if( !pev->netname )
|
||||||
|
|
||||||
if (!command || !*command)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// ALERT(at_console, "%s with command \"%s\"\n", STRING(pev->classname), command);
|
sprintf( cmd, "%s\n", STRING( pev->netname ) );
|
||||||
|
CLIENT_COMMAND( ENT( pActivator->pev ), cmd );
|
||||||
|
|
||||||
char* str = NULL;
|
UTIL_Remove( this );
|
||||||
|
|
||||||
if ((str = (char*)strstr(command, "playmp3")) != NULL)
|
|
||||||
{
|
|
||||||
int pchlen = 0;
|
|
||||||
int extlen = 3; // "mp3" excluding NULL terminator.
|
|
||||||
int ideallen = 0;
|
|
||||||
|
|
||||||
char* pch = NULL, *lastpch = NULL;
|
|
||||||
char* song = NULL;
|
|
||||||
|
|
||||||
pch = strtok(str, " .");
|
|
||||||
|
|
||||||
while (pch)
|
|
||||||
{
|
|
||||||
pchlen = strlen(pch);
|
|
||||||
ideallen = (pchlen <= extlen) ? pchlen : extlen;
|
|
||||||
|
|
||||||
if (strncmp(pch, "mp3", sizeof(char) * ideallen) == 0)
|
|
||||||
{
|
|
||||||
pch = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastpch = pch;
|
|
||||||
pch = strtok(NULL, " .");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
song = lastpch;
|
|
||||||
|
|
||||||
PlayMP3(pActivator, song);
|
|
||||||
}
|
|
||||||
|
|
||||||
UTIL_Remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTriggerCommand::PlayMP3(CBaseEntity* pClient, const char* song)
|
|
||||||
{
|
|
||||||
ASSERT(pClient != NULL);
|
|
||||||
|
|
||||||
char cmd[128];
|
|
||||||
sprintf(cmd, "play sound/mp3/%s.mp3\n", song);
|
|
||||||
|
|
||||||
CLIENT_COMMAND(ENT(pClient->pev),cmd);
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ extern void CopyToBodyQue( entvars_t* pev );
|
|||||||
extern int giPrecacheGrunt;
|
extern int giPrecacheGrunt;
|
||||||
extern int gmsgSayText;
|
extern int gmsgSayText;
|
||||||
extern int gmsgBhopcap;
|
extern int gmsgBhopcap;
|
||||||
|
extern int gmsgPlayMP3;
|
||||||
|
|
||||||
extern cvar_t allow_spectators;
|
extern cvar_t allow_spectators;
|
||||||
|
|
||||||
@ -487,6 +488,12 @@ void ClientCommand( edict_t *pEntity )
|
|||||||
{
|
{
|
||||||
GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate();
|
GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate();
|
||||||
}
|
}
|
||||||
|
else if( FStrEq(pcmd, "playmp3" ) )
|
||||||
|
{
|
||||||
|
MESSAGE_BEGIN( MSG_ONE, gmsgPlayMP3, NULL, ENT( pev ) );
|
||||||
|
WRITE_STRING( (char *)CMD_ARGV( 1 ) );
|
||||||
|
MESSAGE_END();
|
||||||
|
}
|
||||||
else if( FStrEq(pcmd, "give" ) )
|
else if( FStrEq(pcmd, "give" ) )
|
||||||
{
|
{
|
||||||
if( g_flWeaponCheat != 0.0 )
|
if( g_flWeaponCheat != 0.0 )
|
||||||
|
@ -190,6 +190,7 @@ int gmsgStatusText = 0;
|
|||||||
int gmsgStatusValue = 0;
|
int gmsgStatusValue = 0;
|
||||||
|
|
||||||
int gmsgScope = 0;
|
int gmsgScope = 0;
|
||||||
|
int gmsgPlayMP3 = 0;
|
||||||
|
|
||||||
void LinkUserMessages( void )
|
void LinkUserMessages( void )
|
||||||
{
|
{
|
||||||
@ -233,12 +234,12 @@ void LinkUserMessages( void )
|
|||||||
gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) );
|
gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) );
|
||||||
gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 );
|
gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 );
|
||||||
gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 );
|
gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 );
|
||||||
|
gmsgPlayMP3 = REG_USER_MSG( "PlayMP3", -1 );
|
||||||
|
gmsgScope = REG_USER_MSG( "Scope", 1 );
|
||||||
gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 );
|
gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 );
|
||||||
|
|
||||||
gmsgStatusText = REG_USER_MSG( "StatusText", -1 );
|
gmsgStatusText = REG_USER_MSG( "StatusText", -1 );
|
||||||
gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 );
|
gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 );
|
||||||
|
|
||||||
gmsgScope = REG_USER_MSG( "Scope", 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LINK_ENTITY_TO_CLASS( player, CBasePlayer )
|
LINK_ENTITY_TO_CLASS( player, CBasePlayer )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user