Jump to content
Alpine_gremlin

[SOLVED] Help with Simple Sandbag Script

Recommended Posts

Hello guys. So I`ve already made a post about a separate script that I am working on but since I am still a scrub when it comes to writing my own scripts, I am having trouble with this simple one.

 

All it does is create a sandbag wall at the player`s position after five seconds and is called via the AddAction menu. I get the "error missing )" message at line 7. Could anyone tell me where the problem might be? Am I using the sleep command properly?

 

hint "Building Sandbag...";

sleep 5; 

_time = 5;

if (time = 5) then
{

_newWall = "Land_BagFenceShort" createVehicle (position player);

hint "Sandbag built!";
};

EDIT: I changed time = 5 to _time = 5 and am still getting the same error.

Share this post


Link to post
Share on other sites
36 minutes ago, das attorney said:

if (time == 5) then

= is for assignation

== is for comparison

 

Oh just one more question: Since it is a multiplayer mission, I would like avoiding broadcasting the hint to everyone except the one player using the addaction at that time (everyone has the option to build). Would you happen to know how I could do this since I`m not using triggers?

Share this post


Link to post
Share on other sites
11 hours ago, das attorney said:

if (time == 5) then

= is for assignation

== is for comparison

On a side note, time == 5 will most likely never return true, at least last time I checked.

You'd be luckier with one of these:

round time == 5 //still not recommended
time >= 5 //will work

 

In the OPs specific example the if (time>=5) check doesn't make any sense, since the sleep 5 command will guarantee for at least 5 seconds to pass before doing anything past it.

Edit: Also depending on the runtime of the mission this check will most likely be true all the time, since time increases during mission runtime. It will only be <= 5 for the first 5 seconds after starting the mission.

 

 

Cheers

  • Like 3

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

×