An mSL version of the SQL version of Mafia Wars on SwiftIRC #mafiawars
;\\\\\\\\\\ STARTUP \\\\\\\\\\
on *:load:{
if (!$exists($pFile)) {
; create the file if it doesn't exist
writeini $pFile startup 0 0
remini $pFile startup
}
if (!%MafiaWars) {
%MafiaWars = $?="Enter the channels you want the bot to use, separated with commas. $crlf $crlf Press OK or Cancel to use all channel default. ( $+ $chr(35) $+ )"
%MafiaWars = $remove(%MafiaWars, $chr(32))
if (!%MafiaWars) %MafiaWars = $chr(35)
}
}
on *:unload:{
if (%MafiaWars) unset %MafiaWars
%MafiaDelete = $?!="Would you like to delete the file and directory? $crlf $crlf This action cannot be undone."
if (%MafiaDelete) rmdir $pDir
}
;\\\\\\\\\\ ALIASES \\\\\\\\\\
alias -l pDir { return Mafia\ }
alias -l pFile { return Mafia\Players.ini }
alias -l isPlayer { }
alias -l pNew { hmake $1 10 }
alias -l pSave { hsave -i $1 $pFile $1 }
alias -l pLoad { hload -i $1 $pFile $1 }
alias -l pDel { hfree -w $+(*,$nick,*) }
alias -l doHighscore {
;$doHighscore(NAME,VAR)
.window -c @hs
.window -h @hs
var %x = $ini($pFile,0)
while (%x) {
var %player = $ini($pFile,%x)
var %stat = $iif($readini($pFile, %player, $2), $v1, $readini($pFile, %player, $1))
aline @hs $+(%player,=,%stat)
dec %x
}
.filter -wwctue 2 61 @hs @hs *=*
return $iif($iif($1 isnum,$gettok($line(@hs,$1),1,61),$ord($fline(@hs,$1 $+ =*))),$v1,NR)
}
alias -l doStats { return .msg # $&
7[5Cash:4 $chr(36) $+ $bytes($hget($1,cash),b) 07[04 $+ $doHighscore($1,Cash) $+ 07]] $&
7[5Exp:4 $bytes($hget($1,exp),b) 07[04 $+ $doHighscore($1,Exp) $+ 7]] $&
7[5Job:4 $iif($hget($1,job) isnum,$duration($hget($1,job)),$hget($1,job)) $+ 7] $&
7[5Pickpocket:4 $iif($hget($1,pickpocket) isnum,$duration($hget($1,pickpocket)),$hget($1,pickpocket)) $+ 7] $&
7[5Deal:4 $iif($hget($1,deal) isnum,$duration($hget($1,deal)),$hget($1,deal)) $+ 7] $&
7[5Fight:4 $iif($hget($1,fight) isnum,$duration($hget($1,fight)),$hget($1,fight)) $+ 7]
$pSave($nick)
}
alias -l doJob {
var %Cash = $r(500,3500)
var %Exp = $r(3,15)
var %Wait = $r(90,300)
hinc $1 Cash %Cash
hinc $1 Exp %Exp
hadd -z $1 Job %Wait
.timer 1 %Wait //hadd $1 Job Ready
return .msg # 7** (4Mafia7)4 $nick 5does a job for the 4Godfather 5and gets $&
7[5Cash: $+(7+04,$chr(36),$bytes(%Cash,b)) $+ 7] $&
7[5Exp: 7+04 $+ $bytes(%Exp,b) $+ 7] $&
7[5Waiting time:4 $duration(%Wait) $+ 7]
$pSave($nick)
}
alias -l doFight {
var %Cash = $r(1500,5000)
var %Exp = $r(10,35)
var %Wait = $r(1800,3600)
var %Foe = $nick(#,$r(1,$nick(#,0)))
hinc $1 Cash %Cash
hinc $1 Exp %Exp
hadd -z $1 Fight %Wait
.timer 1 %Wait //hadd $1 Fight Ready
return .msg # 7** (4Mafia7)4 $nick 5starts a fight with4 %Foe 5and gets $&
7[5Cash: $+(7+04,$chr(36),$bytes(%Cash,b)) $+ 7] $&
7[5Exp: 7+04 $+ $bytes(%Exp,b) $+ 7] $&
7[5Waiting time:4 $duration(%Wait) $+ 7]
$pSave($nick)
}
alias -l doPickpocket {
var %Cash = $r(1000,4000)
var %Exp = $r(3,10)
var %Wait = $r(90,300)
var %Mafia = Triads.Yakuza.Italian Mafia.Mexican Mafia.New York Mafia.Russian Mafia.Columbian Cartel.Isreili Mafia.Serbian Mafia.Albanian Mafia
var %PP = $gettok(%Mafia,$r(1,$numtok(%Mafia,46)),46)
hinc $1 Cash %Cash
hinc $1 Exp %Exp
hadd -z $1 Pickpocket %Wait
.timer 1 %Wait //hadd $1 Pickpocket Ready
return .msg # 7** (4Mafia7)4 $nick 5steals from the4 %PP 5and gets $&
7[5Cash: $+(7+04,$chr(36),$bytes(%Cash,b)) $+ 7] $&
7[5Exp: 7+04 $+ $bytes(%Exp,b) $+ 7] $&
7[5Waiting time:4 $duration(%Wait) $+ 7]
$pSave($nick)
}
alias -l doDeal {
var %Drugs = Booze.Tobacco.Marijuana.Cough Syrup.Meth.Cocaine.LSD.DMT.Roofies.Mushrooms.Peyote.Ketamine.Ecstasy.Oxycodone.Salvia.Hash.Opium
var %Drug = $gettok(%Drugs,$r(1,$numtok(%Drugs,46)),46)
var %Cash = $floor($calc($r(100,250) * $findtok(%Drugs,%Drug,46) * (1 + $hget($1,exp) / 100))))
var %Exp = $r(10,30)
var %Wait = $r(1800,3600)
hinc $1 Cash %Cash
hinc $1 Exp %Exp
hadd -z $1 Deal %Wait
.timer 1 %Wait //hadd $1 Deal Ready
return .msg # 7** (4Mafia7)4 $nick 5quickly deals some4 %Drug 5on the streets and gets $&
7[5Cash: $+(7+04,$chr(36),$bytes(%Cash,b)) $+ 7] $&
7[5Exp: 7+04 $+ $bytes(%Exp,b) $+ 7] $&
7[5Waiting time:4 $duration(%Wait) $+ 7]
$pSave($nick)
}
;\\\\\\\\\\ EVENTS \\\\\\\\\\
on *:join:%MafiaWars:{
if ($nick != $me) .notice $nick 4Welcome to7 # $+ 4,7 $nick $+ 4. I am7 $me 4and if you would like to play7 Mafia Wars4, type7 !help 4for a list of commands.
if (!$ini($pFile,$nick)) {
$pNew($nick)
}
elseif (!$hget($nick)) {
$pNew($nick)
$pLoad($nick)
}
else halt
$pSave($nick)
}
on *:part:%MafiaWars:{
if ($hget($nick)) $pSave($nick)
}
on *:nick:%MafiaWars:{
if !$ini($pFile,$nick) {
$pNew($nick)
}
else {
$pNew($nick)
$pLoad($nick)
}
$pSave
}
on *:text:!help:%MafiaWars:{
.notice $nick 7My commands are:4 !fight7, 4!pickpocket7, 4!job7, 4!deal7, and 4!stats7.
}
on *:text:!job:%MafiaWars:{
if !$ini($pFile,$nick) || !$hget($nick) { $pNew($nick) }
if $hget($nick,Job) isnum {
.notice $nick 7** (4Mafia7) 5You still have to wait4 $duration($hget($nick,Job)) 5before you can use this command again.
halt
}
else {
$doJob($nick)
$doStats($nick)
}
$pSave($nick)
}
on *:text:!fight:%MafiaWars:{
if !$ini($pFile,$nick) || !$hget($nick) { $pNew($nick) }
if $hget($nick,Fight) isnum {
.notice $nick 7** (4Mafia7) 5You still have to wait4 $duration($hget($nick,Fight)) 5before you can use this command again.
halt
}
else {
$doFight($nick)
$doStats($nick)
}
$pSave($nick)
}
on *:text:!pickpocket:%MafiaWars:{
if !$ini($pFile,$nick) || !$hget($nick) { $pNew($nick) }
if $hget($nick,Pickpocket) isnum {
.notice $nick 7** (4Mafia7) 5You still have to wait4 $duration($hget($nick,Pickpocket)) 5before you can use this command again.
halt
}
else {
$doPickpocket($nick)
$doStats($nick)
}
$pSave($nick)
}
on *:text:!deal:%MafiaWars:{
if !$ini($pFile,$nick) || !$hget($nick) { $pNew($nick) }
if $hget($nick,Deal) isnum {
.notice $nick 7** (4Mafia7) 5You still have to wait4 $duration($hget($nick,Deal)) 5before you can use this command again.
halt
}
else {
$doDeal($nick)
$doStats($nick)
}
$pSave($nick)
}
on *:text:!stats:%MafiaWars:{ $doStats($nick) }
on *:text:!hs*:%MafiaWars:{
if ($2) .msg # $+(4,$ini($pFile,$ini($pFile,$2))) 5is ranked7 $doHighscore($2,$3) 5in4 $3 5with7 $&
$bytes($gettok($line(@hs,$fline(@hs,$2 $+ =*)),2,61)),b) $+ 5.
}
keeps telling me that table exists for the nick..... -_-
if !$ini($pFile,$nick) || !$hget($nick) { $pNew($nick) }
this line is borked all over.....
thats the same code on all of those lines.......
Thanks for bringing up an old post that I forgot I even had.. but anyway I have updated a lot of it and there shouldn't be too much of an issue now. I'm still trying to fix the highscore table, but it's still usable.