Score/Points System for users

I’m looking to have a system where we can add and track scores for each user. As of right now I found this as a starting point: Individual tracking and how to add a point to a user

As-is it does function but has a couple key limitations that I’d like to move past but are beyond my scope. Foremost, I need a way to be able to add multiple points instead of doing it one at a time. Also ideally, I would have it so that it is only taking the username as an input rather than the entire string.

How would I go about modifying the givepoint command in that post to accept a number to increment by rather than just doing +1? Or, is there an alternate set-up that is perhaps a bit more elegant than this (since as far as I can tell it’s just adding the username multiple times to a quote list).

u r absolutely correct, that version was adding the username over and over and then counting how many times the name was added… this version can do as u asked, add any amount of points ^^

!addcom -ul=owner !givepoint -a=_!givepoint $(eval a=`$(urlfetch$(1))`.split(` `);b=`$(2)`;`$(1)`&&b&&b==b*1&&`$(twitch $(1))`!=`Error: Channel not found.`?`PRIVATE_TOKEN&data=${a[0]==`0.`?`$(1)%20${b} add`:`${a[0].replace(`.`,``)}%20$(1)%20${b*1+a[2]*1} edit`}`:`PRIVATE_TOKEN add`) $(query)

!addcom -ul=owner _!givepoint $(eval a=`$(urlfetch$(2)quote?token=$(1))`;b=`$(query)`;c=b.split(`%20`);b.includes(`PRIVATE_TOKEN`)?(a.includes(`Successfully`)?`Successfully awarded $(4) point(s) to $(3) and they now have ${c[c.length-1].split(` `)[0]}!`:`Error: Please add a valid username and amount of points after the command.`):` `)

!addcom -cd=5 !points $(eval a=`$(urlfetch$(touser))`.split(` `);`$(touser) currently has ${a[0]!=`0.`?a[2]:0} point(s).`)

!addcom -ul=owner !resetpoints $(eval `$(urlfetch`==`All entries have been deleted`?`All scores have been reset!`:`Try again...`)

u can also reduce the amount of points a user has if u use negative numbers :wink:

I copied the commands in as you had them, and added the appropriate tokens. Something appears to have gone wrong, though. Every time I try to test !givepoint it gives me the error message, no matter what way I attempt to order the information. It should look like “!givepoint FancySkunk 5” if I want to give myself 5 points, right?

$(eval a=`$(urlfetch$(1))`.split(` `);b=`$(2)`;`$(1)`&&b&&b==b*1&&`$(twitch $(1))`!=`Error: Channel not found.`?`00e4225192bd94d7&data=${a[0]==`0.`?`$(1)%20${b} add`:`${a[0].replace(`.`,``)}%20$(1)%20${b*1+a[2]*1} edit`}`:`00e4225192bd94d7 add`) $(query)

$(eval a=`$(urlfetch$(touser))`.split(` `);`$(touser) currently has ${a[0]!=`0.`?a[2]:0} point(s).`)

$(eval `$(urlfetch`==`All entries have been deleted`?`The leaderboard has been reset!`:`Try again...`)

$(eval a=`$(urlfetch$(2)quote?token=$(1))`;b=`$(query)`;c=b.split(`%20`);b.includes(`00e4225192bd94d7`)?(a.includes(`Successfully`)?`Successfully awarded $(4) point(s) to $(3) and they now have ${c[c.length-1].split(` `)[0]}!`:`Error: Please add a valid username and amount of points after the command.`):` `)

yes, that is the correct format… what is it saying?

u do have the first one aliased to the last one, correct?

oh shit, u know what?, the one thing i didn’t test is using an empty quote list… i used one we already had that already had info in it… it doesn’t respond the same for an empty one… lemme update that one command real quick… (!givepoint)

$(eval a=`$(urlfetch$(1))`.split(` `);b=`$(2)`;`$(1)`&&b&&b==b*1&&`$(twitch $(1))`!=`Error: Channel not found.`?`00e4225192bd94d7&data=${a[0]==`0.`||a[0]==`There`?`$(1)%20${b} add`:`${a[0].replace(`.`,``)}%20$(1)%20${b*1+a[2]*1} edit`}`:`00e4225192bd94d7 add`) $(query)

there, that should fix it… but now that u’ve exposed your private token, i would recommend generating a new one, cause anybody that knows how to use the system can now make commands on their own channel that can manipulate the info in your list… aka, they could add extra points to their own name, remove points from others, or even add corrupted info that would break the commands

oh wait, needa do the same thing to !points too…

$(eval a=`$(urlfetch$(touser))`.split(` `);`$(touser) currently has ${a[0]!=`0.`||a[0]!=`There`?a[2]:0} point(s).`)

there we go

Awesome! Everything looks to be in working order now. I’ll change the tokens before we actually use this for anything, per your advice.

oops, lmao… i was high when i did that… the !points command is in fact broken, lol, my bad…

$(eval a=`$(urlfetch$(touser))`.split(` `);`$(touser) currently has ${a[0]!=`0.`&&a[0]!=`There`?a[2]:0} point(s).`)

that’ll fix it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.