Jump to content

MTA automessages.


stylo

Recommended Posts

U should name the timer, or on connect, ul get loads of timers running.

.timerspam1 0 600 mta.text $1 bla...
.timerspam2 0 900 mta.text $1 bla...

this way u can only have 1 timer called 'timerspam1'

whereas u can have unlimited 'timer's

Link to comment
Can't you just start and stop the messages with a command?

Sure, but i dont think theres a way to stop individual unnamed timers.

coz as it was b4, everytime u connect, a new timer is started, the old one didnt get stopped.

so u would end up with tons of timers running and eventually loads of messages.

Link to comment
Can't you just start and stop the messages with a command?

Sure, but i dont think theres a way to stop individual unnamed timers.

coz as it was b4, everytime u connect, a new timer is started, the old one didnt get stopped.

so u would end up with tons of timers running and eventually loads of messages.

ahahah

PS the script works fine! its nice, Thnx :)

Link to comment
Can't you just start and stop the messages with a command?

Sure, but i dont think theres a way to stop individual unnamed timers.

coz as it was b4, everytime u connect, a new timer is started, the old one didnt get stopped.

so u would end up with tons of timers running and eventually loads of messages.

Yeah there is a way to stop unnamed timers but it's a bit complicated. Every timer has it's own id, so you'll have to do a loop and check what every timer does and stop the needed one.

Link to comment
Can't you just start and stop the messages with a command?

Sure, but i dont think theres a way to stop individual unnamed timers.

coz as it was b4, everytime u connect, a new timer is started, the old one didnt get stopped.

so u would end up with tons of timers running and eventually loads of messages.

Yeah there is a way to stop unnamed timers but it's a bit complicated. Every timer has it's own id, so you'll have to do a loop and check what every timer does and stop the needed one.

theres no way to know how many unnamed timers there are tho, so ud just have to do a while loop up to some random amount and hope that u got them all, while in the processs of not stopping any other timers.

if u name them then u dont have all this trouble.

Link to comment
there is a way to know how many timers you have ;) $timer(0)

But there is no way to know which unnamed timers are for ur auto messages and which are for other stuff.

its up to u.. dont name them if u dont want to. :roll:

yes you can! :D

if (mta.say* iswm $timer(ID).com) {}

Well yeh you can get anything from a timer, but it's easier to name them

Link to comment

u mean mta.text :P and u know what i mean, even if u use that u still dont know which timers ur stopping.

some of the timers may also be mta.text timers, but not timers for ur auto messages.

we could go on forever here...

/me slaps toady... u know naming them is the best option.

Link to comment
  • 6 months later...

would that work?

on *:SIGNAL:mta.command: { 
  if ($3 == !advert) { 
    if ($mta.level($1,$2) >= 5) { 
      if (!$4) mta.pm $1 $2 Error - Set an advert-Message 
      else { 
        set %advertmsg $4- 
        set %advert 1 
        .timer 1 60 !.signal mta.advert $1 
      } 
    } 
    else mta.pm $1 $2 Error - You need to be level 5 to use this command 
  } 
  elseif ($3 == !stopadvert) { 
    if ($mta.level($1,$2) >= 5) { 
      unset %advert 
      unset %advertmsg 
      mta.text $1 Advert stopped 
    } 
    else mta.pm $1 $2 Error - You need to be level 5 to use this command 
  } 
} 
on *:SIGNAL:mta.advert: { 
  if (%advert == 1) { 
    mta.text %advermsg 
    .timer 1 60 !.signal mta.advert $1 
  } 
} 

Link to comment

This is how I would do it:

on *:SIGNAL:mta.command: { 
  if ($3 == !advert) { 
    if ($mta.level($1,$2) = 5) { 
      if ($4 == $null) mta.pm $1 $2 Error - Set an advert-Message 
      else { 
        mta.text $1 Advert $iif(!timer(mta.advert),changed,added) 
        .timermta.advert 0 60 mta.text $1 $4- 
      } 
    } 
    else mta.pm $1 $2 Error - You need to be level 5 to use this command 
  } 
  elseif ($3 == !stopadvert) { 
    if ($mta.level($1,$2) = 5) { 
      if ($timer(mta.advert)) { 
        .timermta.advert off 
        mta.text $1 Advert stopped 
      } 
      else mta.pm $1 $2 Error - No advert found 
    } 
    else mta.pm $1 $2 Error - You need to be level 5 to use this command 
  } 
}  

I would prefer mine cause you are using a variable, your timer would never stop and your using a signal

And you forgot your $1 at line 24 :wink:

Link to comment

right this is what i come up with :-

you can set as many adverts as you want and they show a random one every 5 mins so it doesnt flood the chat box ;)

let me know how you go on any probs post here.

!addadvert

!startads

!stopads

on *:SIGNAL:mta.command { 
  if ($3 == !addadvert) { 
    if ($mta.level($1,$2) < 5) mta.pm $1 $2 Error: Incorrect Level 
    if ($4 == $null) mta.pm $1 $2 Error: !addadvert <advert> 
    else { 
      if ($mta.level($1,$2) >= 5) {  
        !writeini -n adverts.ini advert $calc($slr.adverts($1) + 1) $4- 
        !writeini -n adverts.ini adverts total $calc($slr.adverts($1) + 1)  
        mta.pm $1 $2 Advert Added Correctly  
      }     
    }     
  } 
  elseif ($3 == !startads) { 
    if ($mta.level($1,$2) < 5) mta.pm $1 $2 Error: Incorrect Level 
    else { 
      !writeini -n adverts.ini adverts ads start 
      .timerads 0 300 slr.advertstime $1-   
    mta.pm $1 $2 Succes In Starting The Ads  
   } 
  } 
  elseif ($3 == !stopads) { 
    if ($mta.level($1,$2) < 5) mta.pm $1 $2 Error: Incorrect Level 
    else { 
      !writeini -n adverts.ini adverts ads stop 
      mta.pm $1 $2 Succes In Stopping The Ads  
    } 
  } 
} 
alias slr.adverts !return $iif($readini(adverts.ini,adverts,total) == $null,0,$v1) 
alias slr.advertstime { 
  var %a = $rand(0,$slr.adverts($1)) 
  var %b = $readini(adverts.ini,adverts,ads) 
  if (%b == start) { 
    mta.text $1 Advert: $readini(adverts.ini,advert,%a) 
  } 
} 

Link to comment
line 4 should start with 'elseif'

also, lines 6 and 10 arent needed. (maybe im just being picky :lol: )

looks fine apart from that. :mrgreen:

tip: u could use $ini(ininame.ini,topic,0) to get the total, which would save writing/storing it.

i aint bothered please say if its wrong i wanna learn more if you are on about mine ?

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...