dev

textPage 13 of 208
50 messages on this page
Saturday, January 29, 2022
Avatar for e5e1a1e030d906e6b0758aa714298a47ac1eb96bd571c5acc968a191bb9574fb
User e5e1a1
There's a full guide on handlebars in the docs
Avatar for 6bbafaadf0e1183243bd245f399a705298a6a8f00a3dcf2c75763ebdbf5a5b1b
User 6bbafa
I've also tried {{multiply ${newLvl} 10}} and every other combination I could find searching here with no luck
Avatar for 6bbafaadf0e1183243bd245f399a705298a6a8f00a3dcf2c75763ebdbf5a5b1b
User 6bbafa
giveplus Steam_${player.steamId} casinoCoin {{multiply (${newLvl}) 10}}
Avatar for 6bbafaadf0e1183243bd245f399a705298a6a8f00a3dcf2c75763ebdbf5a5b1b
User 6bbafa
I can't get the math to work
Avatar for 6bbafaadf0e1183243bd245f399a705298a6a8f00a3dcf2c75763ebdbf5a5b1b
User 6bbafa
Yeah sorry I have that fixed
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
As said in #csmm-support ,
giveplus Steam_${player.steamId}
...
Requires that Steam_ part
The say part works?
Avatar for 6bbafaadf0e1183243bd245f399a705298a6a8f00a3dcf2c75763ebdbf5a5b1b
User 6bbafa
So I am no coder but I know enough to be dangerous with powershell scripts, etc. I haven't worked with handlebars much and I use Visual Studio Code for most things documents. Any recommendation for extensions? I'm a bit frustrated with myself for not being able how to figure out:
say "[FF7F00]${player.name} [FFFF00]has reached level [9400D3]${newLvl} [FFFF00]and has earned (sum ${newLvl} * 10) Dukes"; giveplus ${player.steamId} casinoCoin (sum ${newLvl} * 10)
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Essentially, it'll allow using persistent variables in both runtimes. During handlebars execution and during command execution
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
It's not implemented yet but looking into it ๐Ÿ‘€
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
I managed to get it to work using a second hook and some w2l's. Can you tell me more about this potential solution, I would like to try to compact the whole thing into 1 hook if possible?
Friday, January 28, 2022
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
No more Schrodinger variables?
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
I hope that makes it clear ๐Ÿ˜„
I also know a potential solution for your use case: ability to call the persistent variable functions via CSMM custom functions
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
So in CSMMs custom command system, there's a few steps that happen
First of all, it will load a bunch of data from your server. This is stuff like
{{ server.onlinePlayers }}
and
{{ player.steamId }}
Then, it will take your template and run it through the Handlebars engine with the data it just collected. This is when everything with
{{ }}
resolves. All the Handlebars helpers like the
if
statements, the
add
helper and the persistent variables helpers.
After this, a list of strings comes out. Every element of this list is either a 7 days to die command OR a CSMM custom function (like
wait
).
CSMM will now go through the list and execute each thing one by one.
It's almost like it doesn't wait(x) before running the first #if
is exactly right. All the Handlebars stuff gets resolved first and only after that, the
wait
gets evaluated
Thursday, January 27, 2022
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
The logline will fire 4 times and pass B (Top code less the
delVar
)
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
I don't see how Say B will ever happen
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
I'm having a hard time understanding what you are trying to do...
Your code says:
Add 1 to the variable
If it is eq to 1 or less, say A and delete the variable
If it is greater or equal to 3, Say B
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
I'm wanting to get rid of the vari as i'm looking for a specific number of a log line entry in a specific time, it I don't remove it after a fail the first count will still be active & I will start getting false positives.
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
What are you aiming for with that delVar?
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
Soooo..
If i run it like this, technically it will work, Fail the 0, fail the 1, pass on the 4th.
wait(10);
{{#if (lte (getVar (add "player:counter:" player.steamId)) 1)}};
say "Command will fail {{getVar (add "player:counter:" player.steamId)}} time.";
{{/if}}
{{#if (gte (getVar (add "player:counter:" player.steamId)) 3)}};
say "Command will fire {{getVar (add "player:counter:" player.steamId)}} time.";
{{/if}}```

```Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 2 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fire 4 time.```

Problem is if I add the `delVar` here, It will just keep failing.

```{{ setVar (add "player:counter:" player.steamId) (add 1 (getVar (add "player:counter:" player.steamId))) }};
wait(10);
{{#if (lte (getVar (add "player:counter:" player.steamId)) 1)}};
say "Command will fail {{getVar (add "player:counter:" player.steamId)}} time.";
{{delVar (add "player:counter:" player.steamId)}};
{{/if}}
{{#if (gte (getVar (add "player:counter:" player.steamId)) 3)}};
say "Command will fire {{getVar (add "player:counter:" player.steamId)}} time.";
{{/if}}```



```Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.
Chat (from '-non-player-', entity id '-1', to 'Global'): 'Server': Command will fail 1 time.```

It's almost like it doesn't wait(x) before running the first `#if`, any thoughts?
Wednesday, January 26, 2022
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
Gotcha, I'm testing live on our test server as it's pulling a specific logline that directly relates to a new anti cheat feature I'm looking to implement, I've been waiting on these per varis to put it into place ๐Ÿ˜‰ I don't want to post the logline as ..well...you never know who might be reading this.
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
We'll see how your test goes ๐Ÿ˜„
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Let me know what happens when you test this :P
I am thinking of adding the per vars helpers as CSMM custom functions too. That way, you'll have more direct control of how/when they get called. So a dual system then
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
So untested as I said but I think this may cause issues depending on how the Handlebars engine behaves in this specific scenario.
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
For testing purposes: You could have deleted the variable via the playground UI instead :P
I would assume (not tested) that you should have that
delVar
call inside the first part of the if. So that way, it would only get deleted when the condition passes
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
Just a question about removing the per vari , This works fine
{{delVar (add "player:counter:" player.steamId)}}
But the issue I'm facing is if I add the
delVar
to the end of my hook it will keep deleting the vari every time the hook fires thus resetting the count back to 0.
I was manually removing the per vari with a custom command for testing purposes ๐Ÿ˜Š
{{ setVar (add "player:counter:" player.steamId) (add 1 (getVar (add "player:counter:" player.steamId))) }};

wait(10);

{{#if (gt (getVar (add "player:counter:" player.steamId)) 3)}};

say "PASSED for the {{getVar (add "player:counter:" player.steamId)}} time";

{{else}}

say "FAILED for the {{getVar (add "player:counter:" player.steamId)}} time.";

{{delVar (add "player:counter:" player.steamId)}};

 {{/if}}```
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
It's working now thankyou ! ๐Ÿ˜‰
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Hmmm ok, weird! I'll see if I can set this all up locally. It'd be tough to debug on the droplet.
Tuesday, January 25, 2022
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
I'd have to debug and check I suppose
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
My hypothesis:
Because your server is restarting it's very possible that some API requests behave weirdly, or network is glitchy or w/e.
Perhaps with a try catch around it that would fix the issue

Hmm actually I don't think this is the issue :p
I don't actually know but I suspect some Handlebars engine weirdness
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Yep, you sure do! :p
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Uh ok, so maybe I'm blind but I appear to be providing a value... ๐Ÿ™‚
unknown.png

unknown.png

PNG โ€ข 24.0 KB

Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
That you must provide the variable value message is something that was recently added here, coming from here:
https://canary.discord.com/channels/336821518250147850/427106880255426560/932692647955542107
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Oh no what this means is that the
setVar
helper failed because of
You must provide the variable value
. Because it failed, the output of the template was just
{{setVar "shutdownInTwoMinutes" 0}}
. It then tried to execute that as a command on your server which ofcourse failed and thus error gets returned
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Could that be it?
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Maybe because the server isn't ready yet to accept API calls?
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
So the hook is working but the variable command isn't...
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
sorry more:
"timestamp": "1/24/2022, 10:22:20 PM",
"results": [
    {
        "command": "{{setVar \"shutdownInTwoMinutes\" 0}}",
        "result": "An error occurred executing the API request to the 7D2D server"
    }
],
"errors": [
    "setVar: You must provide the variable value"
],
"template": [
    "{{setVar \"shutdownInTwoMinutes\" 0}}"
],
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
"results": [
{
"command": "{{setVar "shutdownInTwoMinutes" 0}}",
"result": "An error occurred executing the API request to the 7D2D server"
}
],
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Does it show the thing running there?
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Have you looked at the executions tab of the playground?
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Ok so my test case isn't complicated... not sure what's up here. Using a command to set a variable:
setvalue:
{{setVar "shutdownInTwoMinutes" 1}}
Then using the hook to change it:
OnConnected:
{{setVar "shutdownInTwoMinutes" 0}}
Then using a separate command to say the variable in chat:
readvalue:
say2 "[FF0000]Server" "Value of shutdownInTwoMinutes is: {{getVar "shutdownInTwoMinutes"}}"  
After setting it and restarting the server, it still reads as 1.
Avatar for a12f6e80e9d89b5470e3311f9d8388d6d4bc834b3825be85bf1f6a4e71dd314f
User a12f6e
Yeah I know, maybe something else is wrong, I'll look into it. ๐Ÿ™‚ But multiple shutdowns and the On Connect hook didn't fire. Let me check it again.
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Keep in mind that your counter is player-specific right now. So if you are testing with different players, the counters would be different
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
So as soon as I go over that the check switches
unknown.png

unknown.png

PNG โ€ข 43.1 KB

unknown.png

unknown.png

PNG โ€ข 43.2 KB

Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
You could grep your CSMM logs for
SSE error for server
. That should get logged when the server goes offline
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
I know for a fact the hooks are working, I sent you a screenshot of the hook and notifications both working ๐Ÿ˜‰
Avatar for bddf696212701f4e2e40cc177bb39c1f9c5f0a4ce49c307b79e8101c2a98158e
User bddf69
Nope, it's almost instant when the server goes down. Unless for some reason you are running an old version of Allocs?
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
I reduced to 10, made it run on playground and it got me the say pass part.
Try this instead of just FAIL to give you more control:
say "FAILED for the {{getVar (add "player:counter:" player.steamId)}} time.";
Avatar for bc43431b65cc8f7fb88ae66e5cfbe175a39472cbc3db92f842c7a016ee80c451
User bc4343
It seems to fire regardless of the count

wait(10);

{{#if (gt (getVar (add "player:counter:" player.steamId)) 100)}}

say "PASS";

{{else}}

say "FAIL";

 {{/if}}```

I have the hook firing once a second so my theory was set vari > wait for (x) seconds > compare vari count to a pre determined number > either PASS or FAIL depending on the #if.

My above example seems to fire PASS regardless of what the compare number at the end of the #if is?
Avatar for 6ceaf41ff27d04ff247f59c1bc5a9f4cc4ace95acc526862d52cdbbb8702989b
User 6ceaf4
Try this @User 44583928 :
{{ setVar (add "player:counter:" player.steamId) (add 1 (getVar (add "player:counter:" player.steamId))) }};

{{#if (gt (getVar (add "player:counter:" player.steamId)) 100)}}

say "TEST"

 {{/if}}```