OP
Ameglian cow
Joined: Jan 2018
Posts: 21 |
Hello everyone, I am trying to make a points system for Twitch. So far I have this:
[script]
on *:text:!gamble*:#: {
if (%floodgamble) { return }
set -u0 %floodgamble On
if ($2 isnum 1-1000000000) {
var %wager = $floor($2)
var %randgamble = $rand(1,100)
if (%randgamble <= 50) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - %wager)
msg $chan /me @ $+ $msgtags(display-name).key lost $2 points in roulette and now has $readini(Points.ini,$+(#,.,$nick),Points) points.
}
elseif (%randgamble >= 50) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + (%wager * 1))
msg $chan /me @ $+ $msgtags(display-name).key won $2 points in roulette and now has $readini(Points.ini,$+(#,.,$nick),Points) points.
}
else {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + (%wager * 1))
msg $chan /me @ $+ $msgtags(display-name).key won $2 points in roulette and now has $readini(Points.ini,$+(#,.,$nick),Points) points.
}
SET -ze %gamble_CD. $+ $nick 0
}
else msg $chan /me @ $+ $msgtags(display-name).key To gamble points, use the form !gamble <amount>
n23=}
Combined with this script:
[script]
alias -1 addPoints {
if {$1 !isnum) { echo 2 -st $1 is not a number. It need to be a number. | halt }
var %topic $+($chan,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $1)
writeini -n Points.ini %topic Points %points
return %points
}
alias -l lookUpPoints {
var %topic $+($chan,.,$nick)
var %points $readini(Points.ini,%topic,Points)
return %points
}
alias doaddpoints {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %points $calc($readini(Points.ini,%topic,Points) + $3)
writeini -n Points.ini %topic Points %points
echo -a Added points for %topic
}
alias dorempoints {
var %topic $+($1,.,$2)
remini -n Points.ini %topic Points
echo -a Removed points for %topic
}
on *:text:!points:#:{
if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
set -u10 %floodpoints On
set -u30 %floodpoints. $+ $nick On
msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) total points.
}
on $*:text:/!points (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return }
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) total points. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
if ((%floodjoin) || ($($+(%,floodjoin.,$nick),2))) { return }
set -u10 %floodjoin On
set -u30 %floodjoin. $+ $nick On
msg $chan $nick has joined and is now earning points.
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
if ((%floodpart) || ($($+(%,floodpart.,$nick),2))) { return }
set -u10 %floodpart On
set -u30 %floodpart. $+ $nick On
msg $chan $nick has left the channel and is no longer earning points.
n54=}
It all works fine and is responding the way I want it to. However, people can !gamble points that they don't have and my guess is this happens because the first part of the script doesn't check in Points.ini if they in fact have the points. They can also !gamble below 0 which will result in people just gambling millions over and over. My question is if you can fill in the blanks to check if the user has enough points in Points.ini so that the user can't gamble more than he/she has. They also shouldn't be able to go below 0. I am new to this and I tried my hardest but I can't figure it out. Thank you very much for reading this, Ry
Last edited by Ryntovy; 13/06/18 05:54 PM.
|