Fix issues in a few plugins.

This commit is contained in:
BotoX 2016-10-26 22:46:10 +02:00
parent c66709f27c
commit 062a08b67e
7 changed files with 56 additions and 37 deletions

View File

@ -99,7 +99,7 @@ public Action OnCheatCommand(int client, const char[] command, int argc)
if(IsClientAuthorized(client) && CheckCommandAccess(client, "", ADMFLAG_CHEATS))
return Plugin_Continue;
PrintToConsole(client, "denied :^)");
//PrintToConsole(client, "denied :^)");
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))
return Plugin_Continue;
PrintToConsole(client, "denied :^)");
//PrintToConsole(client, "denied :^)");
return Plugin_Handled;
}

View File

@ -94,9 +94,9 @@ public void OnPluginStart()
AddCommandListener(Command_Say, "say");
AddCommandListener(Command_Say, "say_team");
HookEvent("player_team", Event_PlayerTeamPost, EventHookMode_PostNoCopy);
HookEvent("player_spawn", Event_PlayerSpawnPost, EventHookMode_PostNoCopy);
HookEvent("player_death", Event_PlayerDeathPost, EventHookMode_PostNoCopy);
HookEvent("player_team", Event_PlayerTeamPost, EventHookMode_Post);
HookEvent("player_spawn", Event_PlayerSpawnPost, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeathPost, EventHookMode_Post);
HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
HookEntityOutput("trigger_teleport", "OnEndTouch", Teleport_OnEndTouch);

View File

@ -71,11 +71,14 @@ public Action Command_ForceInputPlayer(int client, int args)
for(int i = 0; i < TargetCount; i++)
{
if (sArguments[2][0])
if(!IsValidEntity(aTargetList[i]))
continue;
if(sArguments[2][0])
SetVariantString(sArguments[2]);
AcceptEntityInput(aTargetList[i], sArguments[1], aTargetList[i], aTargetList[i]);
ReplyToCommand(client, "[SM] Input succesfull.");
ReplyToCommand(client, "[SM] Input successful.");
}
return Plugin_Handled;
@ -103,7 +106,7 @@ public Action Command_ForceInput(int client, int args)
SetVariantString(sArguments[2]);
AcceptEntityInput(client, sArguments[1], client, client);
ReplyToCommand(client, "[SM] Input succesfull.");
ReplyToCommand(client, "[SM] Input successful.");
}
else if(StrEqual(sArguments[0], "!target"))
{
@ -125,7 +128,7 @@ public Action Command_ForceInput(int client, int args)
SetVariantString(sArguments[2]);
AcceptEntityInput(entity, sArguments[1], client, client);
ReplyToCommand(client, "[SM] Input succesfull.");
ReplyToCommand(client, "[SM] Input successful.");
}
}
else
@ -135,19 +138,19 @@ public Action Command_ForceInput(int client, int args)
int entity = INVALID_ENT_REFERENCE;
while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
{
char sClassname[64];
char sTargetname[64];
static char sClassname[64];
static char sTargetname[64];
GetEntPropString(entity, Prop_Data, "m_iClassname", sClassname, sizeof(sClassname));
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
if(strncmp(sClassname, sArguments[0], Wildcard, false) == 0
|| strncmp(sTargetname, sArguments[0], Wildcard, false) == 0)
{
if (sArguments[2][0])
if(sArguments[2][0])
SetVariantString(sArguments[2]);
AcceptEntityInput(entity, sArguments[1], client, client);
ReplyToCommand(client, "[SM] Input succesfull.");
ReplyToCommand(client, "[SM] Input successful.");
}
}
}

View File

@ -41,8 +41,8 @@ public void OnPluginStart()
RegAdminCmd("sm_rainbow", Command_Rainbow, ADMFLAG_CUSTOM1, "Enable rainbow glowcolors. sm_rainbow [frequency]");
HookEvent("player_spawn", Event_ApplyGlowcolor, EventHookMode_PostNoCopy);
HookEvent("player_team", Event_ApplyGlowcolor, EventHookMode_PostNoCopy);
HookEvent("player_spawn", Event_ApplyGlowcolor, EventHookMode_Post);
HookEvent("player_team", Event_ApplyGlowcolor, EventHookMode_Post);
LoadConfig();

View File

@ -998,7 +998,7 @@ public void OnPlayerRadio(DataPack 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)
{
PbSetInt(RadioText, "msg_dst", g_MsgDest);
@ -1021,7 +1021,7 @@ public void OnPlayerRadio(DataPack pack)
}
EndMessage();
Handle SendAudio = StartMessage("SendAudio", g_MsgPlayers, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
Handle SendAudio = StartMessage("SendAudio", g_MsgPlayers, playersNum, USERMSG_RELIABLE);
if(g_bIsProtoBuf)
PbSetString(SendAudio, "radio_sound", g_MsgRadioSound);
else

View File

@ -24,7 +24,7 @@ public Plugin myinfo =
name = "WeaponCleaner",
author = "BotoX",
description = "Clean unneeded weapons",
version = "2.1",
version = "2.2",
url = ""
};
@ -65,12 +65,12 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
continue;
// Kill it
AcceptEntityInput(G_WeaponArray[0][0], "Kill");
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
// Move index backwards (since the list was modified by removing it)
i--;
d--;
if(KillWeapon(G_WeaponArray[i][0]))
{
// Move index backwards (since the list was modified by removing it)
i--;
d--;
}
}
}
g_MaxWeapons = StringToInt(newValue);
@ -129,7 +129,7 @@ public void OnEntityCreated(int entity, const char[] classname)
public void OnEntityDestroyed(int entity)
{
RemoveWeapon(entity);
RemoveWeapon(EntIndexToEntRef(EntRefToEntIndex(entity)));
}
public void OnWeaponSpawned(int entity)
@ -157,7 +157,7 @@ public Action OnWeaponEquip(int client, int entity)
return;
// Weapon should not be cleaned anymore
RemoveWeapon(entity);
RemoveWeapon(EntIndexToEntRef(entity));
}
public Action OnWeaponDrop(int client, int entity)
@ -184,6 +184,8 @@ public Action OnWeaponDrop(int client, int entity)
bool InsertWeapon(int entity)
{
int entref = EntIndexToEntRef(entity);
// Try to find a free slot
for(int i = 0; i < g_MaxWeapons; i++)
{
@ -191,28 +193,27 @@ bool InsertWeapon(int entity)
continue;
// Found a free slot, add it here
G_WeaponArray[i][0] = entity;
G_WeaponArray[i][0] = entref;
G_WeaponArray[i][1] = GetTime();
return true;
}
// No free slot found
// Kill the first (oldest) item in the list
AcceptEntityInput(G_WeaponArray[0][0], "Kill");
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
KillWeapon(G_WeaponArray[0][0]);
// 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();
return true;
}
bool RemoveWeapon(int entity)
bool RemoveWeapon(int entref)
{
// Find the Weapon
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;
@ -243,16 +244,31 @@ bool CheckWeapons()
if(g_MaxWeaponLifetime && GetTime() - G_WeaponArray[i][1] >= g_MaxWeaponLifetime)
{
// Kill it
AcceptEntityInput(G_WeaponArray[i][0], "Kill");
// This implicitly calls OnEntityDestroyed() which calls RemoveWeapon()
// Move index backwards (since the list was modified by removing it)
i--;
if(KillWeapon(G_WeaponArray[i][0]))
{
// Move index backwards (since the list was modified by removing it)
i--;
}
}
}
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)
{
for(int i = 0; i < MAX_WEAPONS; i++)