AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Off-Topic (https://forums.alliedmods.net/forumdisplay.php?f=15)
-   -   Vscript compiling problems (https://forums.alliedmods.net/showthread.php?t=262407)

KneeGrow 05-03-2015 18:11

Vscript compiling problems
 
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?

Kia 05-05-2015 08:43

Re: Vscript compiling problems
 
What game are you talking about?

eyal282 03-30-2022 17:54

Re: Vscript compiling problems
 
Quote:

Originally Posted by KneeGrow (Post 2293050)
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?

Because google Duck Duck Go leads to this post when looking up the error name, I will answer that I'm convinced this error is the result of an infinite loop.

elise11 04-06-2022 10:36

Re: Vscript compiling problems
 
Its so dificult.


All times are GMT -4. The time now is 02:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.