custom-hooks-commands
textPage 17 of 152
50 messages on this page
Wednesday, May 29, 2024
User 6ceaf4
can you check if players can execute commands?
User 6ceaf4
ok, my server disconnected from csmm, that's why hooks ain't triggering
User 6ceaf4
Gotta say... I'm having the same problem
User 830925
Yes sir, I eve ntried shrinking it to just INF setRole and turning case sensitive off
User 6ceaf4
hook trigger is plain text
INF setRole Steam_?User 830925
Not sure what I did wrong. Set every bit of that exactly the way you have it here and nothings happens. I fired off the test command `w2l "setRole Steam_76561197980560687 DiscordRole" numerous times. Each time I see it in the console as expected. It's almost as if the logLine is never getting intercepted because even in the "Last Result" section of the custom hook I see zero results.
User 830925
OK TY, will give that a try later (not at computer now)
User 6ceaf4
INF setRole Steam_ as normal string search is fine btw
User 6ceaf4
you need both variables, so you can do
w2l "Test: setRole(${custom.id}, ${custom.role})"User 6ceaf4
Don't worry, at least you tried ๐
you need a custom variable to the steamId and one to the role. let's call them
For id the regex is
For role, the regex is
you need a custom variable to the steamId and one to the role. let's call them
id and roleFor id the regex is
(?<=setRole Steam_)(\d+)For role, the regex is
(?<=setRole Steam_\d{17} )\w+User 830925
Well I tried and I failed. Doing it with a fake role called "DiscordRole" and just manually sending that to console (same format my bot would since it just uses a console command)
So the console command I am using to test it is
I DO see that output in the console so I know that part is working fine:
w2l "setRole Steam_76561198002857667 DiscordRole"I DO see that output in the console so I know that part is working fine:
2024-05-29T15:37:02 16611.360 INF setRole Steam_76561198002857667 DiscordRoleHook event is
logLineCommand (just for testing) currently is
w2l "Test: ${custom.tempCommand}" but ultimately I just want the command to be exactly what is in my tempCommand variable.String filtering:
Initially I tried just
Then I tried regex instead with
(I think this might be the issue as I don't think it is capturing the logLine)
Initially I tried just
INF setRole Steam_ as a normal search string.Then I tried regex instead with
^INF\s(setRole\sSteam_[0-9]{17}\s(DiscordRole|OtherDiscordRole))$(I think this might be the issue as I don't think it is capturing the logLine)
Custom Variable:
Name:
Regex:
Name:
tempCommandRegex:
^INF\s(setRole\sSteam_[0-9]{17}\s(DiscordRole|OtherDiscordRole))$...... but nothing ever happens when I fire off that test command (other than me seeing it print that line to the console as we want it to do)
User 6ceaf4
w2l worked, so that is perfect. So now I can get the bot to send a message using w2l. Something like setRole Steam_765698765756765 WhateverRole now the question is, how would I intercept that in (I am assuming) a logLine hook and then parse the steamID and role out of that messaage and issue them in a command (do I need to post this in the other channel? Don't wanna get in more trouble)
Yeah, pretty much. You'll need to test it out a bit
User 830925
Brilliant!
User 6ceaf4
I guess this is more straight forward (and accurate):
{{#each (listVar "your-var-name-goes-here")}} {{!--#if (gte (round (abs (divide (timeDiff (moment this.updatedAt)) 3600) ) 0) 24)--}} {{#if (lte (timeDiff (moment this.updatedAt)) -86400)}} {{!-- it's been over 24 hours--}}a {{else}} {{!-- let player know he can't do this again yet--}}b {{/if}} {{/each}}
if timeDiff is less than -86400 (60sec * 60min * 24h), then a day has past.
User 6ceaf4
Let's read it from the center...
So, for every var that has "your-var-name-goes-here" (which should be only one), that line will convert the .updatedAt information it to a date (using moment), check how many seconds passed (using timeDiff), divide by 3600 to convert to hours (with divide, not really needed, tbh), make it a positive number (with abs), round it with round and check if it is greater or equal 24 (hours).
So, for every var that has "your-var-name-goes-here" (which should be only one), that line will convert the .updatedAt information it to a date (using moment), check how many seconds passed (using timeDiff), divide by 3600 to convert to hours (with divide, not really needed, tbh), make it a positive number (with abs), round it with round and check if it is greater or equal 24 (hours).
User 6ceaf4
sorry, code was missing the this.updatedAt...
User 830925
That went so far over my head ๐ฆ
Tuesday, May 28, 2024
User 6ceaf4
{{#each (listVar "your-var-name-goes-here")}} {{#if (gte (round (abs (divide (timeDiff (moment this.updatedAt)) 3600) ) 0) 24)}} {{!-- it's been over 24 hours--}} {{else}} {{!-- let player know he can't do this again yet--}} {{/if}} {{/each}}
User 6ceaf4
what about timeDiff?
User e5e1a1
But "how do I make this work" is a big question
User e5e1a1
If you give it a go and hit a specific hiccup we can give specific answers
User e5e1a1
From here - I recommend you go give it a try and tell us what you tried and what result you got
User e5e1a1
That would take some fiddling and testing and research
User e5e1a1
For that one you'll want to include a command in the "reset" part of the function that will set a second custom variable with a timestamp and then include a check with some maths to see if the timestamp was more than 3 days ago
User e5e1a1
The 3 day wait before allowing it to be done again is trickier because we don't recommend setting waits that last that long - if the csmm server instance restarts while waiting, the wait is forgotten
User e5e1a1
The command should also start with, check if the variable is 1. If so, do the thing. If not, set the variable, wait, clear the variable
User e5e1a1
Set a variable called reset_{{steamId}} to 1, wait(60), set the variable to 0
User e5e1a1
The second time in 60 seconds should be easy enough
User 830925
I know it is possible, I just cannot grasp the concept. I have tried, but failed. But here is what I would like to happen. I am assuming it just needs a temp variable and a small if then else if statement...
- Player types a command (ie. !resetdata) in chat.
- If it is the first time they type it (let's say, in 60 seconds) then it tells them in global chat to type it again within 60 seconds to reset
- If it is the 2nd time they typed it within 60 seconds it does
resetdata SteamID - If it is something they have already completed in the last X days (maybe 3 days) then do not let them do it again. So basically, have their personal variable last for 3 days. Is that even possible?
So I would assume some variable gets set. We use an If/Then to see if this is the first time or not. And an else if to see if it is the second time and if so, fire off the reset command.
Would anyone be able to assist?
Friday, May 10, 2024
User 6ceaf4
loop thru all online players every 5 minutes if you don't want to fire the command.
search for each server.onlineplayers here for that
search for each server.onlineplayers here for that
Thursday, May 9, 2024
User 5791fc
hmm, it might work if he is killing zombies. I suppose having the command fail when he is offline is not that big of a deal. What would I put in the cronjob that would check first? Right now the cronjob just runs the command every 5 minutes. And, when he's offline I just get a player offline message in the log every 5 minutes. Maybe theres a way to silence the error with some option I could put in the cron command?
User 6ceaf4
maybe use a log line of him killing a zombie would be better?
User 6ceaf4
what would trigger the hook? I'd leave as a cronjob but do the check first. Actually, going over every player online to see if that one is one of them seems more trouble than just issue a command that will fail
User 5791fc
I have a server running this command for a player every 5 minutes for a player who has asset unloading client crash issues:"eoc Chrono145 memcl" do you think there is a way to turn this into a custom hook command that checks if the player is online first?
Wednesday, May 8, 2024
User 651f09
Yep this worked! I could have sworn i tried it yesterday but I guess not lol.
User bddf69
try just using 'id' instead of crossId? That's the CSMM internal ID and should also work
Tuesday, May 7, 2024
User 651f09
Does setRole only work with steamID's? I've tried crossId, entityId, and XBL (steamId) but no dice.
This is part of my hook:
setRole({{get "crossId" (lookupPlayer custom.playername)}}, Supporter); And I get this message:
I removed the EOS id in this example.
Invalid criteria. Details: Could not use the providedwhereclause. Could not filter byid: Does not match the declared data type of the corresponding attribute. 1 error validating value: โข Specified value (a string: 'EOS_xxxxxxxxxxxxxxxxxx') doesn't match the expected type: 'number' ,EOS_xxxxxxxxxxxxxxxxxx, Supporter I removed the EOS id in this example.
Monday, May 6, 2024
User 830925
hah, that is almost exactly what I did. I did not do an each loop I just added that to the on player connected hook. Seems to be working fine so far.
User b42753
Did you think something like this?
Cron example, or you can hook the code elsewhere..
Cron example, or you can hook the code elsewhere..
{{#if (gte this.role.level 2000)}} cgc adduser {{this.steamId}} Default; {{else if (gte this.role.level 2}} cgc adduser {{this.steamId}} Admin; {{else if (gte this.role.level 1}} cgc adduser {{this.steamId}} HeadAdmin; {{else if (gte this.role.level 0}} cgc adduser {{this.steamId}} Owner; {{/if}} {{/each}}```
Sunday, May 5, 2024
User 830925
You'd definitely think ๐
User 6ceaf4
you think you'd be more able to find yourself around javascript maybe?
User 830925
Yes sir
User 6ceaf4
Rust is what, C#?
User 6ceaf4
the if/then would not be possible. what you can do instead is to use player joined hook, which only triggers the first time the player joins (or when char is reset)
User 830925
Would I need to do some sort of if/then statement so if they are already in a chat group like admin or others it does not try to re-add them back to the other default one? If so, what is the variable to read chat groups? I am assuming it'd be something like ...
{{#if (ne ???player is in a chat group???)}} cgc adduser {{player.steamId}} Default {{/if}}
.... or something? God I feel so dumb diving into this (I code plugins for Rust but here I am barely able to "Hello World" things)
User 830925
Oh so just do a quick "add them to this chat group" when they join? Good idea
User 6ceaf4
make a player connected hook
you can even set different chat groups for players and admins
you can even set different chat groups for players and admins

