Top

Gangster RPG


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  9.0 (of 4 scores)
Date Added  Nov 26, 2008
Last Updated  Nov 27, 2008
Tags  bot  game  gang  roleplay  rpg 

Introduction

I finally finished the shell for the Gangster Bot Purcell had asked for. I've added a few little snippets in there for easy addition of items. You are free to use this bot as you wish, but please give credit where credit is due. This was created from scratch, 100% by me.

Enjoy.

Grab the Code

on *:load:{
  .write gangster.txt 0
}
 
on *:connect:{
  var %x 0
  var %y $read(gangster.txt,-1)
  while %x < %y {
    hload -si $gettok($read(gangster.txt,%y),1,32) gangster.ini $gettok($read(gangster.txt,%y),1,32)
    inc %x
  }
}
 
on *:text:.gangster*:?:{
  if !$2 || !$3 || $2 !isalnum || $3 !isalnum {
    .notice $nick .gangster <name> <password>
  }
  if $gettok($read(gangster.txt,w,$2),2,32) !== $null {
    .msg # That name has been taken.
    halt
  }
  else {
    hmake $nick
    hadd $nick name $2
    hadd $nick pass $3
    hadd $nick cash 1000
    hadd $nick atk 5
    hadd $nick def 5
    hadd $nick atk_mod 0
    hadd $nick def_mod 0
    hadd $nick points 0
    hadd $nick level 1
    hsave -i $nick gangster.ini $hget($nick,name)
    write -l1 gangster.txt $calc($read(gangster.txt,-1) + 1)
    write gangster.txt $nick $2
    .msg # Welcome to Gangsters, $2 $+($chr(40),$nick,$chr(41))
    .notice $nick Type .help for a list of commands.
    stats
  }
}
 
on *:text:.crime*:#:{
  if !$hget($nick) {
    .notice $nick .gangster <name> <password>
    halt
  }
  if $hget($nick,jail) {
    .notice $nick You cannot do that while in jail.
    halt
  }
  else {
    if !$2 {
      .notice $nick Crimes: mug; carjack;
    }
    if $2 = mug {
      if !$hfind($nick,mugging) {
        var %x $rand(100,300)
        var %cash $calc($hget($nick,cash) + %x)
        hadd $nick cash %cash
        hadd -z $nick mugging 60
        .msg # $hget($nick,name) mugs an unsuspecting pedestrian for $+($chr(36),$bytes(%x,b),.)
        .notice $nick Total Cash: $+($chr(36),$bytes($hget($nick,cash),b))
      }
      else {
        .notice $nick You have to wait $+($duration($hget($nick,mugging),3),.)
        halt
      }
    }
    if $2 = carjack {
      if !$hfind($nick,carjack) {
        var %x $rand(0,100)
        if %x <= 20 {
          .msg # $hget($nick,name) finds an unlocked car. They proceed to hotwire the car and drive away.
          .notice $nick You have obtained 1 car.
          hadd $nick cars $calc($hget($nick,cars) + 1)
          var %carjack $rand(60,180)
          hadd -z $nick carjack %carjack
        }
        if %x > 20 && %x <= 50 {
          var %jail.time $rand(60,300)
          .msg # $hget($nick,name) was caught trying to steal a car and is sent to jail for $+($duration(%jail.time,3),.)
          hadd -z $nick jail %jail.time
          var %carjack $rand(60,180)
          hadd -z $nick carjack %carjack
        }
        if %x > 50 && %x <= 100 {
          var %cash $rand(500,2000)
          .msg # $hget($nick,name) finds a car and breaks into it. Taking it to a local chop shop, $hget($nick,name) gets $+($chr(36),$bytes(%cash,b),.)
          hadd $nick cash $calc($hget($nick,cash) + %cash)
          var %carjack $rand(60,180)
          hadd -z $nick carjack %carjack
          .notice $nick Total cash: $+($chr(36),$bytes($hget($nick,cash),b))
        }
        hsave -i $nick gangster.ini $hget($nick,name)
      }
      else {
        .notice $nick You have to wait $+($duration($hget($nick,carjack),3),.)
        halt
      }
    }
  }
}
 
