NPC

hello. I’m not so good in scripting, i’m still learning. I do now know what’s wrong with this script. i think it is a parenthesis problem, but i have not noticed anything.

if (playerenters){toweapons -grab} if (keypressed && keydown2(keycode(a,true)) { setani grab,; }

I want it to play grab ani when you press A. it is supposed to work even if there’s no item(solid) in front of you.

well you have 3 left parenthesis and 2 right parenthesis, for one.

Not sure how to fix the keydown since it’s been so long since I’ve used it.
I’ll let tric do it for me lol

ok. i fixed it. thanks. well, Alex helped me lol. Had to add #p(parameter).

The part highlighted in bold is actually the problem so your code should become

if (keypressed && keydown2(keycode(a),true)){

I can understand the otherway though,which would’ve been

if (keypressed && strtofloat(#p(0)) == keycode(a)){

But this makes your code harder to understand and shouldn’t really be used while you’re trying to learn how to script in GS1.

gotta keep it simple

not exactly, Tricxta. Here it is:

if (playerenters){toweapons -grab}; if (keypressed && strequals(#p(0),65)) { setani grab,;}

not really a problem but why did no one notice the missing ; ?

-edit-

wait its outside of the brackets . wtf ?

it does work. the brackets are not a problem.

It might work but that’s not the problem. It’s the fact you’re using incorrect syntax!!!
You’re like alex when it comes to scripting, his scripts sucked because they were just copy and pasted together,
several timeouts, etc… Yet he thought he was top shit because the scripts worked.

If you refuse to correct your form, I for one refuse to help you.

oh. could you explain me what is in a correct syntax in my script? Sorry, but i’ve read the npc programming, and commands sheet, but there are some things i have not fully understood.

Thank you, Tricxta!

toweapons -grab

This might work but it’s wrong, each line needs a semicolon to end it. The correct way would be:
toweapons -grab;

That’s the only syntax error. Keep in mind you don’t need brackets if you only use one command for a statement.
Example:
This requires brackets since there’s 2 commands I need to execute
if (playerFarts){
message hahahaha!;
setcharani tease,;
}

However the following only needs one command and therefore brackets are not required
if (playerchats)message I be not interested in your shenanigans!;

However if you look in the debugger you’ll see the command is wrapped in brackets automatically.

oh. i see, Thanks for making me know. I’ll try to not commit that error again.