MrBehemoth
Senior Member
Posts: 408
Threads: 19
Joined: Feb 2014
Reputation:
40
|
RE: Something wrong with my script
The error message is telling you that there's something wrong with the SetEntityActive function on line 92. I've not counted the lines, but I'm guessing it's this:
if(SetEntityActive("armor1") == false)
So, the first thing error message says is that it can't find a matching signature (the list of variables in the brackets) for what it expects to find for SetEntityActive. We know SetEntityActive normally has two variables, a string and a boolean, so there's the first problem. But would it be true or false? You don't know, because that's what you're testing for... but it doesn't matter because...
The second part of the error message is saying that it can't convert your if condition into a boolean in order to work out whether it equals false. That's because, like most (if not all) of the functions in HPL2, SetEntityActive returns void, which means it's a one way street.
Notice how the wiki describes it as:
void SetEntityActive(string, boolean)
void SetPizzaTopping("cheese", "tomato") means call the SetPizzaTopping function and pass it 2 variables, "cheese" and "tomato". It's then up to SetPizzaTopping what it does with those variables and it returns void: it doesn't give you anything back. SetEntityActive is no different.
If we had a function:
boolean GetEntityActive(string)
then that would be different and it would do exactly what you want it to do... But we don't.
TL;DR: Your if condition is not going to work. You can't use SetEntityActive like that.
An alternative approach would be to use a variable to store whether the entity is active or not, and update it any time you use SetEntityActive. Then check the variable in your if statement instead.
(This post was last modified: 10-12-2014, 12:09 AM by MrBehemoth.)
|
|
10-12-2014, 12:04 AM |
|