Ksna Race System with CheckPoints

Started by BrYaN_FuRy, Jul 30, 2015, 08:57 AM

Previous topic - Next topic

BrYaN_FuRy

Hello i was working on Checkpoint race system i have complete that system This is Ksna Race System

What's New in this System: This is Ksna Race System but with Checkpoints Here it is

I am Posting Whole System

function onPlayerClass
{
raceplayer = false;
check0 = false;
check1 = false;
check2 = false;
check3 = false;
check4 = false;
check5 = false;
check6 = false;
check7 = false;
check8 = false;
check9 = false;
check10 = false;
}

function onScriptLoad()
{
CreateCheckpoint( null, 2, Vector( 10.1409, 963.899, 10.9402 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -231.318, 1079.07, 20.147 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -397.966, 1067.51, 12.9971 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -488.76, 771.059, 10.3594 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -636.525, 548.756, 10.592 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -738.273, 158.318, 10.6376 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -843.745, -289.459, 10.4258 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -825.032, -774.582, 10.4491 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -971.792, -1073.91, 14.217 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -1200.94, -862.164, 14.2198 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 2, Vector( -1247.47, -784.685, 14.217 ), RGB(225, 0, 255), 6);
race <- false;
 racecount <- 0;
 racestart <- false;
}
 
[code]function onPlayerPart( player, reason )
{
if ( pstats[ player.ID ].raceplayer ) {
 racecount--;
 Message( "[#00FFFF]>> " + player.Name + " is out of the race." );
    if ( racecount == 0 ) closerace();
 pstats[ player.ID ].raceplayer = false;
    }
}

function onPlayerDeath( player, reason )
{
if ( pstats[ player.ID ].raceplayer ) {
 racecount--;
 Message( "[#00FFFF]>> " + player.Name + " is out of the race." );
    if ( racecount == 0 ) closerace();
 pstats[ player.ID ].raceplayer = false;
    }
}

function onPlayerKill( player, killer, weapon, bodypart )
{
if ( pstats[ player.ID ].raceplayer ) {
 racecount--;
 Message( "[#00FFFF]>> " + player.Name + " is out of the race." );
    if ( racecount == 0 ) closerace();
 pstats[ player.ID ].raceplayer = false;
    }
}
Commands
if( cmd == "race") {
 if( race ) MessagePlayer("[#0033CC]Race is already started.. ",player);
 else if ( player.World == 1 ) MessagePlayer( "Error - Invalid Command",player );
else if ( player.World == 3 ) MessagePlayer( "Error - Invalid Command",player );
 else{
  race = true;
  Message("[#00FFFF]Race is started by "+ player.Name +", 30sec to join the race.");
  Message("[#0033CC]Film Studio to Airport race started.");
  NewTimer( "raceplayers", 30000, 1);
  FindVehicle( 1 ).Pos = Vector( -54.2794, 966.151, 15.9403 );
  FindVehicle( 2 ).Pos = Vector( -54.2794, 956.151, 15.9403 );
  FindVehicle( 3 ).Pos = Vector( -54.2794, 946.151, 15.9403 );
  FindVehicle( 4 ).Pos = Vector( -54.2794, 936.151, 15.9403 );
  FindVehicle( 1 ).World = 2;
  FindVehicle( 2 ).World = 2;
  FindVehicle( 3 ).World = 2;
  FindVehicle( 4 ).World = 2;
 }
 }
 else if ( cmd == "leaverace")
 {
  if ( !player.Spawned )MessagePlayer("[#FF0000]Spawn to use this command" player);
 else if ( !race ) MessagePlayer("[#FF0000]Race is not started do /race", player);
  else if ( player.World == 1 ) MessagePlayer( "Error - Invalid Command",player );
else if ( player.World == 3 ) MessagePlayer( "Error - Invalid Command",player );
 if ( !pstats[ player.ID ].raceplayer ) MessagePlayer("[#FF0000]You are not in any Race", player);
 else
 {
 racecount--;
 Message( "[#00FFFF]>> " + player.Name + " has left the race." );
    if ( racecount == 0 ) closerace();
player.World = 1;
 pstats[ player.ID ].raceplayer = false;
    }
  }
 else if( cmd == "joinrace") {
 if ( !player.Spawned )MessagePlayer("[#FF0000]Spawn to use this command" player);
 else if ( !race ) MessagePlayer("[#FF0000]Race is not started do /race", player);
 else if ( pstats[player.ID].raceplayer ) MessagePlayer("[#0033CC]You already joined race.",player);
  else if ( player.World == 1 ) MessagePlayer( "Error - Invalid Command",player );
else if ( player.World == 3 ) MessagePlayer( "Error - Invalid Command",player );
 else if ( racecount > 4 ) MessagePlayer("[#00FFFF]Too Late! Only 4 players can race at once", player);
 else if ( racestart ) MessagePlayer("[#FFF000]Too Late!", player);
 else {
  racecount++;
   for( local i=0; i <= racecount; i++ )
  {
   local plr = FindPlayer( i );
   player.Vehicle = FindVehicle( i );
   player.World = 2;
  }
  player.Frozen = true;
  pstats[player.ID].raceplayer = true;
  Message("[#FF0000]"+ player.Name +" has joined race.")
 }
 }


function raceplayers()
{
     if ( racecount > 1 )
  {
  NewTimer( "Ann", 1000, 1, "3" );
  NewTimer( "Ann", 2000, 1, "2" );
  NewTimer( "Ann", 3000, 1, "1" );
  } else closerace();
}
function Ann( number )
{
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
   local plr = FindPlayer( i );
      if ( ( plr ) && ( pstats[ plr.ID ].raceplayer ) )
                        {
      switch( number.tointeger() )
          {
       case 1:
       Announce( "1", plr );
       startrace();
       Announce( "Go!", plr );
       break;
       
       case 2:
       Announce( "2", plr );
       break;
       
       case 3:
       Announce( "3", plr );
       break;
          }
      }
  }
}
function startrace()
{
    racestart = true;
CreatePickup( 382, 2, 1, Vector( -1435.9, -790.299, 14.6437 ), 255, false );
 CreateCheckpoint( null, 2, Vector( 10.1409, 963.899, 10.9402 ), RGB(225, 0, 255), 2);
 local plr;
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
  {
      plr = FindPlayer( i );
      if ( ( plr ) && ( pstats[ plr.ID ].raceplayer ) )
                {
                    plr.IsFrozen = false;
                }
        }
 }
}

