Thread: [Solved] [L4D] Count witch entities
View Single Post
Omixsat
Member
Join Date: Jul 2022
Old 09-13-2022 , 05:07   Re: [L4D] Count witch entities
Reply With Quote #7

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 0sizeof(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 0WitchListw++)
        {
            
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[] namebool 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(entref0);


    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(indextrue1);
            
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(indexevent.GetBool("oneshot"), 2); //oneshot
        
}
    }

Attached Files
File Type: sp Get Plugin or Get Source (l4d_witchcounter.sp - 16 views - 3.6 KB)
__________________
My Plug-Ins
Plug-in lookup
My Forks
[1] [2]

Last edited by Omixsat; 09-13-2022 at 05:20. Reason: updated with code
Omixsat is offline