Jump to content
Sign in to follow this  
BullyBoii

Cant seem to hint a variable?

Recommended Posts

Hi guys, i was just trying our some basic scripting to try and display the

position of a player in-game via the hint script

_playerPos = getpos solider_1;

hint _playerPos

is see no reason for this not to have worked, based on my very limited scripting

knowledge, anyone have any suggestions

Share this post


Link to post
Share on other sites

thanks,

so if i wanted to create a trigger from this to kill the player if they are at a certain direction would i just script


hint format ["%1", getdir player]

if (%1 === 300) then {player setDamage 1} else {};
sleep 1;
if (alive player) then {} else {hint silent "you have been killed"};

thanks for your help, i really need to start learning how to script, ive been trying codecademy for javascript and html but its not the same as having some face-to-face teach you, plus i try and work throught the exercises too fast so i dont really learn much :)

thanks anyway

Share this post


Link to post
Share on other sites

You can only hint strings, that's why you need to format the position array.

%1 is only used inside a "format" array, not outside.

You'd use something like

if ((getDir player) == 300) then {player setDamage 1};

Which is kind of a weird way to kill the player..

"else" does not need to be used in an if-then statement. It's optional.

You can also use exclamation mark ( ! ), or "NOT" for doing something that's "not true".

if (not alive player) then {hint "you're dead"};
// equals
if (!alive player) then {hint "you're dead"};

Read some scripting tutorials, keep coding, looking at other people's script etc. That's the best way to learn.

Share this post


Link to post
Share on other sites

cheers, i spose its really about logical thinking, its just hard trying to get into that mentality

im still gooing to keep at it, it doesnt process itself overnight :)

Share this post


Link to post
Share on other sites
im still gooing to keep at it, it doesnt process itself overnight :)

hah, sometimes it actually does! There's been plenty of times where I'll be completely stumped and suddenly wake up one morning knowing exactly what to try next.

Share this post


Link to post
Share on other sites

You need to enable script errors, then it will be immediately clear what you're doing wrong (in your case it would say "type array, expected string").

Also, if you just need to quickly hint a variable it's faster to use str instead of format:

hint str (getPos player);

One more thing...

so if i wanted to create a trigger from this to kill the player if they are at a certain direction would i just script

I don't think you realize what getDir does. It returns the direction the unit is facing. Do you really want your script to kill anyone who looks north-west? Even if that is your intention, == is an exact comparison. _dir == 300 returns true only and only if _dir is exactly 300. Because getDir returns a decimal number that is almost impossible. 300.0001 is not 300.

It might be better if you explained in detail what exactly it is you want to achieve.

Edited by Deadfast

Share this post


Link to post
Share on other sites
hah, sometimes it actually does! There's been plenty of times where I'll be completely stumped and suddenly wake up one morning knowing exactly what to try next.

Same here.... too true!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×