on *:text:.buy*:#:{
  if !$hget($nick) {
    .notice $nick .gangster <name> <password>
    halt
  }
  if $hget($nick,jail) {
    .notice $nick You cannot do that while in jail.
    halt
  }
  else {
    if !$2 {
      ;//Edit these to your liking.
      .notice $nick Shops: Armor;  Weapon;  Car;
      halt
    }
    if $2 = armor {
      ;//ITEM_NAME [ITEM_HASH] PRICE
      ;//I did it this way so you can show what the item is, and have something
      ;//to put in the hash table without spamming it.
      .notice $nick Armors: Bulletproof Vest [bpvest] $+($chr(36),500,;)
    }
    if $2 = weapon {
      .notice $nick Weapons: Machette [machette] $+($chr(36),500,;) - Glock [glock] $+($chr(36),750,;)
    }
    if $2 = car {
      .notice $nick Cars: Rolls Royce [rolls] $+($chr(36),$bytes(10000,b),;)
    }
    if $2 !isnum {
      .notice $nick .buy <num> <item>
      halt
    }
 
    /*
    This is the template you can use to make new items.
    Just change anything that says CHANGE_ME.
 
    if $2 isnum && $3 = CHANGE_ME {
      var %cash $calc($2 * CHANGE_ME)
      if $hget($nick,cash) >= %cash {
        hadd $nick cash $calc($hget($nick,cash) - %cash)
        hadd $nick CHANGE_ME $calc($hget($nick,CHANGE_ME) + $2)
        hadd $nick def_mod $calc($hget($nick,def_mod) + (CHANGE_ME * $2))
        hadd $nick atk_mod $calc($hget($nick,atk_mod) + (CHANGE_ME * $2))
        .msg # $nick buys $2 CHANGE_ME.
      }
    }
    */
 
    ;########### ARMORS ###########
 
    if $2 isnum && $3 = bpvest {
      var %cash $calc($2 * 500)
      if $hget($nick,cash) >= %cash {
        hadd $nick cash $calc($hget($nick,cash) - %cash)
        hadd $nick bp_vest $calc($hget($nick,bp_vest) + $2)
        hadd $nick def_mod $calc($hget($nick,def_mod) + (2 * $2))
        hadd $nick atk_mod $calc($hget($nick,atk_mod) + (1 * $2))
        .msg # $nick buys $2 Bulletproof Vest.
      }
    }
 
    ;########### WEAPONS ###########
 
    if $2 isnum && $3 = machette {
      var %cash $calc($2 * 500)
      if $hget($nick,cash) >= %cash {
        hadd $nick cash $calc($hget($nick,cash) - %cash)
        hadd $nick machette $calc($hget($nick,machette) + $2)
        hadd $nick def_mod $calc($hget($nick,def_mod) + (1 * $2))
        hadd $nick atk_mod $calc($hget($nick,atk_mod) + (3 * $2))
        .msg # $nick buys $2 Machette.
      }
    }
    if $2 isnum && $3 = glock {
      var %cash $calc($2 * 750)
      if $hget($nick,cash) >= %cash {
        hadd $nick cash $calc($hget($nick,cash) - %cash)
        hadd $nick glock $calc($hget($nick,glock) + $2)
        hadd $nick def_mod $calc($hget($nick,def_mod) + (2 * $2))
        hadd $nick atk_mod $calc($hget($nick,atk_mod) + (4 * $2))
        .msg # $nick buys $2 Glock.
      }
    }
 
    ;########### CARS ###########
 
    if $2 isnum && $3 = rolls {
      var %cash $calc($2 * 10000)
      if $hget($nick,cash) >= %cash {
        hadd $nick cash $calc($hget($nick,cash) - %cash)
        hadd $nick rolls $calc($hget($nick,rolls) + $2)
        hadd $nick def_mod $calc($hget($nick,def_mod) + (10 * $2))
        hadd $nick atk_mod $calc($hget($nick,atk_mod) + (13 * $2))
        .msg # $nick buys $2 Rolls Royce.
      }
    }
 
    ;########### END ###########
    hsave -i $nick gangster.ini $hget($nick,name)
  }
}
 
