mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 21:43:22 +00:00
guesswho fixes
This commit is contained in:
parent
b62f9fd542
commit
0b89cde2d5
5 changed files with 195 additions and 83 deletions
|
@ -270,7 +270,7 @@ public Action Command_GuessWho(int client, int args) {
|
|||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) <= 0
|
||||
|| target_list[0] == 0){
|
||||
|| target_list[0] <= 0){
|
||||
/* This function replies to the admin with a failure message */
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
|
@ -293,6 +293,8 @@ public Action Command_GuessWho(int client, int args) {
|
|||
ReplyToCommand(client, "Has Spawnpoint: no (possibly map spawn %f %f %f)", mapConfig.spawnpoint[0], mapConfig.spawnpoint[1], mapConfig.spawnpoint[2]);
|
||||
ReplyToCommand(client, "Map Time: %d", mapConfig.mapTime);
|
||||
ReplyToCommand(client, "Flow Bounds: (%f, %f)", movePoints.MinFlow, movePoints.MaxFlow);
|
||||
} else if(StrEqual(subcmd, "test")) {
|
||||
|
||||
} else {
|
||||
ReplyToCommand(client, "Unknown option. Leave blank for help");
|
||||
}
|
||||
|
@ -382,7 +384,7 @@ public Action Command_Join(int client, int args) {
|
|||
ChangeClientTeam(client, 2);
|
||||
L4D_RespawnPlayer(client);
|
||||
TeleportEntity(client, tpLoc, NULL_VECTOR, NULL_VECTOR);
|
||||
CheatCommand(client, "give", "gnome");
|
||||
Game.SetupPlayer(client);
|
||||
if(!ArePlayersJoining()) {
|
||||
InitGamemode();
|
||||
}
|
||||
|
|
|
@ -51,24 +51,25 @@ methodmap GuessWhoGame < BaseGame {
|
|||
return currentSeeker;
|
||||
}
|
||||
public set(int client) {
|
||||
int existingSeeker = currentSeeker;
|
||||
currentSeeker = client;
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && i != client) {
|
||||
ClearInventory(i);
|
||||
CheatCommand(i, "give", "gnome");
|
||||
if(IsClientConnected(i) && IsClientInGame(i)) {
|
||||
this.SetupInventory(i);
|
||||
}
|
||||
}
|
||||
// Reset things incase set mid-start
|
||||
if(currentSeeker > 0) {
|
||||
SetEntPropFloat(currentSeeker, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SetPlayerBlind(currentSeeker, 0);
|
||||
L4D2_RemoveEntityGlow(currentSeeker);
|
||||
if(existingSeeker > 0) {
|
||||
SetEntPropFloat(existingSeeker, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SetPlayerBlind(existingSeeker, 0);
|
||||
L4D2_RemoveEntityGlow(existingSeeker);
|
||||
}
|
||||
|
||||
L4D2_SetEntityGlow(client, L4D2Glow_Constant, 0, 10, SEEKER_GLOW_COLOR, false);
|
||||
|
||||
hasBeenSeeker[client] = true;
|
||||
Format(buffer, sizeof(buffer), "g_ModeScript.MutationState.CurrentSeeker = GetPlayerFromUserID(%d);", GetClientUserId(client));
|
||||
CheatCommand(client, "give", "fireaxe");
|
||||
L4D2_ExecVScriptCode(buffer);
|
||||
currentSeeker = client;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,27 +153,49 @@ methodmap GuessWhoGame < BaseGame {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.CleanupGnomes(true);
|
||||
CreateTimer(5.0, Timer_ResetAll);
|
||||
}
|
||||
|
||||
public void Cleanup(bool noClearInv = false) {
|
||||
DeleteCustomEnts();
|
||||
PeekCam.Destroy();
|
||||
if(recordTimer != null) {
|
||||
delete recordTimer;
|
||||
}
|
||||
if(recordTimer != null) delete recordTimer;
|
||||
if(doorToggleTimer != null) delete doorToggleTimer;
|
||||
if(waitForStartTimer != null && IsValidHandle(waitForStartTimer)) delete waitForStartTimer;
|
||||
if(waitTimer != null) delete waitTimer;
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i)) {
|
||||
if(!noClearInv && isEnabled)
|
||||
ClearInventory(i);
|
||||
SDKUnhook(i, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
|
||||
SDKUnhook(i, SDKHook_WeaponDrop, OnWeaponDrop);
|
||||
Game.UnsetupPlayer(i);
|
||||
}
|
||||
if(moveTimers[i] != null) {
|
||||
delete moveTimers[i];
|
||||
}
|
||||
}
|
||||
// Annoying
|
||||
this.CleanupGnomes();
|
||||
}
|
||||
|
||||
public void CleanupGnomes(bool orphansOnly = false) {
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
char model[32];
|
||||
while ((entity = FindEntityByClassname(entity, "prop_physics")) != INVALID_ENT_REFERENCE) {
|
||||
int parent = GetEntPropEnt(entity, Prop_Data, "m_hParent");
|
||||
if(orphansOnly && parent >= 0) continue;
|
||||
GetEntPropString(entity, Prop_Data, "m_ModelName", model, sizeof(model));
|
||||
if(StrEqual(model, "models/props_junk/gnome.mdl")) {
|
||||
RemoveEntity(entity);
|
||||
}
|
||||
}
|
||||
entity = INVALID_ENT_REFERENCE;
|
||||
while ((entity = FindEntityByClassname(entity, "weapon_gnome")) != INVALID_ENT_REFERENCE) {
|
||||
int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
|
||||
if(orphansOnly && owner >= 0) continue;
|
||||
GetEntPropString(entity, Prop_Data, "m_ModelName", model, sizeof(model));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,6 +279,28 @@ methodmap GuessWhoGame < BaseGame {
|
|||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupInventory(int client) {
|
||||
ClearInventory(client);
|
||||
ignoreDrop[client] = true;
|
||||
if(client == this.Seeker) {
|
||||
CheatCommand(client, "give", "fireaxe");
|
||||
} else {
|
||||
GivePlayerItem(client, "weapon_gnome");
|
||||
}
|
||||
ignoreDrop[client] = false;
|
||||
}
|
||||
|
||||
public void SetupPlayer(int client) {
|
||||
this.SetupInventory(client);
|
||||
SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
|
||||
SDKHook(client, SDKHook_WeaponEquip, OnWeaponEquip);
|
||||
}
|
||||
|
||||
public void UnsetupPlayer(int client) {
|
||||
SDKUnhook(client, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
|
||||
SDKUnhook(client, SDKHook_WeaponEquip, OnWeaponEquip);
|
||||
}
|
||||
}
|
||||
|
||||
stock bool ArePlayersJoining() {
|
||||
|
|
|
@ -38,14 +38,25 @@ Action Timer_WaitForPlayers(Handle h) {
|
|||
|
||||
Action Timer_CheckHiders(Handle h) {
|
||||
static float pos[3];
|
||||
static char classname[16];
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i)) {
|
||||
GetClientAbsOrigin(i, pos);
|
||||
distQueue[i].AddPos(pos);
|
||||
distQueue[i].Check(i);
|
||||
|
||||
int activeWeapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
|
||||
if(IsValidEntity(activeWeapon)) {
|
||||
GetEntityClassname(activeWeapon, classname, sizeof(classname));
|
||||
if(i == currentSeeker) {
|
||||
if(StrEqual(classname, "weapon_melee")) continue;
|
||||
Game.SetupInventory(i);
|
||||
} else if(StrEqual(classname, "weapon_gnome")) continue;
|
||||
}
|
||||
Game.SetupInventory(i);
|
||||
}
|
||||
}
|
||||
|
||||
Game.CleanupGnomes(true);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue