mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2016
Posts: 1
D
Mostly harmless
OP Offline
Mostly harmless
D
Joined: Mar 2016
Posts: 1
Hi there,

Very new to IRC and scripting in general and was looking for a little help for my problem. I'm adapting a script I already have thanks to a mate of mine, and essentially it let's people request songs for me to play on Guitar Hero Live. Currently there's a !list command with a URL to the list of songs available which is great.

The problem I'm having is that I don't want people to be able to submit any random text as a "request" - due to trolling and such - and was wondering if there was any way of linking the !request cmd to a permanent list of songs, so that if people do not request within the songlist the request will not be taken and added to the queue.
This is the script I currently have:

Quote:

on *:TEXT:!songs:#: {
if (%songstimer == 0) {
if (%SongsLink == $null) {
msg $chan I don't have a link to a list of songs $nick
}
else {
msg $chan The songs you can request are found here %SongsLink
}

%songstimer = 1
.timer 1 10 set %songstimer 0
}
}


%songstimer = 1
.timer 1 10 set %songstimer 0
}
}


on *:TEXT:!current:#: {
if (%currenttimer == 0) {
var %songname $readini(SongRequests.ini, n, Songs, 0)
var %user $readini(UserRequests.ini, n, Users, 0)

if (%songname != $null) {
msg $chan " %songname " requested by %user is the current song.
}
else {
msg $chan There are no songs left on the list. Type !request to request a song.
}

%currenttimer = 1
.timer 1 10 set %currenttimer 0
}
}


on *:TEXT:!next:#: {
if (%nexttimer == 0) {
var %songname $readini(SongRequests.ini, n, Songs, 1)
var %user $readini(UserRequests.ini, n, Users, 1)

if (%songname != $null) {
msg $chan " %songname " requested by %user is the next song.
}
else {
msg $chan There is no next song. type !request to get your song on the list.
}

%nexttimer = 1
.timer 1 10 set %nexttimer 0
}
}


on 3:TEXT:!resetsongs:#: {
/remini SongRequests.ini Songs
/remini UserRequests.ini Users
%totalsongs = 0
msg $chan Songlist has been reset.
}


on *:TEXT:!request*:#: {
if ($2- == $null) {
msg $chan Please add a song name $nick
}
elseif ($2- isnum) {
msg $chan You can not request numbers $nick
}
elseif (%totalsongs >= %TotalSongLimit) {
msg $chan The song list is currently full $nick
}
elseif ($len($2-) > %SongLengthLimit) {
msg $chan That song name too long $nick
}
elseif ($countRequest(SongRequests.ini, Songs, $2-) >= %SongRequestLimit) {
msg $chan That song is already on the list $nick
}
elseif ($countRequest(UserRequests.ini, Users, $nick) >= %UserRequestLimit) {
msg $chan You already have a song on the list $nick
}
else {
var %song $2-
writeini -n SongRequests.ini Songs %totalsongs %song
writeini -n UserRequests.ini Users %totalsongs $nick
%totalsongs = $calc(%totalsongs + 1)
msg $chan The song " %song " has been added to the list $nick
}
}


/*
Removes the first song on the list (song currently being played)
*/
on 3:TEXT:!pop:#: {
$removeRequest(SongRequests.ini, Songs, 0)
$removeRequest(UserRequests.ini, Users, 0)

%totalsongs = $calc(%totalsongs - 1)

var %next $readini(SongRequests.ini, n, Songs, 0)
var %user $readini(UserRequests.ini, n, Users, 0)

if (%next == $null) {
msg $chan There are no songs left on the list. Type !request to request a song.
}
else {
msg $chan The next song is " %next " requested by %user
}
}


/*
Removes a target song from the list (takes numbers starting at 1 or takes the song title)
*/
on *:TEXT:!remove*:#: {
if ($nick isop #) {
if ($2- isnum) {
var %index $2-
if (%index < 1 || %index > %totalsongs) {
msg $chan That is not a song's spot on the list $nick
}
elseif (. isin %index) {
msg $chan Don't use decimals $nick
}
else {
var %actualIndex $calc(%index - 1)
var %songname $readini(SongRequests.ini, n, Songs, %actualIndex)
$removeRequest(UserRequests.ini, Users, %actualIndex)
$removeRequest(SongRequests.ini, Songs, %actualIndex)
%totalsongs = $calc(%totalsongs - 1)

msg $chan " %songname " has been removed from the list $nick
}
}
elseif ($2- == $null) {
msg $chan Please use a song number or song title to remove $nick
}
else {
var %index $findNum($2-)

if (%index == -1) {
msg $chan Couldn't find that song $nick
}
else {
$removeRequest(UserRequests.ini, Users, %actualIndex)
$removeRequest(SongRequests.ini, Songs, %index)
%totalsongs = $calc(%totalsongs - 1)
msg $chan " $2- " has been removed from the list $nick
}
}
}
}


on *:TEXT:!change*:#: {
if ($nick isop #) {
if ($2 isnum) {
var %index $2
if (%index < 1 || %index > %totalsongs) {
msg $chan that is not a song's spot on the list $nick
}
elseif (. isin %index) {
msg $chan Don't use decimals $nick
}
else {
var %actualIndex $calc(%index - 1)
var %songname $readini(SongRequests.ini, n, Songs, %actualIndex)
writeini -n SongRequests.ini Songs %actualindex $3-

msg $chan $nick has changed " %songname " has been changed to " $3- "
}
}
}
}


on *:TEXT:!list:#: {
if (%listtimer == 0) {
var %count 0
var %output The song list is
%output = %output $+ $chr(32) $+ $chr(32)

while (%count < %totalsongs) {
var %song $readini(SongRequests.ini, Songs, %count)

if (%count == $calc(%totalsongs - 1)) {
%output = %output $+ %song $+ $chr(46) $+ $chr(32) $+ $chr(32)
}
else {
%output = %output $+ %song $+ $chr(44) $+ $chr(32) $+ $chr(32)
}

%count = $calc(%count + 1)
}

msg $chan %output

%listtimer = 1
.timer 1 10 set %listtimer 0
}
}


alias findNum {
var %count 0
var %target $1

while (%count < %totalsongs) {
var %tempSong $readini(SongRequests.ini, n, Songs, %count)

if (%tempSong == %target) {
return %count
}

%count = $calc(%count + 1)
}

return -1
}


alias countRequest {
var %count 0
var %repeats 0

while (%count < %totalsongs) {
if ($readini($1, n, $2, %count) == $3) {
inc %repeats
}
%count = $calc(%count + 1)
}
return %repeats
}


alias removeRequest {
var %count 0
var %found 0
var %target $3

while (%count < %totalsongs) {
if (%found == 1) {
var %beforeCount $calc(%count - 1)
var %tempsong $readini($1, n, $2, %count)
writeini -n $1 $2 %beforeCount %tempsong
}

if (%count == %target) {
/remini $1 $2 %count
%found = 1
}

%count = $calc(%count + 1)
}

/remini $1 $2 $calc(%count - 1)
}


Also here are the variables I currently have set:
Quote:
%SongLengthLimit 55
%TotalSongLimit 20
%SongRequestLimit 1
%UserRequestLimit 2
%SongsLink http://theherofeed.com/guitar-hero-tv-song-list/

/*DO NOT EDIT BELOW THIS LINE*/
%listtimer 0
%currenttimer 0
%nexttimer 1
%songstimer 0
%totalsongs 2



Any help would be greatly appreciated,

Dex.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Add this before the else {} statement in your !request event:

Code:
elseif (!$read($scriptdirsonglist.txt,nw,$remove($2-,?,*,&))) { msg $chan That song is not in my list $nick }


Then go into the script directory and create a file called songlist.txt with a list of songs. Each line in this file should contain just the name of the song - no other text.

Last edited by hixxy; 10/03/16 09:14 PM.

Link Copied to Clipboard