Jump to content

MTAMA Scripting


Si|ent

Recommended Posts

Montana, I have that !aka script if you want it...

It does a similar function, notes the IP of those who are kicked (not by bad names or ping) and then if they come back after changing their name you can type !aka and it'll list all usernames that were kicked on that IP.

You can just butcher it a bit to log all IDs.

Although, methinks it would get a bit big just using an .ini file...

Link to comment
  • Replies 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

A slightly updated timeban script, featuring:

- Recovering after MTAMA turnoff (Still no unban when MTAMA is off)

- Multiple servers (Last bantime will be the unban on all banned servers)

- Bantimes in secs, mins, hours and days

Insert in mta.start

 .timerunban 0 10 mta.timeunban

Insert in mta.say something equivalent to:

 elseif ($3 == !timeban && %isadmin. [ $+ [ $1 ] $+ . $+ [ $2 ] ] == true) {
   mta.timeban $1-
 }

And to finish it all, insert these method at the bottom of your script:

alias mta.timeban {
 %id = $mta.getid($1,$4)
 %ip = $mta.ip($1, %id)
 %currenttime = $ctime

 if (%id == -1) {
   !return
 }
 %factor_text = $6
 if (%factor_text == sec || %factor_text == s || %factor_text == secs || %factor_text == seconds) {
   %factor = 1
 }
 elseif (%factor_text == min || %factor_text == m || %factor_text == mins || %factor_text == minutes) {
   %factor = 60
 }
 elseif (%factor_text == hour || %factor_text == h || %factor_text == hours) {
   %factor = 3600
 }
 elseif (%factor_text == day || %factor_text == d || %factor_text == hours || %factor_text == uur || %factor_text == uren) {
   %factor = 86400
 }
 elseif (%factor_text == week || %factor_text == w || %factor_text == weeks) {
   %factor = 604800
 }

 %ban_until = $calc(%currenttime + $5 * %factor)
 mta.say $1 $4 has been banned until $asctime(%ban_until)

 %bans = $readini( "MTAbans.ini", bans, ips)
 %bans = $addtok(%bans, $longip(%ip), 32)

 %servers = $readini( "MTAbans.ini", servers, $longip(%ip))
 %servers = $addtok(%servers, $1, 32)

 writeini "MTAbans.ini" bans ips %bans
 writeini "MTAbans.ini" banduration $longip(%ip) %ban_until
 writeini "MTAbans.ini" server $longip(%ip) %servers
 writeini "MTAbans.ini" name $longip(%ip) $mta.name($1,%id)

 mta.ban $1 %id
}

alias mta.timeunban {
 %bans = $readini( "MTAbans.ini", bans, ips)
 %num_bans = $numtok(%bans, 32)
 %currenttime = $ctime
 %counter = 0

 while (%counter < %num_bans) {
   if (%num_bans > 1) {
     %banned = $gettok( %bans , %counter + 1 , 32)
   }
   else {
     %banned = %bans
   }
   if (%banned != $null) {
     %ban_until = $readini( "MTAbans.ini", banduration, %banned )
     if (%ban_until < %currenttime) {
       %servers = $readini( "MTAbans.ini", server, %banned)
       %name   = $readini( "MTAbans.ini", name, %banned)
       %num_servers = $numtok(%servers,32)
       %counter2 = 0
       while (%counter2 < %num_servers) {
         %server = $gettok( %servers , %counter2 + 1 , 32)
         mta.say %server  %name ( $+ $longip(%banned) $+ ) is unbanned (timer)
         mta.unban %server $longip(%banned)
         %counter2 = %counter2 + 1
       }
       %bans = $remtok(%bans, %banned, 32)
       %num_bans = $calc(%num_bans - 1)
       %counter = %counter - 1

       remini "MTAbans.ini" banduration %banned
       remini "MTAbans.ini" server %banned
       remini "MTAbans.ini" name %banned
     }
   }
   %counter = %counter + 1
 }
 if (%bans != $null) {
   writeini "MTAbans.ini" bans ips %bans
 }
 else {
   remini "MTAbans.ini" bans ips
 }
}

(I hope this post is not too long :) )

EDIT: c/p error (space inserted) solved

Edited by Guest
Link to comment

wow harry, thats a long script for what it does :P i did make one like that a week ago or so, storesw the ip's in an ini, then unbans after the secs, mins, hours etc u put in, but i used !tempban instead of timer. Also,

%id = $mta.getid($1,$4)

I dont think you,or anyone, has actually posted the getid script here yet, so i dont think that would work for anyone who hasnt got it in the script, correct me if im wrong on that pls :)

Cube, im not at home atm, so i cant get that script for you, ill post it when i return tomorrow.

Link to comment

Hmm.. i thought Aeron posted that one allready, for those which haven't seen it yet, here it is:


