[Minigame] Maze Runners.

Mahmoud Tornado

  • Full Member
  • Posts: 220
[Minigame] Maze Runners.
«  »Last edited
Hello, dear VC-MP community.
I was talking to some friends and they asked me to make an maze minigame, they said that they played one before.
So i was thinking and finally, i made it and now i would love to share it.
Idea: had been taken from anime's world server.

First:  PlayerClass, for making or checking if player is maze player.
Code: [Select]
mazerunner = false;

Second:  Scriptload, for making the maze false {didn't started yet}, and making the maze map.
Code: [Select]
maze <- false;
 mazecount <- 0;
 mazestart <- false;
 mazeobjects();
 print( "=== Maze Minigame Loaded ===" );

Third:  CreateMazeObjects
Code: [Select]
function mazeobjects();
{
CreateObject(1078,2,Vector(-382.707, -575.289, 1071.11),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-333.354, -594.997, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-425.653, -598.008, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-385.225, -600.134, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-395.847, -554.743, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(2505,2,Vector(-382.539, -577.317, 1073.05),255).RotateToEuler(Vector(3.14159, 3.14159, 1.5416),1)
CreateObject(2505,2,Vector(-429.002, -576.413, 1073.05),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-452.034, -582.818, 1071.3),255).RotateToEuler(Vector(0, 0, 1.55),1)
CreateObject(310,2,Vector(-421.297, -554.912, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(2505,2,Vector(-337.211, -572.848, 1073.02),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-314.453, -568.476, 1071.3),255).RotateToEuler(Vector(0, 0, 1.55),1)
CreateObject(310,2,Vector(-327.652, -551.383, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-333.015, -550.631, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-323.242, -550.807, 1071.3),255).RotateToEuler(Vector(3.14159, -3.14159, 1.5416),1)
CreateObject(310,2,Vector(-331.936, -545.814, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-340.61, -545.855, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-349.144, -545.831, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-357.863, -545.785, 1071.3),255).RotateToEuler(Vector(0, 0, 0),1)
CreateObject(310,2,Vector(-358.379, -550.907, 1071.3),255).RotateToEuler(Vector(0, 0, 1.45),1)
}

Fourth: When player have been killed or get disconnected, get out of the maze count.
Code: [Select]
function onPlayerKill( killer, player, reason, bodypart )
{
if ( Stats[ player.ID ].mazerunner )
{
mazecount--;
Message( "[#00de00]Minigame: [#fbf3f3]" + player.Name + " is out of the maze." );
if ( mazecount == 0 ) closemaze();
Stats[ player.ID ].mazerunner = false;
}
}

function onPlayerDeath( player, reason )
{
if ( Stats[ player.ID ].mazerunner )
{
mazecount--;
Message( "[#00de00]Minigame: [#fbf3f3]" + player.Name + " is out of the maze." );
if ( mazecount == 0 ) closemaze();
Stats[ player.ID ].mazerunner = false;
}
}


function onPlayerPart( player, reason )
{
if ( Stats[ player.ID ].mazerunner )
{
mazecount--;
Message( "[#00de00]Minigame: [#fbf3f3]" + player.Name + " is out of the maze." );
if ( mazecount == 0 ) closemaze();
Stats[ player.ID ].mazerunner = false;
}
}

Fifthly: Maze Commands, maze, joinmaze and startmaze.
Code: [Select]
if( Stats[player.ID].mazerunner ) return MessagePlayer( "[#00de00]Minigame: [#fbf3f3]You can't use commands while you playing in a maze.", player );
cmd = cmd.tolower ( );

if( cmd == "maze")
{
  if( maze ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]maze is already started.. ",player);
  else
{
   maze = true;
   Message("[#00de00]Minigame: [#fbf3f3]"+ player.Name +" has asked for maze, 20sec to join him.");
   NewTimer( "mazetimer", 20000, 1);
}
}
 else if( cmd == "joinmaze")
{
 if ( !player.Spawned )MessagePlayer("[#00de00]Information: [#fbf3f3]Spawn to use this command" player);
 else if ( !maze ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]maze is not started do /maze", player);
 else if ( Stats[player.ID].mazerunner ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]You already a maze runner.",player);
 else if ( mazecount > 4 ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]Too Late!", player);
 else if ( mazestart ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]Too Late!", player);
 else {
  mazecount++;
   for( local i=0; i <= mazecount; i++ )
  {
   local plr = FindPlayer( i );
  }
  player.Frozen = true;
  Stats[player.ID].mazerunner = true;
  player.World = 2;
  player.CanAttack = false;
  player.Pos = Vector(-449.832, -579.169, 1075.8);
  Message("[#00de00]Minigame: [#fbf3f3]"+ player.Name +" has joined the maze.")
 }
 }
 else if( cmd == "startmaze")
{
 if ( !player.Spawned )MessagePlayer("[#00de00]Information: [#fbf3f3]Spawn to use this command" player);
 else if ( !maze ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]maze is not started do /maze fisrt to start one.", player);
 else if ( !Stats[player.ID].mazerunner ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]You aren't a maze runner to start it.",player);
 else if ( mazecount < 1 ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]You can't start the maze, as you are only.", player);
 else if ( mazestart ) MessagePlayer("[#00de00]Minigame: [#fbf3f3]The maze is already started.", player);
 else {
 startmaze();
 }
 }

Sixth: Maze functions:
Code: [Select]
function startmaze()
{
    mazestart = true;
    CreatePickup(376, 2, 50, Vector(-355.151, -548.226, 1072.8), 255, true);
    local plr;
    for( local i=0; i <= GetMaxPlayers(); i++ )
{
{
    plr = FindPlayer( i );
    if ( ( plr ) && ( Stats[ plr.ID ].mazerunner ) )
{
    plr.IsFrozen = false;
}
}
}
}

function closemaze()
{
    maze = false;
    mazestart = false;
    mazecount = 0;
    local plr;
    for( local i=0; i <= GetMaxPlayers(); i++ ){
{
    plr = FindPlayer( i );
    if ( plr )
{
    if( Stats[ plr.ID ].mazerunner )
{
    Stats[ plr.ID ].mazerunner = false;
    plr.IsFrozen = false;
    plr.CanAttack = true;
    plr.World = 1;
    plr.Pos = Vector( 496, -84, 11  );
}
}
}
}
}

function mazetimer()
{
   if ( mazecount > 1 )
{
  NewTimer( "MAnn", 1000, 1, "3" );
  NewTimer( "MAnn", 3000, 1, "2" );
  NewTimer( "MAnn", 6000, 1, "1" );
  NewTimer( "MAnn", 7000, 1, "0" );
}
   else closemaze();
}

function MAnn( number )
{
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
   local plr = FindPlayer( i );
      if ( ( plr ) && ( Stats[ plr.ID ].mazerunner ) )
                        {
      switch( number.tointeger() )
          {
       case 0:
       startmaze();
       Announce( "Go!", plr );
       break;

       case 1:
       Announce( "1", plr );
       break;
       
       case 2:
       Announce( "2", plr );
       break;
       
       case 3:
       Announce( "3", plr );
       break;
          }
      }
  }
}

Seventh: onPickupPickedUp( player, pickup )
Code: [Select]
  if ( pickup.Model == 376 )
{
  if ( Stats[ player.ID ].mazerunner )
{
  IncCash( player, 5000 );
  MessagePlayer("[#00de00]Minigame: [#fbf3f3]Congratulation! You Got 5000$" player);
  pickup.Remove();
  player.World = 1;
  Message( "[#00de00]Minigame: [#fbf3f3]Congratulation! "+player.Name+" Has finished the maze." );
  closemaze();
}
}

Finally, hope that like you.
Your friend,
Mahmoud Ashraf.

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 447
[Minigame] Re: Maze Runners.
« Reply #1,  »
its showing The index "Stats" does not exists
Try to UnderStand ME!

dracc

  • Jr. Member
  • Posts: 84
[Minigame] Re: Maze Runners.
« Reply #2,  »
Quote from =RK=MarineForce on May 18th, 01:29 AM
its showing The index "Stats" does not exists
Looks like adding
Code: [Select]
Stats <- array(100, null);
in onScriptLoad() would be enough.

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 447
[Minigame] Re: Maze Runners.
« Reply #3,  »
mazerunner doesn't exists WTF

mazerunner <- array(100, null);
Try to UnderStand ME!

AroliS^

  • Newbie
  • Learning of Mike Tyson K.O
  • Posts: 46

KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 117
[Minigame] Re: Maze Runners.
« Reply #5,  »
Quote
First:  PlayerClass, for making or checking if player is maze player.
Code: [Select]
mazerunner = false;
We are his people !
Who can challange us ?

Gabriel_Stories

  • Newbie
  • Posts: 6
[Minigame] Re: Maze Runners.
« Reply #6,  »
I have already added the labyrinth to my Server But when I use / startmaze CMD does not work

_Bab English_

Aceptas un Duelo ?