mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
added chat command /time to show or hide time until next spawn
added chat command /broadcast to show or hide broadcast until next spawn added rcon shot,shotgun_me,grenade,grenade_me,laser,laser_me Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
fd7c0c39ac
commit
b0bf68c3d3
|
@ -73,6 +73,8 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
|
|||
m_RaceState = RACE_NONE;
|
||||
m_PrevPos = Pos;
|
||||
m_Core.Reset();
|
||||
m_BroadTime = true;
|
||||
m_BroadCast = true;
|
||||
m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision());
|
||||
m_Core.m_Pos = m_Pos;
|
||||
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = &m_Core;
|
||||
|
@ -622,8 +624,13 @@ void CCharacter::Tick()
|
|||
}
|
||||
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
|
||||
} else {
|
||||
str_format(aBuftime, sizeof(aBuftime), "Current Time: %d min %d sec", IntTime/60, IntTime%60);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_BroadTime)
|
||||
str_format(aBuftime, sizeof(aBuftime), "%dm %ds", IntTime/60, IntTime%60);
|
||||
else
|
||||
str_format(aBuftime, sizeof(aBuftime), "");
|
||||
|
||||
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
|
||||
{
|
||||
|
@ -636,14 +643,17 @@ void CCharacter::Tick()
|
|||
}
|
||||
}
|
||||
|
||||
if( g_Config.m_SvBroadcast[0] != 0) {
|
||||
if( g_Config.m_SvBroadcast[0] != 0 && m_BroadCast)
|
||||
{
|
||||
char aTmp[128];
|
||||
str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast);
|
||||
strcat(aBuftime, aTmp);
|
||||
}
|
||||
GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if( g_Config.m_SvBroadcast[0] != 0) {
|
||||
char aTmp[128];
|
||||
str_format(aTmp, sizeof(aTmp), "%s\n", g_Config.m_SvBroadcast);
|
||||
|
|
|
@ -170,6 +170,9 @@ public:
|
|||
int m_CpActive;
|
||||
float m_CpCurrent[25];
|
||||
|
||||
int m_BroadTime;
|
||||
int m_BroadCast;
|
||||
|
||||
|
||||
|
||||
// info for dead reckoning
|
||||
|
|
|
@ -737,6 +737,28 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
else
|
||||
Score()->ShowRank(p->GetCID(), Server()->ClientName(ClientId));
|
||||
}
|
||||
else if (!str_comp_nocase(pMsg->m_pMessage, "/time")&&g_Config.m_SvEmotionalTees)
|
||||
{
|
||||
CCharacter* pChr = p->GetCharacter();
|
||||
if (pChr)
|
||||
{
|
||||
if(pChr->m_BroadTime)
|
||||
pChr->m_BroadTime=false;
|
||||
else
|
||||
pChr->m_BroadTime=true;
|
||||
}
|
||||
}
|
||||
else if (!str_comp_nocase(pMsg->m_pMessage, "/broadcast")&&g_Config.m_SvEmotionalTees)
|
||||
{
|
||||
CCharacter* pChr = p->GetCharacter();
|
||||
if (pChr)
|
||||
{
|
||||
if(pChr->m_BroadCast)
|
||||
pChr->m_BroadCast=false;
|
||||
else
|
||||
pChr->m_BroadCast=true;
|
||||
}
|
||||
}
|
||||
else if (!str_comp_nocase(pMsg->m_pMessage, "/emotepain")&&g_Config.m_SvEmotionalTees)
|
||||
{
|
||||
CCharacter* pChr = p->GetCharacter();
|
||||
|
@ -1113,16 +1135,16 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
case EMOTICON_8:
|
||||
pChr->m_EmoteType = EMOTE_SURPRISE;
|
||||
break;
|
||||
case EMOTICON_13:
|
||||
case EMOTICON_1:
|
||||
case EMOTICON_4:
|
||||
case EMOTICON_7:
|
||||
case EMOTICON_13:
|
||||
pChr->m_EmoteType = EMOTE_BLINK;
|
||||
break;
|
||||
case EMOTICON_3:
|
||||
case EMOTICON_6:
|
||||
pChr->m_EmoteType = EMOTE_HAPPY;
|
||||
break;
|
||||
case EMOTICON_1:
|
||||
case EMOTICON_4:
|
||||
case EMOTICON_9:
|
||||
case EMOTICON_15:
|
||||
pChr->m_EmoteType = EMOTE_PAIN;
|
||||
|
@ -1533,6 +1555,96 @@ void CGameContext::ConUnSuperMe(IConsole::IResult *pResult, void *pUserData, int
|
|||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConShotgun(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
|
||||
{
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_SHOTGUN,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConShotgunMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_SHOTGUN,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConGrenade(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
|
||||
{
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_GRENADE,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConGrenadeMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_GRENADE,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConLaser(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
|
||||
{
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_RIFLE,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConLaserMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->CheatsAvailable(cid)) return;
|
||||
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
||||
if(chr)
|
||||
{
|
||||
chr->GiveWeapon(WEAPON_RIFLE,-1);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
@ -1736,6 +1848,12 @@ void CGameContext::OnConsoleInit()
|
|||
|
||||
Console()->Register("tele", "ii", CFGFLAG_SERVER, ConTeleport, this, "Teleports Player i1 to i2",2);
|
||||
|
||||
Console()->Register("shotgun", "i", CFGFLAG_SERVER, ConShotgun, this, "Give shotgun weapon to player i",2);
|
||||
Console()->Register("shotgun_me", "", CFGFLAG_SERVER, ConShotgunMe, this, "Give shotgun weapon to self",1);
|
||||
Console()->Register("grenade", "i", CFGFLAG_SERVER, ConGrenade, this, "Give grenade weapon to player i",2);
|
||||
Console()->Register("grenade_me", "", CFGFLAG_SERVER, ConGrenadeMe, this, "Give grenade weapon to self",1);
|
||||
Console()->Register("laser", "i", CFGFLAG_SERVER, ConLaser, this, "Give rifle weapon to player i",2);
|
||||
Console()->Register("laser_me", "", CFGFLAG_SERVER, ConLaserMe, this, "Give rifle weapon to self",1);
|
||||
Console()->Register("weapons", "i", CFGFLAG_SERVER, ConWeapons, this, "Give all weapons to player i",2);
|
||||
Console()->Register("weapons_me", "", CFGFLAG_SERVER, ConWeaponsMe, this, "Give all weapons to self",1);
|
||||
|
||||
|
|
|
@ -58,9 +58,15 @@ class CGameContext : public IGameServer
|
|||
static void ConUnSuper(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConSuper(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConSuperMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
|
||||
static void ConWeaponsMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
|
||||
static void ConShotgun(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConShotgunMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConGrenade(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConGrenadeMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConRifle(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConRifleMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConWeapons(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
static void ConWeaponsMe(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
|
||||
static void ConTeleport(IConsole::IResult *pResult, void *pUserData, int cid);
|
||||
|
||||
|
|
Loading…
Reference in a new issue