function closerace() {
    Message( "[#FF0000]Race cancelled!" );
    race = false;
 racestart = false;
    racecount = 0;
    local plr;
     for( local i=0; i <= GetMaxPlayers(); i++ ){
  {
      plr = FindPlayer( i );
      if ( plr )
            {
    if( pstats[ plr.ID ].raceplayer )
    {
                    pstats[ plr.ID ].raceplayer = false;
                    plr.IsFrozen = false;
                    plr.Pos = Vector( 496.26, -83.9443, 10.0302  );
    }
            }
        }
 }

}


CheckPoints

function onPickupPickedUp( player, pickup )
{
 if ( pickup.Model == 382 )
 {
  if ( !pstats[ player.ID ].raceplayer ) PrivMessage( player, "You are not in race");
  else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check6 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check7 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check8 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check9 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( pstats[ player.ID ].check10 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else
  {
  IncCash( player, 25000 );
   Message( " [#FF0000] " + player.Name + " has win the race and got 25000$.");
   pickup.Remove();
   closerace();
  }
  }
}


function onCheckpointEntered(player, checkpoint)
{
if ( checkpoint.ID == 0 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else if ( pstats[ player.ID ].check0 == true ) PrivMessage( player, "You already pickup CheckPoint ID 0");
else
{
pstats[ player.ID ].check0 = true;
PrivMessage( player, "Checkpoint 0 Pick Up Sucessfully 0/10");
}
}
if ( checkpoint.ID == 1 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else if ( pstats[ player.ID ].check1 == true ) PrivMessage( player, "You already pickup CheckPoint ID 1");
else if ( pstats[ player.ID ].check0 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 0");
else
{
pstats[ player.ID ].check1 = true;
PrivMessage( player, "Checkpoint 1 Pick Up Sucessfully 1/10");
}
}
if ( checkpoint.ID == 2 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check2 == true ) PrivMessage( player, "You already pickup CheckPoint ID 2");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check2 = true;
PrivMessage( player, "Checkpoint 2 Pick Up Sucessfully 2/10");
}
}
if ( checkpoint.ID == 3 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check3 == true ) PrivMessage( player, "You already pickup CheckPoint ID 3");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check3 = true;
PrivMessage( player, "Checkpoint 3 Pick Up Sucessfully 3/10");
}
}
if ( checkpoint.ID == 4 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check4 == true ) PrivMessage( player, "You already pickup CheckPoint ID 4");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check4 = true;
PrivMessage( player, "Checkpoint 4 Pick Up Sucessfully 4/10");
}
}
if ( checkpoint.ID == 5 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check5 == true ) PrivMessage( player, "You already pickup CheckPoint ID 5");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check5 = true;
PrivMessage( player, "Checkpoint 5 Pick Up Sucessfully 5/10");
}
}
if ( checkpoint.ID == 6 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check6 == true ) PrivMessage( player, "You already pickup CheckPoint ID 6");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 5");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check6 = true;
PrivMessage( player, "Checkpoint 6 Pick Up Sucessfully 6/10");
}
}
if ( checkpoint.ID == 7 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check7 == true ) PrivMessage( player, "You already pickup CheckPoint ID 7");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 5");
else if ( pstats[ player.ID ].check6 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 6");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check7 = true;
PrivMessage( player, "Checkpoint 7 Pick Up Sucessfully 7/10");
}
}
if ( checkpoint.ID == 8 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check8 == true ) PrivMessage( player, "You already pickup CheckPoint ID 8");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 5");
else if ( pstats[ player.ID ].check6 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 6");
else if ( pstats[ player.ID ].check7 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 7");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check8 = true;
PrivMessage( player, "Checkpoint 8 Pick Up Sucessfully 8/10");
}
}
if ( checkpoint.ID == 9 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check9 == true ) PrivMessage( player, "You already pickup CheckPoint ID 9");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 5");
else if ( pstats[ player.ID ].check6 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 6");
else if ( pstats[ player.ID ].check7 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 7");
else if ( pstats[ player.ID ].check8 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 8");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check9 = true;
PrivMessage( player, "Checkpoint 9 Pick Up Sucessfully 9/10");
}
}
if ( checkpoint.ID == 10 )
{
if ( !race ) PrivMessage( player, ":P Race is not started yet" );
else if ( pstats[ player.ID ].check10 == true ) PrivMessage( player, "You already pickup CheckPoint ID 10");
else if ( pstats[ player.ID ].check1 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 1");
else if ( pstats[ player.ID ].check2 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 2");
else if ( pstats[ player.ID ].check3 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 3");
else if ( pstats[ player.ID ].check4 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 4");
else if ( pstats[ player.ID ].check5 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 5");
else if ( pstats[ player.ID ].check6 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 6");
else if ( pstats[ player.ID ].check7 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 7");
else if ( pstats[ player.ID ].check8 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 8");
else if ( pstats[ player.ID ].check9 == false ) PrivMessage( player, "You didn't Pickup Checkpoint ID 9");
else if ( pstats[ player.ID ].raceplayer == false ) PrivMessage( player, "You are not in any race");
else
{
pstats[ player.ID ].check10 = true;
PrivMessage( player, "Checkpoint 10 Pick Up Sucessfully 10/10");
PrivMessage( player, "Now Move to Airport for Win");
}
}
}

Note: race is for world 2 and I am new so Scripting Way is not Good
Code Updated!

KAKAN

Better if you've done it with case, anyways NICE!
oh no

BrYaN_FuRy

Sorry Code Updated I miss clĂ sses

Ksna

#3
Nice,
many booleans ;D

use checkpoints = 0; in playerclass


function onCheckpointEntered(player, checkpoint)
{
if( stats[ player.ID ].checkpoints == checkpoint.ID ){
stats[ player.ID ].checkpoints++;
MessagePlayer("Owned", player );
   // Make checkpoint disappear after he gets it
}
else MessagePlayer("Go back", player);
}

BrYaN_FuRy

i was new so i dont know much so i release like that btw thanks

Derwaish.

Sorry for bump
but i am getting error.
Everything is looking fine but when i use command race it show " invalid command "


Thijn

Then you obviously didn't copy paste the script correctly.

Finch Real

@RizwaN You just miss something while copying i just script it for newbies
My Snipet Showroom

http://pastebin.com/5KKuU5cg

dEaN

match with old race system but anyways -Nice-
I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

:P

#9
@Rizwan remove these two lines from every command 100% will work after it
else if ( player.World == 1 ) MessagePlayer( "Error - Invalid Command",player );
    else if ( player.World == 3 ) MessagePlayer( "Error - Invalid Command",player );
SLC is a good scripter but he always use bad words for abusing players :P

kennedyarz

A suggestion, place points on the map that indicate where the player has to go. And another thing destroy checkpoint and the points to add for when the race ends

luchgox

Strength does not come from wining.Your struggles develop your strengths.

FAW[K]EY[E]

i can make it more easier n need to do this much big scripting