PlayerRankings: Add rotating code, and optimize slightly.
This commit is contained in:
parent
a5fada7a93
commit
ba69fbf29a
@ -29,7 +29,9 @@ ConVar g_hCVar_ProtectionMinimal3;
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
int g_iCrownParent = INVALID_ENT_REFERENCE;
|
||||
int g_iSkullEntity = INVALID_ENT_REFERENCE;
|
||||
int g_iSkullParent = INVALID_ENT_REFERENCE;
|
||||
int g_iDialogLevel = 100000;
|
||||
|
||||
int g_iPlayerWinner[6];
|
||||
@ -80,6 +82,7 @@ public void OnPluginStart()
|
||||
|
||||
CreateTimer(0.1, UpdateScoreboard, INVALID_HANDLE, TIMER_REPEAT);
|
||||
CreateTimer(0.1, UpdateDialog, INVALID_HANDLE, TIMER_REPEAT);
|
||||
CreateTimer(0.1, UpdateCrowns, INVALID_HANDLE, TIMER_REPEAT);
|
||||
|
||||
RegConsoleCmd("sm_togglecrown", OnToggleCrown);
|
||||
RegConsoleCmd("sm_toggleskull", OnToggleCrown);
|
||||
@ -380,6 +383,34 @@ public Action UpdateDialog(Handle timer)
|
||||
g_iDialogLevel--;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action UpdateCrowns(Handle timer)
|
||||
{
|
||||
if (g_bEngineCSGO)
|
||||
return;
|
||||
|
||||
if (IsValidEntity(g_iCrownEntity))
|
||||
{
|
||||
float fAngles[3];
|
||||
GetClientAbsAngles(g_iCrownParent, fAngles);
|
||||
|
||||
fAngles[0] += 8.0;
|
||||
fAngles[2] += 5.5;
|
||||
|
||||
TeleportEntity(g_iCrownEntity, NULL_VECTOR, fAngles, NULL_VECTOR);
|
||||
}
|
||||
|
||||
if (IsValidEntity(g_iSkullEntity))
|
||||
{
|
||||
float fAngles[3];
|
||||
GetClientAbsAngles(g_iSkullParent, fAngles);
|
||||
|
||||
TeleportEntity(g_iSkullEntity, NULL_VECTOR, fAngles, NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -589,14 +620,16 @@ public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
if (!g_bHideCrown[client])
|
||||
{
|
||||
if (g_iPlayerWinner[0] == GetSteamAccountID(client))
|
||||
int steamAccountID = GetSteamAccountID(client);
|
||||
|
||||
if (g_iPlayerWinner[0] == steamAccountID)
|
||||
{
|
||||
CreateTimer(7.0, OnClientSpawnPostCrown, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(7.0, OnClientSpawnPostCrown, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
KillCrown();
|
||||
}
|
||||
else if (g_iPlayerWinner[3] == GetSteamAccountID(client))
|
||||
else if (g_iPlayerWinner[3] == steamAccountID)
|
||||
{
|
||||
CreateTimer(7.0, OnClientSpawnPostSkull, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(7.0, OnClientSpawnPostSkull, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
KillSkull();
|
||||
}
|
||||
}
|
||||
@ -605,8 +638,12 @@ public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnClientSpawnPostCrown(Handle timer, int client)
|
||||
public Action OnClientSpawnPostCrown(Handle timer, int serial)
|
||||
{
|
||||
int client = -1;
|
||||
if((client = GetClientFromSerial(serial)) == -1)
|
||||
return;
|
||||
|
||||
if (!IsClientInGame(client) || IsFakeClient(client) || !IsPlayerAlive(client))
|
||||
return;
|
||||
|
||||
@ -617,8 +654,12 @@ public Action OnClientSpawnPostCrown(Handle timer, int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnClientSpawnPostSkull(Handle timer, int client)
|
||||
public Action OnClientSpawnPostSkull(Handle timer, int serial)
|
||||
{
|
||||
int client = -1;
|
||||
if((client = GetClientFromSerial(serial)) == -1)
|
||||
return;
|
||||
|
||||
if (!IsClientInGame(client) || IsFakeClient(client) || !IsPlayerAlive(client))
|
||||
return;
|
||||
|
||||
@ -635,10 +676,10 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
|
||||
if (!IsPlayerAlive(client))
|
||||
{
|
||||
if (g_iPlayerWinner[0] == GetSteamAccountID(client))
|
||||
if (g_iCrownParent == client)
|
||||
KillCrown();
|
||||
|
||||
if (g_iPlayerWinner[3] == GetSteamAccountID(client))
|
||||
if (g_iSkullParent == client)
|
||||
KillSkull();
|
||||
}
|
||||
}
|
||||
@ -648,17 +689,17 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SpawnCrown(int client)
|
||||
{
|
||||
int iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
if ((iCrownEntity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
if ((entity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
return;
|
||||
|
||||
SetEntityModel(iCrownEntity, "models/unloze/crown_v2.mdl");
|
||||
SetEntityModel(entity, "models/unloze/crown_v2.mdl");
|
||||
|
||||
DispatchKeyValue(iCrownEntity, "solid", "0");
|
||||
DispatchKeyValue(iCrownEntity, "modelscale", "1.5");
|
||||
DispatchKeyValue(iCrownEntity, "disableshadows", "1");
|
||||
DispatchKeyValue(iCrownEntity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(iCrownEntity, "disablebonefollowers", "1");
|
||||
DispatchKeyValue(entity, "solid", "0");
|
||||
DispatchKeyValue(entity, "modelscale", "1.5");
|
||||
DispatchKeyValue(entity, "disableshadows", "1");
|
||||
DispatchKeyValue(entity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(entity, "disablebonefollowers", "1");
|
||||
|
||||
float fVector[3];
|
||||
float fAngles[3];
|
||||
@ -666,10 +707,10 @@ void SpawnCrown(int client)
|
||||
GetClientAbsAngles(client, fAngles);
|
||||
|
||||
fVector[2] += 80.0;
|
||||
fAngles[0] = 8.0;
|
||||
fAngles[2] = 5.5;
|
||||
fAngles[0] += 8.0;
|
||||
fAngles[2] += 5.5;
|
||||
|
||||
TeleportEntity(iCrownEntity, fVector, fAngles, NULL_VECTOR);
|
||||
TeleportEntity(entity, fVector, fAngles, NULL_VECTOR);
|
||||
|
||||
float fDirection[3];
|
||||
fDirection[0] = 0.0;
|
||||
@ -680,9 +721,10 @@ void SpawnCrown(int client)
|
||||
TE_SendToAll();
|
||||
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(iCrownEntity, "SetParent", client);
|
||||
AcceptEntityInput(entity, "SetParent", client);
|
||||
|
||||
g_iCrownEntity = iCrownEntity;
|
||||
g_iCrownEntity = entity;
|
||||
g_iCrownParent = client;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -690,17 +732,17 @@ void SpawnCrown(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SpawnSkull(int client)
|
||||
{
|
||||
int iSkullEntity = INVALID_ENT_REFERENCE;
|
||||
if ((iSkullEntity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
if ((entity = CreateEntityByName("prop_dynamic")) == INVALID_ENT_REFERENCE)
|
||||
return;
|
||||
|
||||
SetEntityModel(iSkullEntity, "models/unloze/skull.mdl");
|
||||
SetEntityModel(entity, "models/unloze/skull.mdl");
|
||||
|
||||
DispatchKeyValue(iSkullEntity, "solid", "0");
|
||||
DispatchKeyValue(iSkullEntity, "modelscale", "1.5");
|
||||
DispatchKeyValue(iSkullEntity, "disableshadows", "1");
|
||||
DispatchKeyValue(iSkullEntity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(iSkullEntity, "disablebonefollowers", "1");
|
||||
DispatchKeyValue(entity, "solid", "0");
|
||||
DispatchKeyValue(entity, "modelscale", "1.5");
|
||||
DispatchKeyValue(entity, "disableshadows", "1");
|
||||
DispatchKeyValue(entity, "disablereceiveshadows", "1");
|
||||
DispatchKeyValue(entity, "disablebonefollowers", "1");
|
||||
|
||||
float fVector[3];
|
||||
float fAngles[3];
|
||||
@ -709,7 +751,7 @@ void SpawnSkull(int client)
|
||||
|
||||
fVector[2] -= 30.0;
|
||||
|
||||
TeleportEntity(iSkullEntity, fVector, fAngles, NULL_VECTOR);
|
||||
TeleportEntity(entity, fVector, fAngles, NULL_VECTOR);
|
||||
|
||||
float fDirection[3];
|
||||
fDirection[0] = 0.0;
|
||||
@ -720,9 +762,10 @@ void SpawnSkull(int client)
|
||||
TE_SendToAll();
|
||||
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(iSkullEntity, "SetParent", client);
|
||||
AcceptEntityInput(entity, "SetParent", client);
|
||||
|
||||
g_iSkullEntity = iSkullEntity;
|
||||
g_iSkullEntity = entity;
|
||||
g_iSkullParent = client;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -731,7 +774,10 @@ void SpawnSkull(int client)
|
||||
void KillCrown()
|
||||
{
|
||||
if ((IsValidEntity(g_iCrownEntity) && AcceptEntityInput(g_iCrownEntity, "Kill")) || g_iCrownEntity != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
g_iCrownEntity = INVALID_ENT_REFERENCE;
|
||||
g_iCrownParent = INVALID_ENT_REFERENCE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -740,7 +786,10 @@ void KillCrown()
|
||||
void KillSkull()
|
||||
{
|
||||
if ((IsValidEntity(g_iSkullEntity) && AcceptEntityInput(g_iSkullEntity, "Kill")) || g_iSkullEntity != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
g_iSkullEntity = INVALID_ENT_REFERENCE;
|
||||
g_iSkullParent = INVALID_ENT_REFERENCE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -750,9 +799,11 @@ public Action ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:re
|
||||
{
|
||||
if (g_hCVar_Protection.BoolValue && motherInfect && !g_bProtection[client])
|
||||
{
|
||||
if ((g_iPlayerWinner[0] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal1.IntValue) ||
|
||||
(g_iPlayerWinner[1] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal2.IntValue) ||
|
||||
(g_iPlayerWinner[2] == GetSteamAccountID(client) && GetClientCount() >= g_hCVar_ProtectionMinimal3.IntValue))
|
||||
int steamAccountID = GetSteamAccountID(client);
|
||||
|
||||
if ((g_iPlayerWinner[0] == steamAccountID && GetClientCount() >= g_hCVar_ProtectionMinimal1.IntValue) ||
|
||||
(g_iPlayerWinner[1] == steamAccountID && GetClientCount() >= g_hCVar_ProtectionMinimal2.IntValue) ||
|
||||
(g_iPlayerWinner[2] == steamAccountID && GetClientCount() >= g_hCVar_ProtectionMinimal3.IntValue))
|
||||
{
|
||||
PrintToMessageHUD(client, 60, Float:{-1.0, 0.3}, {255, 255, 255, 255}, {255, 255, 255, 255}, 0, 0.1, 0.1, 5.0, 0.0, "%t", "Protected");
|
||||
CPrintToChat(client, "{cyan}%t {white}%t", "Chat Prefix", "Protected");
|
||||
|
Loading…
Reference in New Issue
Block a user