hi. i have created a command for fighting and i want to make track for wins and lose matches like !profile : wins 10 lose 5 draw 2 . it shows how many match i played and how much win lose draw . and i wonder if there a way to make ranks to it
Hey @tager_almoot!
Yes, it’s possible, at least the first part of what you’re asking for definitely is: Use ehsankia’s Quote System API.
Here’s a similar command I wrote that you can use for guide: Win-Loss Counter with customapi
There are plenty other topics using this API on the forum that can help you if this one doesn’t satisfy your needs.
this is the command i’m using:
$(user) fought $(touser) and $(eval a=[won by KO
,Draw both fighter's down
,lost by submission
]; a[Math.floor(Math.random()*a.length)])
how i could add the tacker to it because i did’t get it from ehsankia quote system + the win-loss counter -
i want it to track win and lose by it self and if u can type the command that will be great help
Alright, sorry I was busy, I didn’t have time to look into your command…
As I mentioned before, we’ll use ehsankia’s quote system API. You’ll get your TOKENS
by clicking on the second link in the post, in the Manual Installation section, use these in the commands I wrote. To know where to look for your PUBLIC_TOKEN
and PRIVATE_TOKEN
, look at the field bellow:
$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&data=$(querystring))
Keep your PRIVATE_TOKEN
secret, don’t share it anywhere. Add the following commands from the dashboard. Don’t use the chat as anyone could monitor it and copy the token, they could then edit your data.
First we’ll have a command to define the outcome of the fight, this is your !fight
command:
$(eval a=[`w`,`d`,`l`]; b=[`l`,`d`,`w`]; r=Math.floor(Math.random()*3); `$(user) ${a[r]}|$(touser) ${b[r]}|`;)
Then, to this !fight
command, we’ll add _fight
as an alias (put _fight
in the alias field of !fight
):
$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))`; q=`$(query)`.replace(`|`,` `).split(` `); o=[`won by KO!`, `it's a draw: both fighters are down.`, `lost by submission...`]; `${q[0]} fought ${q[2]} and ${q[1]==`w`?o[0]:q[1]==`d`?o[1]:q[1]==`l`?o[2]:`ERROR`}`;)
And finally, to get an user’s statistics, here’s the !stats
command:
$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`|`); u=[]; w=d=l=e=0; q.forEach(f => f==`$(user)`+f.slice(`$(user)`.length)?u.push(f.replace(`$(user) `,``))); u.forEach(g => g==`w`?w++:g==`d`?d++:g==`l`?l++:e++); `$(user) statistics - Wins: ${w} | Losses: ${l} | Draws: ${d}${if(e>0){" | ERRORS: "+e}}`;)
For the ranks there’s too much data to take in account, so I won’t set it up, learn JS and implement it yourself if you really want it.
i have created !fight command : $(eval a=[`w`,`d`,`l`]; b=[`l`,`d`,`w`]; r=Math.floor(Math.random()*3); `$(user) a[r]|$(touser) b[r]|`; )
and add on alias _fight
and created _fight command : $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=fhd83hjfdefj&data=$(querystring))`; q=`$(query)`.replace(`|`,` `).split(` `); o=[`won by KO!`, `it's a draw: both fighters are down.`, `lost by submission...`]; `${q[0]} fought ${q[2]} and ${q[1]==`w`?o[0]:q[1]==`d`?o[1]:q[1]==`l`?o[2]:`ERROR`}`;)
and i have added my private token to it and when i use fight command it kept giving me errors
i created !stats command and added my public token to it but it still
$(eval q=`$(urlfetch json https://twitch.center/customapi/quote/list?token=ce1wcwu2&no_id=1)`.split(`|`); u=[]; w=d=l=e=0; q.forEach(f => if(f.includes(`$(user)`)){u.push(e.replace(`$(user) `,``))}); u.forEach(g => g==`w`?w++:g==`d`?d++:g==`l`?l++:e++); `$(user) statistics - Wins: ${w} | Losses: ${l} | Draws: ${d}${if(e>0){" | ERRORS: "+e}}`; )
but it did’t work kept giving me Unexpected token ‘if’
The problem with the error in the first command is that There should be ${}’s around the a[r] and b[r] in the first command
As for the second command I dont think your allowed to do if inside of .forEach try:
q.forEach(f=>f=="$(user)"+f.slice("$(user)".length)?u.push(f.replace(`$(user) `,``)))
Thank you @potatoeaterlove!
I didn’t try these commands as, if I remember well, it was very late when I wrote them, hence the bracket error. I also learned that if
statements don’t work in forEach
loops thanks to that mistake and thank you for the very clever fix!
I updated the code in the original reply.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.