dev
textPage 13 of 208
50 messages on this page
Saturday, January 29, 2022
User e5e1a1
There's a full guide on handlebars in the docs
User 6bbafa
I've also tried {{multiply ${newLvl} 10}} and every other combination I could find searching here with no luck
User 6bbafa
giveplus Steam_${player.steamId} casinoCoin {{multiply (${newLvl}) 10}}
User 6bbafa
I can't get the math to work
User 6bbafa
Yeah sorry I have that fixed
User 6ceaf4
As said in #csmm-support ,
Requires that Steam_ part
The say part works?
giveplus Steam_${player.steamId}...Requires that Steam_ part
The say part works?
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)
User bddf69
Essentially, it'll allow using persistent variables in both runtimes. During handlebars execution and during command execution
User bddf69
It's not implemented yet but looking into it ๐
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
User 6ceaf4
No more Schrodinger variables?
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
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
CSMM will now go through the list and execute each thing one by one.
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 evaluatedThursday, January 27, 2022
User bc4343
The logline will fire 4 times and pass B (Top code less the
delVar )User 6ceaf4
I don't see how Say B will ever happen
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
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
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.
User 6ceaf4
What are you aiming for with that delVar?
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
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.
User bddf69
We'll see how your test goes ๐
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
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.
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 passesUser 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}}```
User bc4343
It's working now thankyou ! ๐
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
User bddf69
I'd have to debug and check I suppose
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.
This function runs before the template gets rendered:
https://github.com/CatalysmsServerManager/7-days-to-die-server-manager/blob/master/worker/util/CSMMCommand/index.js#L39
https://github.com/CatalysmsServerManager/7-days-to-die-server-manager/blob/master/worker/util/CSMMCommand/index.js#L39
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
I don't actually know but I suspect some Handlebars engine weirdness
User bddf69
Yep, you sure do! :p
User a12f6e
Uh ok, so maybe I'm blind but I appear to be providing a value... ๐

unknown.png
PNG โข 24.0 KB
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
https://canary.discord.com/channels/336821518250147850/427106880255426560/932692647955542107
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 returnedUser a12f6e
Could that be it?
User a12f6e
Maybe because the server isn't ready yet to accept API calls?
User a12f6e
So the hook is working but the variable command isn't...
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}}" ],
User a12f6e
"results": [
{
"command": "{{setVar "shutdownInTwoMinutes" 0}}",
"result": "An error occurred executing the API request to the 7D2D server"
}
],
{
"command": "{{setVar "shutdownInTwoMinutes" 0}}",
"result": "An error occurred executing the API request to the 7D2D server"
}
],
User bddf69
Does it show the thing running there?
User bddf69
Have you looked at the executions tab of the playground?
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.
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.
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
User bddf69
You could grep your CSMM logs for
SSE error for server. That should get logged when the server goes offlineUser bddf69
I know for a fact the hooks are working, I sent you a screenshot of the hook and notifications both working ๐
User bddf69
Nope, it's almost instant when the server goes down. Unless for some reason you are running an old version of Allocs?
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:
Try this instead of just FAIL to give you more control:
say "FAILED for the {{getVar (add "player:counter:" player.steamId)}} time.";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?
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}}```

