I'm trying to set a trigger to enable when a car goes fast enough (a trigger_hurt in the front of the car so people dont die from it when its parked)
But I keep getting compiler issues when I load the map
Compiler log (from console)
Code:
AN ERROR HAS OCCURED [Script terminated by SQQuerySuspend]
CALLSTACK
*FUNCTION [EntFire()] unnamed line [20]
*FUNCTION [startRound()] cs_vehicletest.nut line [38]
*FUNCTION [main()] InputRunScript line [1]
LOCALS
[caller] NULL
[activator] NULL
[delay] 0
[value] ""
[action] "Disable"
[target] "killcar"
[this] TABLE
[e2mean] 0
[e1mean] 0
[e2] INSTANCE
[e1] INSTANCE
[ent2] INSTANCE
[entity] INSTANCE
[this] TABLE
[this] TABLE
My actual code
it finds trigger
compares it's mean velocity (x,y,z) with the value 2000
enables when > 2000
disables otherwise
Code:
function startRound() {
printl("A new round has started");
local entity = null;
entity = Entities.FindByClassname(entity,"trigger_hurt"); // find the trigger
if(entity!=-1){
printl("Trigger found");
} else {
printl("error trigger");
}
local e1 = null;
e1 = entity.GetVelocity(); //get its velocity
local e1mean = null;
e1mean = (e1.x + e1.y + e1.z)/3; //separate its dimensional components and sums them up
printl("The mean is");
printl("mean1: "+e1mean); //checking the code to see if it compiles this far
while (entity!=-1) //will constantly be monitored as long as it's "alive"
{
if(e1mean > 2000) // condition
{
EntFire(entity.GetName(), "Enable", 0,);
}
else
{
EntFire(entity.GetName(), "Disable", 0,);
}
}
}
It doesn't say anything is particularly wrong with the syntax or parameters (it is fine with the "enable" part)
although the documentation says
function EntFire(target, action, value, delay, activator)
i've seen an example for l4d2 written like:
(from
https://developer.valvesoftware.com/...cript_Examples)
Code:
ent <- null;
while((ent = Entities.FindByClassname(ent,"prop_physics")) != null)
{
EntFire(ent.GetName(),"DisableShadow",0);
}
Does anyone else see the problem?