alias mta.getid {
 set %playerid 0
 set %return -1
 if ( $2 == $null ) {
   !return -1
 }
 if ( $2 isnum ) {
   !return $2
 }
 else {
   while ( $mta.maxplayers($1) > %playerid ) {
     if ( $ini( $+ $1 $+ .ini, ID $+ %playerid ) ) {
       if ($mta.name($1, %playerid) == $2) {
         !return %playerid
       }
     }
     %playerid = %playerid + 1
   }
 }
 unset %playerid
 mta.say $1 Unknown player: $2
 !return -1
} 

BTW, the code in my previous post is not working ATM bocause something went wrong c/p it. I'm looking for the error. - EDIT- Solved, i hate spaces

The lenghth is because of the multiple servers, that is giving a lot of problems

Edited by Guest
Link to comment

yeah ive just had a look through it... luckily for me i ONLY ever connect to one at a time as i dont want to run my script on anyone elses server, so my script does for now :) maybe in mtama3 i can connect to more without loading scripts :)

Nice script though harry, i love the sheer amount of variables in it :)

Link to comment

New snippets:

Nick-change detection:

alias mta.join {
 var %a = $read(ips.txt,w,$mta.ip($1,$2) *)
 if (%a != $null) {
   var %a = $gettok(%a,2,32)
   if ($mta.name($1,$2) != %a) {
     mta.say $1 Nick change detected: $+(',$mta.name($1,$2),') is $+(',%a,')
     !write -s $+ $mta.ip($1,$2) ips.txt $mta.ip($1,$2) $mta.name($1,$2)
   }
 }
 else !write ips.txt $mta.ip($1,$2) $mta.name($1,$2)
}

Host-resolving:

alias mta.join {
mta.dns $1 $2
}
alias mta.dns {
 !hadd -m mta.dns $mta.ip($1,$2) $1 $2
 !.dns $mta.ip($1,$2)
}
on *:DNS:{
 !tokenize 32 $hget(mta.dns,$dns(0).ip)
 !hdel mta.dns $dns(0).ip
 if ($1 != $null) {
   mta.log $1 * $mta.name($1,$2) $+ 's host: $dns(0).addr
   ;
 }
}

For the ones that missed the $mta.getid function:

alias mta.getid {
 var %a = 0
 while %a <= $mta.maxplayers($1) {
   if $+(*,$2,*) iswm $mta.name($1,$2) !return %a
   !inc %a
 }
}

This script above in implented in MTA:mA 3.0

Edited by Guest
Link to comment

[OT]

!tokenize 32 $hget(mta.dns,$dns(0).ip)

!hdel mta.dns $dns(0).ip

if $+(*,$2,*) iswm $mta.name($1,$2) !return %a

!inc %a

Wow.. You keep remembering me why i still hate mirc script ;)

[/OT]

For the overall kills/deaths (weren't they inhere somewere?), i couldn't find them with the search.

Insert into mta.kill

 set %kills  $calc($readini("MTAStats.ini",kills,$mta.name( $1 , $3 )) + 1)
 set %deaths $calc($readini("MTAStats.ini",deaths,$mta.name( $1 , $2 )) + 1)
 writeini -n "MTAStats.ini" kills $mta.name( $1 , $3 ) %kills
 writeini -n "MTAStats.ini" deaths $mta.name( $1 , $2 ) %deaths
 unset %kills
 unset %deaths

Insert into somewere else, where you like it (for example in mta.text):

elseif (!3=stat) {
mta.say $1 Overall kills: $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 ))) Deaths: $calc($readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) Ratio:  $round( $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 )) / $readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) , 2) Online: $duration($mta.online($1,$2)) Status: $iif($mta.game($1,$2) == 1,Out Game,In Game)
}

Link to comment

HI,

Why this not working:

[color=green]alias mta.text {
if (!stats iswm $3) { 
   if ($4 isnum) mta.say $1 Name: $mta.name($1,$4) - ID: $4 - Ping: $mta.ping($1,$4) - Kills: $mta.kills($1,$4) - Deaths: $mta.deaths($1,$4) - Overall kills: $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 ))) - Overall Deaths: $calc($readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) - Ratio:  $round( $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 )) / $readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) , 2) - Online: $duration($mta.online($1,$2)) - Status: $iif($mta.status($1,$4) == 1,Out Game,In Game) - IP: $mta.ip($1,$2) 
   else mta.say $1 Name: $mta.name($1,$2) - ID: $2 - Ping: $mta.ping($1,$2) - Kills: $mta.kills($1,$2) - Deaths: $mta.deaths($1,$2) -Overall kills: $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 ))) - Overall Deaths: $calc($readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) - Ratio:  $round( $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $2 )) / $readini("MTAstats.ini",deaths,$mta.name( $1 , $2 ))) , 2) - Online: $duration($mta.online($1,$2)) - Status: $iif($mta.status($1,$4) == 1,Out Game,In Game) - IP: $mta.ip($1,$2)  
 }  [/color]

