Jump to content

Recommended Posts

Hi, so I am currently working on a small basic RP server for a dozen friends.. And I am currently trying to create a "garbage man" job. So I have placed dumpsters around and once interacting with them a script gets called that basically adds certain items to a crate (The dumpster) But ofcourse it would be weird if you can just spam the script and gets loads of garbage and that way load your whole truck up with only 1 dumpster, so I want to add a cooldown to it.

 

The script I used is as simple as: " testbox addmagazinecargoglobal ["vop_dilithium", 150]; " And as I am totally not a pro scripter, I was wondering how I would go and add a cooldown to this. I have tried sleep, uiSleep and waitUntil. But probably used them incorrectly..

 

Any tips? 😄

Share this post


Link to post
Share on other sites

put this somewhere in the execution part of the script:

nextRunTime = time + 120;

 

put this in the condition of the action
time > nextRunTime

 

untested

  • Confused 1

Share this post


Link to post
Share on other sites

@stanhope So, basically what I did is make an addaction in the init of my trashcan: "vuilnisbak1 AddAction ["<t color=""#0EEBE4"">" +"Verzamel Vuilnis", "Vuilnisjob\vuilnisbak1.sqf"];" And the trashcan ofcourse being called "vuilnisbak1"  So where would I put "time > nextRunTime"

Share this post


Link to post
Share on other sites

In the condition of the addaction so:

 

vuilnisbak1 addAction [
    "<t color=""#0EEBE4"">Verzamel Vuilnis</t>", 
    "Vuilnisjob\vuilnisbak1.sqf",
    nil,
    1,
    true,
    false,
    "",
    "time > nextRunTime"
];

Be sure to initialize nextRunTime in initplayer, either set it to 0 or to the current time. 

Share this post


Link to post
Share on other sites

I don't know why many scripters are using addAction in its basic, outdated, ugly, non-practical syntax! You could use code instead of string, string, string.. for such sqf.

 

  On 3/5/2021 at 4:01 PM, steam-76561198069261992 said:

The script I used is as simple as: " testbox addmagazinecargoglobal ["vop_dilithium", 150]; "

Any tips? 😄

 

You can add a variable on caller (the player who triggers the addAction), and use it in condition parameter of the addAction:

For example (I guess vuilnisbak1 is same as testbox...)
 

vuilnisbak1 addAction [ "<t color='#0EEBE4'>Verzamel Vuilnis</t>",
  {
    params ["_crate","_caller"];
    _crate addmagazinecargoglobal ["vop_dilithium", 150];
    _caller setVariable ["stopCoolDown",FALSE];
    sleep 30;
    _caller setVariable ["stopCoolDown",TRUE]
  }, nil, 1, true, false, "", "(_this getVariable ['stopCoolDown',TRUE])" ];

So each player has a cooldown for the crate. Now, if this cooldown must be general (for all players), just set variable on crate instead of player.

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi Actually there is an issue, I just started the server for the first time and we already found an issue. When you activate 1 trashcan, the other trashcans are on cooldown too. Meaning that the cooldown is completely useless as I wanted it so that people wouldn't camp one can but go to others in other locations.

Share this post


Link to post
Share on other sites

As said, you can cooldown action for player (no matter the crate) or for the crate (depending on player or not).

I can't guess what you're scripting but one sure thing, if you set an action on a crate, then a cooldown variable on that crate, there is no reason for disabling the addaction on other crates.

Share this post


Link to post
Share on other sites

The code he put in his reply sets the cooldown to the player.  This has the side-effect that once the cooldown is active it's active for all the crates.  If you want the cooldown for the crate replace _caller with _crate in the code of the addaction and _this with _target in the condition

Share this post


Link to post
Share on other sites

@stanhope thanks, and I know this thread isn't focussed on this. But how do I disable "admin voting" I have looked at "mission voting" "server.cfg" and also multiple threads, but it doesn't seem to work.. And my server is hosted on GPORTAL and in the server.cfg I cannot change anything, it just changes it back.

Share this post


Link to post
Share on other sites

Server stuff is not something I'm good at

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

×