on *:text:.attack*:#:{
  if !$hget($nick) {
    .notice $nick .gangster <name> <password>
    halt
  }
  if $hget($nick,jail) {
    .notice $nick You cannot do that while in jail.
    halt
  }
  if $hget($nick,attack) {
    halt
  }
  if !$2 || !$gettok($read(gangster.txt,w,$+(*,$2)),2,32) {
    .notice $nick .attack <name>
    halt
  }
  else {
    var %def $gettok($read(gangster.txt,w,$+(*,$2)),1,32)
    var %atk.calc $calc(($hget($nick,atk) * $hget($nick,def)) + ($hget($nick,atk_mod) * $hget($nick,def_mod)) + ($hget($nick,level) * 1.5)) * $+(1.,$rand(1,9)))
    var %def.calc $calc((($hget(%def,atk) * $hget(%def,def)) + ($hget(%def,atk_mod) * $hget(%def,def_mod)) + ($hget(%def,level) * 1.5)) * $+(1.,$rand(1,9)))
    hadd -z $nick attack 10
    if %atk.calc > %def.calc {
      var %a $hget(%def,cash)
      var %b $floor($rand($calc(%a/2),%a))
      hadd %def cash $calc($hget(%def,cash) - %b)
      hadd $nick cash $calc($hget($nick,cash) + %b)
      .msg # $hget($nick,name) defeats $hget(%def,name) in battle, stealing $+($chr(36),$bytes(%b,b),.)
    }
    else {
      var %c $hget($nick,cash)
      var %d $floor($rand($calc(%c/2),%c))
      hadd $nick cash $calc($hget($nick,cash) - %d)
      hadd %def cash $calc($hget(%def,cash) + %d)
      .msg # $hget(%def,name) defeats $hget($nick,name) in battle, stealing $+($chr(36),$bytes(%d,b),.)
    }
  }
}
 
on *:text:.stats:#:{
  if !$hget($nick) {
    .notice $nick .gangster <name> <password>
    halt
  }
  else {
    stats
  }
}
 
on *:text:.help:#:{
  if !$2 {
    .notice $nick .gangster; .crime; .buy; .stats;
  }
}
 
alias stats {
  .notice $nick [Level: $+($hget($nick,level),]) [Cash: $+($chr(36),$bytes($hget($nick,cash),b),]) $&
    [Attack: $+($hget($nick,atk),]) [Defense: $+($hget($nick,def),]) [Points: $+($hget($nick,points),]) $&
    [Attack Bonus: $+($hget($nick,atk_mod),]) [Defense Bonus: $+($hget($nick,def_mod),])
}

Comments

  (16)  RSS
`JoKeR´
Comments: 14
 
mIRC Snippet:  Gangster RPG
Posted on Nov 26, 2008 9:43 pm
Comments and suggestions welcome as always. Constructive criticism encouraged, but inappropriate and rude comments will be deleted.

Ratings are always nice too. :)
`JoKeR´
Comments: 14
 
mIRC Snippet:  Gangster RPG
Posted on Nov 27, 2008 9:26 am
Changed from channel to message for .gangster command.
Kasbah
Comments: 18
 
mIRC Snippet:  Gangster RPG
Posted on Nov 29, 2008 9:13 am
Great script `JoKeR´
I really like the way you use hash tables and just reading through is so cool, and makes understanding hash tables so much easier. Thank you for sharing :-)

Purcell:
See I'm editing my last post ;)
Not to sure with hash tables or how others will do it, just going through quickly I would do summin like
Code:
 if ($nick isop $chan) || ($nick === YourExactNickname) {
    if ($1 == !bust) {
      if (!$2) { .notice $nick Syntax: !bust nick | halt }
      hadd $2 jail 0
    }
  }

But not sure how what other ways there are to do this unless you set a variable to 1 and use hadd -z $2 jail %variablename - but that will totally unset it *shrugs* - Trial and error I guess hey ;)
`JoKeR´
Comments: 14
 