[code][color=green]alias mta.kill {
 set %kills  $calc($readini("MTAStats.ini",kills,$mta.name( $1 , $3 )) + 1) 
 set %deaths $calc($readini("MTAStats.ini",deaths,$mta.name( $1 , $2 )) + 1) 
 writeini -n "MTAStats.ini" kills $mta.name( $1 , $3 ) %kills 
 writeini -n "MTAStats.ini" deaths $mta.name( $1 , $2 ) %deaths 
 unset %kills 
 unset %deaths
}[/color]

if i write !stats is example: Name: Unknown - Kills: - Deaths: - Ping: - Overall kills: 0 - Overall deaths: 0 - Ratio: 0 - Online: 10 sec - Status: Out game - IP: 192.168.10.98

Why this Name: Unknown - Kills: - Deaths: - Ping: - not working ?? :) [/code]

Link to comment

Upss it up not is scripts lol

if i write !stats is example: Name: Unknown - Kills: - Deaths: - Ping: - Overall kills: 0 - Overall deaths: 0 - Ratio: 0 - Online: 10 sec - Status: Out game - IP: 192.168.10.98

Why this Name: Unknown - Kills: - Deaths: - Ping: - not working ?? :)

Link to comment

some more for u:

!warned script, tells you who in the server has warnings on their name if you are using my warn script.. its easily adaptable to another warn script too:

  elseif ($3 == !warned) {
   unset %warned
   set %countwarned 0
   while (%countwarned < 26 ) {
    if ($readini( "MTAwarn.ini", main, $mta.name( $1, %countwarned ) ) ) {
       %warned = %warned $mta.name($1, %countwarned ) $+ ,
     }
     %countwarned = %countwarned + 1
   }
   if ( %warned == $null ) {
     mta.say $1 No people in the server have been warned.
     }
   else {
     mta.say $1 Warned people: %warned
     }
   unset %warned
   unset %countwarned  
 }

!alarm script, do !alarm and it will tell you when the time is up:

  elseif ( $3 == !alarm ) {
   if ($4 != $null) {
     if ($4 isnum ) {
       if ($5 == mins || $5 == min || $5 == m ) {
         if ($4 == 1) {
           set %alarm $calc( $4 * 60 ) 
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 minute.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
         else {
           set %alarm $calc( $4 * 60 ) 
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 minutes.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
       }
       elseif ($5 == secs || $5 == sec || $5 == s) {
         if ($4 == 1) {
           set %alarm $4 
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 second.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
         else {
           set %alarm $4
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 seconds.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
       }
       elseif ($5 == hours || $5 == hour || $5 == h) {
         if ($4 == 1) {
           set %alarm $calc( $4 * 3600 ) 
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 hour.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
         else {
           set %alarm $calc( $4 * 3600 ) 
           mta.say $1 $mta.name($1,$2) $+ : Alarm activated for $4 hours.
           .timer 1 %alarm mta.say $1 $mta.name($1,$2) $+ : ALARM TIME UP.
           unset %alarm
         }
       }
       else {
         mta.say $1 $mta.name($1,$2) $+ : Error - Specify time format. Syntax - 
       }
     }
     else {
       mta.say $1 $mta.name($1,$2) $+ : Error - Specify time. Syntax - 
     }
   }
   else {
     mta.say $1 $mta.name($1,$2) $+ : Syntax - 
   }
 }

!lagging script. Put in a ping and it returns all the people with pings over that:

  elseif ($3 == !lagging) {
  if ( $4 isnum ) {
   unset %lagging
   set %countlag 0
   while (%countlag < 26 ) {
    if ( $mta.ping($1, %countlag ) > $4 ) {
       %lagging = %lagging $mta.name($1, %countlag ) $+ ,
     }
     %countlag = %countlag + 1
   }
   if ( %lagging == $null ) {
     mta.say $1 No people in the server have an average ping higher than $4
     }
   else {
     mta.say $1 Average pings above $4 $+ : %lagging
     }
   unset %lagging
   unset %countlag
  }
  else {
   mta.say $1 $mta.name($1,$2) $+ : Error - Please specify a ping. Syntax: !lagging 
  }
 }

ive got some more scripts im gonna post here soon, but i want to perfect them first as they still have the occassional error :P

Edit: There was an error on the lagging script which i have now corrected.

Edited by Guest
Link to comment

just do -

Result: $round( $calc($readini("MTAstats.ini",kills,$mta.name( $1 , $mta.getid($1,$4) )) - $readini("MTAstats.ini",deaths,$mta.name( $1 , $mta.getid($1,$4) ))) , 2)

Link to comment

does somebody has a complete script for me ?

whith the following fucntions :

- !stat

- !stats

- !admin

- !info

- !votekick

- !ping

- !kick

kind regards

Link to comment

post multiple messages at specific time intervals and have them loop? Not sure if anything like this exists already but I'd like to have messages displayed every few minutes giving out rules (1 at a time) when my server is up and some general mta information about known problems for newer players. I get tired of explaining these things over and over and tohught it might be useful. If something liek this alrady exsists I aplogize or if anyone has any suggestions it would be appreciated.. Chewd

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...