Hello, I have a problem with an E2 function I'm trying to make. I'm building a robotic assistant/drone thingy, basically an E2 follower with a whole bunch of features stuffed in it. I'm using #include to construct sort of a modular code, one feature one E2, otherwise the code would be waay too chaotic. One feature I'm trying to implement is a weapon whitelist function, to filter out junk weapons from my roster etc. Whenever the function is called, it's supposed to check the weapons in my possession, and remove those that are not on the whitelist. Here is the code in an E2 that I #include-d in the main E2:
[CODE]function void enforceWhitelist()
{
findIncludeClass("weapon")
findInSphere(Owner:pos(),10)
local HeldWeapons = findToArray()
findClearWhiteList()
for(I=1,HeldWeapons:count())
{
local W = 1
while (W<=WhiteList:count() & HeldWeapons[I,entity]:type()!=WhiteList[W,string]) { W++ }
if(W>WhiteList:count()) { HeldWeapons[I,entity]:propDelete() }
}
}
[/CODE]
Problem is, that the find event ignores the [B]findIncludeClass("weapon")[/B] that precedes it, returning all entities of all classes in the given sphere. I know that normally whitelists are supposed to be declared in the [B]if(first()) {}[/B] part of an E2, however, I'd rather keep all code related to the weapon whitelist thing in the included E2 instead of the main one, and I also want to implement more feaures using find functions, with different whitelists. I also tried to use findClipToClass("weapon"), but it also erased weapons from the inspected array that don't have "weapon" in their name, like M9K stuff. Apart from the problem with the array, the code works well, except that it also deletes any of my props/entities etc I'm standing on as a result of the whitelsit being ignored. Can anyone help me?
Sorry, you need to Log In to post a reply to this thread.