Jump to content

MTA:MA Scripting


Harry

Recommended Posts

  • Replies 357
  • Created
  • Last Reply

Top Posters In This Topic

i hope this thread is betterit was annoying when i asked for a script and ppl tell me to look at mtamt ascripting thread. how the hell am i gonna look thru 70 pages of crap.

anyway, ive got a script that im about to quote that was never thought about or nuthing

ok this is nothing to do with ur conversation at all but it is a script suggestion.

could u make a DM script? now that does sound stupid, but i'll explain.

there is a 30min time limit. the scoreboard is reset before hand. ppl kill, mtama monitors it like the scoreboard. at the end of the round there is a 'champ', who got the most kills and every1 is slapped to death for the next round, and scores reset. the 'champ' gets a 'champ point' for winning the round. in the next round, the name of the champ is randomly spammed (just to give him sum glory). and after say...2hrs the person with the most 'champ points' wins the...ermm.. the...set? ok so the champ points idea isnt realy needed, but i reckon this will give thecurrent gamemode a much better, and fun effect. ty

Link to comment

Deathmatch script, thx for ur help Oli :D

Notes:

elseif $findtok(xcr talidan,$mta.name($1,$2),1,32) { 

If u want to add more admins, seperate them with a space, as shown above.

*/
Deathmatch Script by XcR, idea by Talidan.       
Please do not extract code without asking the author.               
This script is free to use and distribute.                           
Special thanks: Talidan for the idea, [uVA]_ZzZ, [FMJ]Oli and the MTA team for their mod.
*/
on *:SIGNAL:mta.join:{
 !.timer 1 0 mta.msg $1 $2 $mta.name($1,$2) $+ , the server is currently running the Timed Deathmatch script.
 !.timer 1 1 mta.msg $1 $2 Type !rules for more info.
}
on *:SIGNAL:mta.command:{
 if $3 == !rules {
   !.timer 1 0 mta.say $1 DEATHMATCH SCRiPT RULES
   !.timer 1 1 mta.say $1 No glitching/cheating/modding/helikilling/spawnkilling/carkilling.
 }
 elseif $3 == !info mta.say $1 Deathmatch Script by XcR, idea by Talidan.
 ;put in any names u want here... seperate with a space
 elseif $findtok(xcr talidan,$mta.name($1,$2),1,32) {
   if $3 == !start { mta.roundstart $1- }
   elseif $3 == !stop { mta.gamefinish $1- }
 }
}
alias mta.roundend {
 var %e = $readini(roundsdone.ini,done,done)
 !.timer 1 0 mta.say $1 Deathmatch script > Time limit of round %e is up!
 !.timer 1 1 mta.topscore $1-
 !.timer 1 2 mta.say $1 Everyone now must respawn - round is over.
 !.timer 1 3 mta.kill1 $1-
 !writeini roundsdone.ini done done $calc(%e + 1)
 if %e == 3 { mta.gamefinish $1- }
}
alias mta.topscore {
 var %a = 0,%b = 0,%c = 0
 var %d = $readini(champ.ini,champpoints,$mta.name($1,%a))
 while %a < 26 {
   if $mta.score($1,%a) > %b { %b = $mta.score($1,%a) | %c = $mta.name($1,%a) }
   !inc %a
   !return The top scorer is %c with %b points! 
 }
 !writeini champ.ini champpoints %c $calc(%d + 1)
 !writeini champ.ini score %c %b
 !.timer 5 60 mta.say $1 The champ of the last round was %c $+ , with a score of %b $+ !
 mta.roundstart $1-
}
alias mta.kill1 {
 var %a = 0
 while %a < 26 {
   if $mta.health($1,%a) > 0 { mta.slap $1 %a }
   !inc %a
 }
}
alias mta.roundstart {
 var %e = $readini(roundsdone.ini,done,done)
 !writeini roundsdone.ini done done 1
 mta.say $1 Deathmatch round ' $+ %e $+ ' started.
 !.timer 1 1800 mta.roundend $1-
 mta.resetscores $1-
}
alias mta.gamefinish {
 var %a = 0,%b = 0,%c = 0
 var %d = $readini(champ.ini,champpoints,$mta.name($1,%a))
 while %a < 26 {
   if %d > %b { %b = %d | %c = $mta.name($1,%a) }
   !inc %a
   !return Deathmatch gamemode script ended: the winner of the game was %c with a champion score of %d $+ ! 
 }
 !.timer* off
} 

Edited by Guest
Link to comment

omg:

if u want to use more than one, seperate them with || eg

elseif $mta.name($1,$2) == XcR || $mta.name($1,$2) == Talidan { 

ouch :P

instead:

if u want to use more than one, use $findtok(), EG:

elseif $findtok(xcr talidan,$mta.name($1,$2),1,32) { 

And here is the script debugged as far as i can see. There were some bracket mismatches and some var sets which wernt needed:

(Note, there is a !timer* off in this script... this could cause MTA:mA to time out, depends on aerons timer methods. It could mess up GRS's Global ping system and pingkicker aswell, if ure using it, although GRS does have a timer check system, so it would prob be ok :))

*/ 
Deathmatch Script by XcR, idea by Talidan.       
Please do not extract code without asking the author.               
This script is free to use and distribute.                           
Special thanks: Talidan for the idea, MTA team for their mod, and [uVA]_ZzZ. 
*/ 
on *:SIGNAL:mta.join:{ 
 !.timer 1 0 mta.msg $1 $2 $mta.name($1,$2) $+ , the server is currently running the Timed Deathmatch script. 
 !.timer 1 1 mta.msg $1 $2 Type !rules for more info. 
} 
on *:SIGNAL:mta.command:{ 
 if $3 == !rules { 
   !.timer 1 0 mta.say $1 DEATHMATCH SCRiPT RULES 
   !.timer 1 1 mta.say $1 No glitching/cheating/modding/helikilling/spawnkilling/carkilling. 
 } 
 elseif $3 == !info mta.say $1 Deathmatch Script by XcR, idea by Talidan. 
 ;put in any names u want here... seperate with a space
 elseif $findtok(xcr talidan,$mta.name($1,$2),1,32) {
   if $3 == !start { mta.roundstart $1- } 
   elseif $3 == !stop { mta.gamefinish $1- } 
 } 
} 
alias mta.roundend { 
 var %e = $readini(roundsdone.ini,done,done) 
 !.timer 1 0 mta.say $1 Deathmatch script > Time limit of round %e is up! 
 !.timer 1 1 mta.topscore $1- 
 !.timer 1 2 mta.say $1 Everyone now must respawn - round is over. 
 !.timer 1 3 mta.kill1 $1- 
 !writeini roundsdone.ini done done $calc(%e + 1) 
 if %e == 3 { mta.gamefinish $1- } 
} 
alias mta.topscore { 
 var %a = 0,%b = 0,%c = 0 
 var %d = $readini(champ.ini,champpoints,$mta.name($1,%a)) 
 while %a < 26 { 
   if $mta.score($1,%a) > %b { %b = $mta.score($1,%a) | %c = $mta.name($1,%a) } 
   !inc %a 
   !return The top scorer is %c with %b points!  
 } 
 !writeini champ.ini champpoints %c $calc(%d + 1) 
 !writeini champ.ini score %c %b 
 !.timer 5 60 mta.say $1 The champ of the last round was %c $+ , with a score of %b $+ ! 
 mta.roundstart $1- 
} 
alias mta.kill1 { 
 var %a = 0 
 while %a < 26 { 
   if $mta.health($1,%a) > 0 { mta.slap $1 %a }
   !inc %a
 }
} 
alias mta.roundstart { 
 var %e = $readini(roundsdone.ini,done,done) 
 !writeini roundsdone.ini done done 1 
 mta.say $1 Deathmatch round ' $+ %e $+ ' started. 
 !.timer 1 1800 mta.roundend $1- 
 mta.resetscores $1- 
} 
alias mta.gamefinish { 
 var %a = 0,%b = 0,%c = 0 
 var %d = $readini(champ.ini,champpoints,$mta.name($1,%a)) 
 while %a < 26 { 
   if %d > %b { %b = %d | %c = $mta.name($1,%a) } 
   !inc %a 
   !return Deathmatch gamemode script ended: the winner of the game was %c with a champion score of %d $+ !  
 } 
 !.timer* off 
}  

Dan, '=' is when ure setting something to something else, ie:

%b = 1 - sets %b to 1

%b == 1 - if %b equals 1 then do { }

%b === 1 - if case sensitive %b equals 1 then do { }

Link to comment

/me slaps someone with $findtokcs()

[What a nice trick oli I wonder from who you got it :)]

A general rule for if statements:

Now i see that most scripters use.

if expression1 operator expression2 commands

Notice the missing ()

I recommand you all to use the () so it doesn't mess up the condition and it even speeds up the evaluation.

if (expression1 operator expression2) command(s)

Multiple expressions should be:

if ((expression1 operator expression2) && (expression3 operator expression4)) command(s)

Khaled has plans to to change it to wotk with () only, so it greatly speeds up his script handeler.

Also since 6.16 $v1, $v2 work:

That means: $v1 returns expression1, $v2 returns expression2 and so on from the latest if statement.

And dont kill my MTA:mA timers :)

Link to comment

I had needed a script wich slap everyone spawn (an example) at robber and mexican. I had asked to oli this script (in msn).

He had sended to me this:

on *:SIGNAL:mta.spawn:{
 if $mta.skin($1,$2) == Robber {
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
 }
 elseif $mta.skin($1,$2) == Mexican {
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
   mta.slap $1 $2
 }
}

So i load the script, and when i spawn from robber or mexican, i dont be slapped

Why?[/code]

Link to comment

The reason that won't work is that $mta.skin returns the Skin ID, not the skin name. Also, that script can be made a lot shorter and simpler:

on *:SIGNAL:mta.spawn:{
 if ($mta.mode($1) == Deathmatch) {
   if ($findtok(2 3,$3,1,32)) {
     %a = 0
     while (%a < 5) { 
       mta.slap $1 $2 
       inc %a
     }
   }
 }
}

This way it uses $findtok to see if it can find the IDs (2 for robber, 3 for mex) in $3 (The skin ID of the player).

[sKIN2] (VC DM)

1=Cop

2=Robber

3=Mexican

4=Sailor

5=Vice City Crusador

6=Secret Service

Also, always use ( ) brackets around the if match:

e.g: if (blah == blah) { }

Edit: Of course with the while aswell :oops:

/me slaps self

Edited by Guest
Link to comment
The reason that won't work is that $mta.skin returns the Skin ID, not the skin name. Also, that script can be made a lot shorter and simpler:

on *:SIGNAL:mta.spawn:{
 if ($mta.mode($1) == Deathmatch) {
   if ($findtok(2 3,$3,1,32)) {
     %a = 0
     while %a < 5 { 
       mta.slap $1 $2 
       inc %a
     }
   }
 }
}

This way it uses $findtok to see if it can find the IDs (2 for robber, 3 for mex) in $3 (The skin ID of the player).

[sKIN2] (VC DM)

1=Cop

2=Robber

3=Mexican

4=Sailor

5=Vice City Crusador

6=Secret Service

Also, always use ( ) brackets around the if match:

e.g: if (blah == blah) { }

also with WHILE mike

while (%a < 5)

Link to comment

ok, i need another script, a password one for gangwars, since using admin cleint will be a hassle, heres how it goes:

I am in a list of ppl who are allowed to use this command, if sum1 else does it, it fails (i would prefer it if it could be hooked up with level4 grs, but either is fine)

i type /msg gw on and it registers the

when any1 enters from now on, are prompted via PM:

A gangwar is in progress, please enter the password by typing /msg gw . You will be kicked in 20seconds.

obviously, if they dont log on, they are kicked.

after im done, i type /msg gw off and the script will be deactivated and become public.

thats all of it, if you add anything extra for security, thats fine, and i may make changes since i dont think i remembered anything

Link to comment

This is pretty simple to do, i'll do it for you, i'm nice :P

Here you go, haven't tested it yet so gimmie a shout if there are any bugs:

on *:SIGNAL:mta.pm:{
 if ($3 == gw) {
   if ($mta.level($1,$2) >= $readini(gw-password.ini,gw $+ $1,level)) {
     if ($4 == on) {
       if ($5) {
         !writeini gw-password.ini gw $+ $1 password $5
         !writeini gw-password.ini gw $+ $1 status on
         mta.say $1 Gangwar passwording activated.
       }
       else $mta.msg $1 $2 You must specify a password.
     }
     elseif ($4 == off) {
       !writeini gw-password.ini gw $+ $1 status off
       mta.say $1 Gangwar passwording deactivated.
     }
   }
   if (($4 == login) && ($readini(gw-password.ini,gw $+ $1,status) == on) {
     if ($5 == $readini(gw-password.ini,gw $+ $1,password)) {
   !.timerGW. $+ $1 $+ . $+ $2 off
       mta.msg $1 $2 Correct password, you are logged in.
     }
     else mta.msg $1 $2 Incorrect password.
   }
 }
}
on *:SIGNAL:mta.join:{
 if ($readini(gw-password.ini,gw $+ $1,status) == on) {
   mta.msg $1 $2 This server is passworded for a gangwar. Do /msg gw login  to login. [30 secs]
   !.timerGW. $+ $1 $+ . $+ $2 1 30 mta.kick $1 $2
 }
}
on *:SIGNAL:mta.part:{
 if ($timer(GW. $+ $2).type == online) {
   !.timerGW. $+ $1 $+ . $+ $2 off
 }
}
on *:SIGNAL:mta.command:{
 if (($3 == !setgw) && ($mta.level($1,$2) == 5)) {
   if (($4) && ($4 isnum)) {
     !writeini gw-passworded.ini gw $+ $1 level $4
     mta.say $1 The level for passwording the server is now " $+ $4 $+ "
   }
   else mta.say $1 You must specify a valid level.
 }
}

Commands:

/msg gw on

/msg gw off

/msg gw login

!setgw

As you specified :)

(You'll need to do !setgw first before you can turn it on, to make the ini.

Edited by Guest
Link to comment

on *:SIGNAL:mta.join:{
 if ($readini($grs.dir $+ options.ini,main,serverpassword) != $null) {
   mta.msg $1 $2 A gangwar is in progress, please enter the password by typing /msg gw . You will be kicked in 20seconds
   $+(!.timer,$1,.,$2) 1 30 mta.kick $1 $2
 }
}
on *:SIGNAL:mta.part:{
 $+(!.timer,$1,.,$2) off
}
on *:SIGNAL:mta.pm:{
 if ($3 == gw) {
   if ($4 == on) {
     if (($5 != $null) && ($5 != on) && ($5 != off)) {
       if ($mta.level($1,$2) >= 4) {
         mta.say $1 Server passworded
         !writeini " $+ $grs.dir $+ options.ini" main serverpassword $5-
       }
       else mta.msg $1 $2 Insufficent privileges
     }
     else mta.msg $1 $2 Invalid password
   }
   elseif ($4 == off) {
     if ($5 == $readini($grs.dir $+ options.ini,main,serverpassword)) {
       if ($mta.level($1,$2) >= 4) {
         mta.say $1 Server unpassworded
         !remini " $+ $grs.dir $+ options.ini" main serverpassword
       }
       else mta.msg $1 $2 Invalid password
     }
     else mta.msg $1 $2 Insufficent privileges
   }
   elseif ($4 == $readini($grs.dir $+ options.ini,main,serverpassword)) {
     mta.msg $1 $2 ' $+ $mta.name($1,$2) $+ ', you have logged into the gangwar
     $+(!.timer,$1,.,$2) off
   }
   else mta.msg $1 $2 Syntax: /msg gw 
 }
}

THere we go.. wrote that into the forum box.. and its untested.. but should be ok :)

Commands:

/msg gw on - Admin level 4+

/msg gw off - Admin level 4+

/msg gw - logs u in

Edit: Mike.. lol.. just beat me :P ... but ures wont work on more than 1 server at once very well :P

Link to comment
  • 2 weeks later...
bah, fixed. I always screw up the brackets on ifs when using identifiers :(

I wish mirc would check the ( ) brackets aswell as the { }s :evil:

Hint: Use a better editor (/me points at UltraEdit for all your programming skills)

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...