mIRC Snippet:  Gangster RPG
Posted on Nov 29, 2008 12:36 pm
Kasbah, thanks for the comment. Hash tables are easy once you figure out how they work and get over the intimidation they present with their own set of identifiers and aliases. It also seems you don't understand how the -z switch works, which is okay. The -z switch will unset your item after <item> seconds. So doing:
Code:
hadd -z $nick jail 10
would be in lamens terms: add jail to $nick for 10 seconds, then delete.
Kasbah
Comments: 18
 
mIRC Snippet:  Gangster RPG
Posted on Nov 29, 2008 2:59 pm
Quote:
It also seems you don't understand how the -z switch works

I sort of know how the -z switch works I read the help file lol, was just one idea to set jail to 0 but the -z switch unsets it so wasn't sure if you still needed it to be set or not, the above example was just answering Purcell's question.
Otherwise I would have done it like this, which would decrease and unset in 1 second:
Code:
var %temp 1
hadd -z $2 jail %temp

Instead of
Code:
hadd $2 jail 0


Purcell: I looked at the hash table help file for the first time ever today, so no I cannot help you as I am not skeeled enough, please Read the help file dude and please don't flood, if you have something to say and think of something later on to say, click EDIT and add what you wanted to say with your previous post.
`JoKeR´
Comments: 14
 
mIRC Snippet:  Gangster RPG
Posted on Nov 29, 2008 5:30 pm
You wouldn't want to do hadd $2 jail 0 because it would basically forever set jail to 0 until otherwise stated. The code looks to make sure that there is no "jail" in table "$nick", so instead of setting jail to 0, you would want to remove jail from the table using
Code:
hdel $2 jail
Purcell
Comments: 37
 
mIRC Snippet:  Gangster RPG
Posted on Nov 30, 2008 9:00 am
I wanne set: if u kil any u need wait 10 - 15mins to the next

can any set .attack script here with that if u kill 1 u need kill 10 - 15 mins for the next ? thx



Srry for the begin jonesy44!
Cold_Fussion
Comments: 39
 
mIRC Snippet:  Gangster RPG
Posted on Dec 26, 2008 8:47 am
i like the code... great use of hash tables... i have made a huge update for it... but one problem...
.attack name gives me this error, * Invalid format: $floor
this is the code unchanged from urs ...
var %b $floor($rand($calc(%a / 2),%a))
var %d $floor($rand($calc(%c / 2),%c))
how can it be fixed thanks... ill paste the update full version as soon as its fixed
Cold_Fussion
Comments: 39
 
mIRC Snippet:  Gangster RPG
Posted on Dec 26, 2008 8:52 am
oh one more thing, i have made a top10 gangster lvl list and i have made it so it keeps the lvl money so on... changed commands !login added and it checks to see no clones so on... im a self taaught coder for about 4 months and thriving...
Purcell
Comments: 37
 
mIRC Snippet:  Gangster RPG
Posted on Dec 28, 2008 1:46 pm
Col_fussion,
var %b $floor($rand($calc(%a/2),%a))
normal it works!
Purcell
Comments: 37
 
mIRC Snippet:  Gangster RPG
Posted on Jan 1, 2009 6:15 pm
Cold_Fussion, can u post the Top and login script ?
Cold_Fussion
Comments: 39
 
mIRC Snippet:  Gangster RPG
Posted on Feb 9, 2009 4:32 pm
oops forgot about it, will post what ive redone so far


on *:QUIT: {
if ($chan == #gangsters) {
writeini gangsters\ $+ $nick $+ .ini $nick logged 0
msg #gangsters 7 $+ $nick $+ 10,3 $getinfo($nick,gangster) 10is now offline.
if (%login == $nick) {
unset %login
}
}
}
on *:PART:#gangsters: {
msg #gangsters 7 $+ $nick $+ 10,3 $getinfo($nick,gangster) 10is now offline.
writeini gangsters\ $+ $nick $+ .ini $nick logged 0
if (%login == $nick) {
unset %login
}
}
on *:text:!play:#: {
%checkifexist = $exists($mircdir\gangsters\ $+ $nick $+ .ini)
if (%checkifexist == $true) {
if (%login == $null) {
set %login $nick
msg $nick type .login password
mode # +v $nick
halt
}
if (%login != $null) {
msg # $nick plz be patient as %login is busy logging in
halt
}
}
else {
msg $nick type .register gangster-name password
}
}
on *:text:start:?: {
msg $nick type .register gangster-name password or .login password to start
}
on *:text:.login*:?: {
set %loginattempt $getinfo($nick,pass)
if ($getinfo($nick,logged) == 1) { msg $nick Already Logged in | halt }
if (%login != $nick) {
msg $nick plz type !play in the main channel
halt
}
if (($nick == %login) && ($2 == %loginattempt)) {
unset %login
msg #gangsters 7 $+ $nick $+ 10,3 $getinfo($nick,gangster) 10is now online. (3Level: $getinfo($nick,level)) $+ 10) ( $+ $server $+ )
writeini gangsters\ $+ $nick $+ .ini $nick logged 1
msg $nick 7Welcome To Gangsters v1.0
halt
}
if ((%login == $nick) && ($2 != %loginattempt)) {
msg $nick password incorrect
halt
}
}
on *:connect:{
var %x 0
var %y $read(gangster.txt,-1)
while %x < %y {
hload -si $gettok($read(gangster.txt,%y),1,32) gangster.ini $gettok($read(gangster.txt,%y),1,32)
inc %x
}
}

on *:text:.register*:?: {
%checkifexist = $exists($mircdir\gangsters\ $+ $nick $+ .ini)
if (%checkifexist == $true) {
.notice $nick you have a gangter already, $getinfo($nick,gangster)
halt
}
if !$2 || !$3 || $2 !isalnum || $3 !isalnum {
.notice $nick .register <gangster> <password>
}
if $gettok($read(gangster.txt,w,$2),2,32) !== $null {
.msg # That name has been taken.
halt
}
else {
writeini gangsters\ $+ $nick $+ .ini $nick Gangster $2
writeini gangsters\ $+ $nick $+ .ini $nick pass $3
writeini gangsters\ $+ $nick $+ .ini $nick cash 1000
writeini gangsters\ $+ $nick $+ .ini $nick atk 5
writeini gangsters\ $+ $nick $+ .ini $nick def 5
writeini gangsters\ $+ $nick $+ .ini $nick atk_mod 0
writeini gangsters\ $+ $nick $+ .ini $nick def_mod 0
writeini gangsters\ $+ $nick $+ .ini $nick points 0
writeini gangsters\ $+ $nick $+ .ini $nick level 1
write -l1 gangster.txt $calc($read(gangster.txt,-1) + 1)
write gangster.txt $nick $2
msg #gangsters Welcome to Gangsters, $2 $+($chr(40),$nick,$chr(41))
mode #gangsters +v $nick
writeini gangsters\ $+ $nick $+ .ini $nick logged 1
msg #gangsters 7 $+ $nick $+ 10,3 $getinfo($nick,gangster) 10is now online. (3Level: $getinfo($nick,level)) $+ 10) ( $+ $server $+ )
msg $nick Type .help for a list of commands.
msg $nick 7Welcome To Gangsters v1.0
}
}
kyle
Comments: 2
 
mIRC Snippet:  Gangster RPG
Posted on Feb 10, 2009 4:31 pm
how do you work it
VinX
Comments: 56
 
mIRC Snippet:  Gangster RPG
Posted on Aug 2, 2009 9:00 am
@kyle ... just load the script in u r BOT by pressing Alt+R and then type .help


@Joker

Sweet script :)) I love it .. kinda addicted
Xaric
Comments: 14
 
mIRC Snippet:  Gangster RPG
Posted on Aug 2, 2009 5:42 pm
is there an update version with more weapons etc?
Ghost-writer
Comments: 256
 
mIRC Snippet:  Gangster RPG
Posted on Aug 23, 2009 10:04 am
I made a script excatly like this but with a little bit more stuff and no jail and everyone said that yours is like it, But i look and find out this has been here for a few months now how the hell did i NOT see it. lol :|.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom