Okay... I'm ALMOST there. I'm now having issues with the argument type mismatch.
Lines 108, 145, and 146 are having errors.
Code:
error 035: argument type mismatch (argument 1)
PHP Code:
/*
"witch_harasser_set"
{
"userid" "short" // Player who woke up the witch
"witchid" "long" // Entindex of witch woken up
"first" "bool" // First time the witch set a harasser
}
"witch_spawn"
{
"witchid" "long" // Entindex of witch spawning right now.
}
"witch_killed"
{
"userid" "short" // Player who killed the witch
"witchid" "long" // Entindex of witch that was killed.
"oneshot" "bool" // TRUE if the Witch was killed with one shot
}
"zombie_ignited"
{
"userid" "short" // player who caused ignition
"gender" "short" // gender (type) of the infected
"entityid" "long" // entity ID of Tank
"victimname" "string" // "Witch", "Tank", "Hunter", "Smoker", or "Infected"
"fire_ammo" "bool" // true if incendiary ammo was used
}
*/
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.2"
#define DEBUG 1
enum struct WitchInfo
{
int entref; //block 0
bool IsRage; //block 1
bool oneshot;
}
char witcheventnames[][] = {
"witch_harasser_set",
"witch_spawn",
"witch_killed"
};
ConVar hWitchDangerDistance;
ArrayList ListOWitches;
public Plugin myinfo =
{
name = "[L4D] Witch Counter",
author = "Omixsat,Bacardi",
description = "Count witch entities and print their information",
version = "1.0",
url = ""
}
public void OnPluginStart()
{
for(int x = 0; x < sizeof(witcheventnames); x++)
HookEventEx(witcheventnames[x], witchevents);
ListOWitches = new ArrayList(3);
// if plugin is loaded manually, look all spawned witch entities on map
int ent = -1;
WitchInfo witch; // sugar coated array
while((ent = FindEntityByClassname(ent, "witch")) != -1)
{
witch.entref = EntIndexToEntRef(ent);
ListOWitches.PushArray(witch);
}
}
public void OnPluginEnd()
{
ListOWitches.Clear();
}
public void OnMapEnd()
{
ListOWitches.Clear();
}
public void OnEntityDestroyed(int entity)
{
if(!IsValidEntity(entity))
return;
char classname[8];
GetEntityClassname(entity,classname,sizeof(classname));
if(StrEqual(classname, "witch"))
{
int WitchList = ListOWitches.Length;
for(int w = 0; w < WitchList; w++)
{
int ent = EntRefToEntIndex(ListOWitches.Get(w,0));
if(IsValidEntity(ent))
{
PrintToChat("Witch ID %i has been removed from WitchList", ent);
ListOWitches.Erase(w); // = remove witch from list
}
}
}
}
public void witchevents(Event event, const char[] name, bool dontBroadcast)
{
int entref = EntIndexToEntRef(event.GetInt("witchid", 0));
//int userid = event.GetInt("userid", 0);
// Try find entref value from block 0, "entref"
int index = ListOWitches.FindValue(entref, 0);
if(StrEqual(name, "witch_spawn"))
{
// This should not happen, same entity spawn twice
if(index != -1)
return;
WitchInfo witch; // sugar coated array
witch.entref = EntIndexToEntRef(event.GetInt("witchid"));
ListOWitches.PushArray(witch);
}
else if(StrEqual(name, "witch_harasser_set"))
{
if(index != -1)
{
// store userid value to block 2, "harasser"
//ListOWitches.Set(index, userid, 2); //no need
// woked block 1
ListOWitches.Set(index, true, 1);
PrintToChat("Witch ID %i Rage status: %i",EntRefToEntIndex(index),ListOWitches.Get(index,1));
PrintToChat("Witch ID via ArrayList is %i", EntRefToEntIndex(index));
//No need to look for m_rage or m_wanderrage
}
}
else if(StrEqual(name, "witch_killed"))
{
if(index != -1)
{
//ListOWitches.Set(index, userid, 3); //killer
ListOWitches.Set(index, event.GetBool("oneshot"), 2); //oneshot
}
}
}