Fix issues in a few plugins.
This commit is contained in:
parent
c66709f27c
commit
062a08b67e
@ -99,7 +99,7 @@ public Action OnCheatCommand(int client, const char[] command, int argc)
|
|||||||
if(IsClientAuthorized(client) && CheckCommandAccess(client, "", ADMFLAG_CHEATS))
|
if(IsClientAuthorized(client) && CheckCommandAccess(client, "", ADMFLAG_CHEATS))
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
PrintToConsole(client, "denied :^)");
|
//PrintToConsole(client, "denied :^)");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
if(IsClientAuthorized(client) && CheckCommandAccess(client, "", ADMFLAG_CHEATS))
|
if(IsClientAuthorized(client) && CheckCommandAccess(client, "", ADMFLAG_CHEATS))
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
PrintToConsole(client, "denied :^)");
|
//PrintToConsole(client, "denied :^)");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
AddCommandListener(Command_Say, "say");
|
AddCommandListener(Command_Say, "say");
|
||||||
AddCommandListener(Command_Say, "say_team");
|
AddCommandListener(Command_Say, "say_team");
|
||||||
HookEvent("player_team", Event_PlayerTeamPost, EventHookMode_PostNoCopy);
|
HookEvent("player_team", Event_PlayerTeamPost, EventHookMode_Post);
|
||||||
HookEvent("player_spawn", Event_PlayerSpawnPost, EventHookMode_PostNoCopy);
|
HookEvent("player_spawn", Event_PlayerSpawnPost, EventHookMode_Post);
|
||||||
HookEvent("player_death", Event_PlayerDeathPost, EventHookMode_PostNoCopy);
|
HookEvent("player_death", Event_PlayerDeathPost, EventHookMode_Post);
|
||||||
HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
|
HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
|
||||||
|
|
||||||
HookEntityOutput("trigger_teleport", "OnEndTouch", Teleport_OnEndTouch);
|
HookEntityOutput("trigger_teleport", "OnEndTouch", Teleport_OnEndTouch);
|
||||||
|
@ -71,11 +71,14 @@ public Action Command_ForceInputPlayer(int client, int args)
|
|||||||
|
|
||||||
for(int i = 0; i < TargetCount; i++)
|
for(int i = 0; i < TargetCount; i++)
|
||||||
{
|
{
|
||||||
if (sArguments[2][0])
|
if(!IsValidEntity(aTargetList[i]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(sArguments[2][0])
|
||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(aTargetList[i], sArguments[1], aTargetList[i], aTargetList[i]);
|
AcceptEntityInput(aTargetList[i], sArguments[1], aTargetList[i], aTargetList[i]);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -103,7 +106,7 @@ public Action Command_ForceInput(int client, int args)
|
|||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(client, sArguments[1], client, client);
|
AcceptEntityInput(client, sArguments[1], client, client);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input successful.");
|
||||||
}
|
}
|
||||||
else if(StrEqual(sArguments[0], "!target"))
|
else if(StrEqual(sArguments[0], "!target"))
|
||||||
{
|
{
|
||||||
@ -125,7 +128,7 @@ public Action Command_ForceInput(int client, int args)
|
|||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(entity, sArguments[1], client, client);
|
AcceptEntityInput(entity, sArguments[1], client, client);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input successful.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -135,19 +138,19 @@ public Action Command_ForceInput(int client, int args)
|
|||||||
int entity = INVALID_ENT_REFERENCE;
|
int entity = INVALID_ENT_REFERENCE;
|
||||||
while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
|
while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
|
||||||
{
|
{
|
||||||
char sClassname[64];
|
static char sClassname[64];
|
||||||
char sTargetname[64];
|
static char sTargetname[64];
|
||||||
GetEntPropString(entity, Prop_Data, "m_iClassname", sClassname, sizeof(sClassname));
|
GetEntPropString(entity, Prop_Data, "m_iClassname", sClassname, sizeof(sClassname));
|
||||||
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
||||||
|
|
||||||
if(strncmp(sClassname, sArguments[0], Wildcard, false) == 0
|
if(strncmp(sClassname, sArguments[0], Wildcard, false) == 0
|
||||||
|| strncmp(sTargetname, sArguments[0], Wildcard, false) == 0)
|
|| strncmp(sTargetname, sArguments[0], Wildcard, false) == 0)
|
||||||
{
|
{
|
||||||
if (sArguments[2][0])
|
if(sArguments[2][0])
|
||||||
SetVariantString(sArguments[2]);
|
SetVariantString(sArguments[2]);
|
||||||
|
|
||||||
AcceptEntityInput(entity, sArguments[1], client, client);
|
AcceptEntityInput(entity, sArguments[1], client, client);
|
||||||
ReplyToCommand(client, "[SM] Input succesfull.");
|
ReplyToCommand(client, "[SM] Input successful.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
RegAdminCmd("sm_rainbow", Command_Rainbow, ADMFLAG_CUSTOM1, "Enable rainbow glowcolors. sm_rainbow [frequency]");
|
RegAdminCmd("sm_rainbow", Command_Rainbow, ADMFLAG_CUSTOM1, "Enable rainbow glowcolors. sm_rainbow [frequency]");
|
||||||
|
|
||||||
HookEvent("player_spawn", Event_ApplyGlowcolor, EventHookMode_PostNoCopy);
|
HookEvent("player_spawn", Event_ApplyGlowcolor, EventHookMode_Post);
|
||||||
HookEvent("player_team", Event_ApplyGlowcolor, EventHookMode_PostNoCopy);
|
HookEvent("player_team", Event_ApplyGlowcolor, EventHookMode_Post);
|
||||||
|
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ public void OnPlayerRadio(DataPack pack)
|
|||||||
}
|
}
|
||||||
CloseHandle(pack);
|
CloseHandle(pack);
|
||||||
|
|
||||||
Handle RadioText = StartMessage("RadioText", g_MsgPlayers, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
|
Handle RadioText = StartMessage("RadioText", g_MsgPlayers, playersNum, USERMSG_RELIABLE);
|
||||||
if(g_bIsProtoBuf)
|
if(g_bIsProtoBuf)
|
||||||
{
|
{
|
||||||
PbSetInt(RadioText, "msg_dst", g_MsgDest);
|
PbSetInt(RadioText, "msg_dst", g_MsgDest);
|
||||||
@ -1021,7 +1021,7 @@ public void OnPlayerRadio(DataPack pack)
|
|||||||
}
|
}
|
||||||
EndMessage();
|
EndMessage();
|
||||||
|
|
||||||
Handle SendAudio = StartMessage("SendAudio", g_MsgPlayers, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
|
Handle SendAudio = StartMessage("SendAudio", g_MsgPlayers, playersNum, USERMSG_RELIABLE);
|
||||||
if(g_bIsProtoBuf)
|
if(g_bIsProtoBuf)
|
||||||
PbSetString(SendAudio, "radio_sound", g_MsgRadioSound);
|
PbSetString(SendAudio, "radio_sound", g_MsgRadioSound);
|
||||||
else
|
else
|
||||||
|
@ -24,7 +24,7 @@ public Plugin myinfo =
|
|||||||
name = "WeaponCleaner",
|
name = "WeaponCleaner",
|
||||||
author = "BotoX",
|
author = "BotoX",
|
||||||
description = "Clean unneeded weapons",
|
description = "Clean unneeded weapons",
|
||||||
version = "2.1",
|
version = "2.2",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,12 +65,12 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Kill it
|
// Kill it
|
||||||
AcceptEntityInput(G_WeaponArray[0][0], "Kill");
|
if(KillWeapon(G_WeaponArray[i][0]))
|
||||||
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
|
{
|
||||||
|
// Move index backwards (since the list was modified by removing it)
|
||||||
// Move index backwards (since the list was modified by removing it)
|
i--;
|
||||||
i--;
|
d--;
|
||||||
d--;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_MaxWeapons = StringToInt(newValue);
|
g_MaxWeapons = StringToInt(newValue);
|
||||||
@ -129,7 +129,7 @@ public void OnEntityCreated(int entity, const char[] classname)
|
|||||||
|
|
||||||
public void OnEntityDestroyed(int entity)
|
public void OnEntityDestroyed(int entity)
|
||||||
{
|
{
|
||||||
RemoveWeapon(entity);
|
RemoveWeapon(EntIndexToEntRef(EntRefToEntIndex(entity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWeaponSpawned(int entity)
|
public void OnWeaponSpawned(int entity)
|
||||||
@ -157,7 +157,7 @@ public Action OnWeaponEquip(int client, int entity)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Weapon should not be cleaned anymore
|
// Weapon should not be cleaned anymore
|
||||||
RemoveWeapon(entity);
|
RemoveWeapon(EntIndexToEntRef(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action OnWeaponDrop(int client, int entity)
|
public Action OnWeaponDrop(int client, int entity)
|
||||||
@ -184,6 +184,8 @@ public Action OnWeaponDrop(int client, int entity)
|
|||||||
|
|
||||||
bool InsertWeapon(int entity)
|
bool InsertWeapon(int entity)
|
||||||
{
|
{
|
||||||
|
int entref = EntIndexToEntRef(entity);
|
||||||
|
|
||||||
// Try to find a free slot
|
// Try to find a free slot
|
||||||
for(int i = 0; i < g_MaxWeapons; i++)
|
for(int i = 0; i < g_MaxWeapons; i++)
|
||||||
{
|
{
|
||||||
@ -191,28 +193,27 @@ bool InsertWeapon(int entity)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Found a free slot, add it here
|
// Found a free slot, add it here
|
||||||
G_WeaponArray[i][0] = entity;
|
G_WeaponArray[i][0] = entref;
|
||||||
G_WeaponArray[i][1] = GetTime();
|
G_WeaponArray[i][1] = GetTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No free slot found
|
// No free slot found
|
||||||
// Kill the first (oldest) item in the list
|
// Kill the first (oldest) item in the list
|
||||||
AcceptEntityInput(G_WeaponArray[0][0], "Kill");
|
KillWeapon(G_WeaponArray[0][0]);
|
||||||
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
|
|
||||||
|
|
||||||
// Add new weapon to the end of the list
|
// Add new weapon to the end of the list
|
||||||
G_WeaponArray[g_MaxWeapons - 1][0] = entity;
|
G_WeaponArray[g_MaxWeapons - 1][0] = entref;
|
||||||
G_WeaponArray[g_MaxWeapons - 1][1] = GetTime();
|
G_WeaponArray[g_MaxWeapons - 1][1] = GetTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoveWeapon(int entity)
|
bool RemoveWeapon(int entref)
|
||||||
{
|
{
|
||||||
// Find the Weapon
|
// Find the Weapon
|
||||||
for(int i = 0; i < g_MaxWeapons; i++)
|
for(int i = 0; i < g_MaxWeapons; i++)
|
||||||
{
|
{
|
||||||
if(G_WeaponArray[i][0] == entity)
|
if(G_WeaponArray[i][0] == entref)
|
||||||
{
|
{
|
||||||
G_WeaponArray[i][0] = 0; G_WeaponArray[i][1] = 0;
|
G_WeaponArray[i][0] = 0; G_WeaponArray[i][1] = 0;
|
||||||
|
|
||||||
@ -243,16 +244,31 @@ bool CheckWeapons()
|
|||||||
if(g_MaxWeaponLifetime && GetTime() - G_WeaponArray[i][1] >= g_MaxWeaponLifetime)
|
if(g_MaxWeaponLifetime && GetTime() - G_WeaponArray[i][1] >= g_MaxWeaponLifetime)
|
||||||
{
|
{
|
||||||
// Kill it
|
// Kill it
|
||||||
AcceptEntityInput(G_WeaponArray[i][0], "Kill");
|
if(KillWeapon(G_WeaponArray[i][0]))
|
||||||
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
|
{
|
||||||
|
// Move index backwards (since the list was modified by removing it)
|
||||||
// Move index backwards (since the list was modified by removing it)
|
i--;
|
||||||
i--;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KillWeapon(int entref)
|
||||||
|
{
|
||||||
|
if(!IsValidEntity(entref))
|
||||||
|
return RemoveWeapon(entref);
|
||||||
|
|
||||||
|
// This implicitly calls OnEntityDestroyed() on success which calls RemoveWeapon()
|
||||||
|
AcceptEntityInput(entref, "Kill");
|
||||||
|
|
||||||
|
// Not successful?
|
||||||
|
if(IsValidEntity(entref))
|
||||||
|
return RemoveWeapon(entref);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
|
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < MAX_WEAPONS; i++)
|
for(int i = 0; i < MAX_WEAPONS; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user