« [ #D~ Tools ] Map Editor
Knsas race system (Modified-Drift version)

MEGAMIND

  • Hero Member
  • Developer of "Web-Net" search engine
  • Posts: 698
Knsas race system (Modified-Drift version)
«  »
==========================Heres goes same script but a bit more modified============================
Details:
Ksna's  RACE SYSTEM modified using checkpoints

Original Post here
https://forum.vc-mp.org/?topic=1078.0

someone who tried to modify it using checkpoint but didnt worked as it was left abandoned
https://forum.vc-mp.org/?topic=1174.msg7890#msg7890

at the END MEGAMIND fixed it for newbiews
Features:
1. used ksna's race script
2. Added checkpoints and modifed it porperly
3. redesigned from scratch
4.Added Drift cars
5.race ends using checkpoint not a pickup

main.nut
Code: [Select]
//======================== TOP OF SCRIPT ============================

//================== Drift Race====================
class PlayerClass{
 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()
{
dofile( "scripts/Cmds.nut" );

pVehicle <- array( GetMaxPlayers(), null );
driftcarraceVeh <- array( GetMaxPlayers(), null );
driftcarraceVehLocationsIdx <- 0;
driftcarraceVehVectors <- [    Vector(-24.0036,973.773,10.9403), Vector(-24.9422,964.929,10.9403), Vector(-34.3871,966.302,10.9403), Vector(-33.1926,972.686,10.9403)];
driftcarraceVehAngles <- [    -1.7153,-1.7153,-1.7153,-1.7153,];

race <- false;
racecount <- 0;
racestart <- false;
 
stats <- array( GetMaxPlayers(), null );
print( "Drift Race System Loaded." );
}


function onPlayerJoin( player )
{
CreateCheckpoint( null, 26, false,Vector( 10.1409, 963.899, 10.9402 ), RGB(225, 0, 255), 6); //37
CreateCheckpoint( null, 26, false,Vector( -231.318, 1079.07, 20.147 ), RGB(225, 0, 255), 6);//38
CreateCheckpoint( null, 26, false,Vector( -397.966, 1067.51, 12.9971 ), RGB(225, 0, 255), 6);//39
CreateCheckpoint( null, 26, false,Vector( -488.76, 771.059, 10.3594 ), RGB(225, 0, 255), 6);//40
CreateCheckpoint( null, 26, false,Vector( -636.525, 548.756, 10.592 ), RGB(225, 0, 255), 6);//41
CreateCheckpoint( null, 26, false,Vector( -738.273, 158.318, 10.6376 ), RGB(225, 0, 255), 6);//42
CreateCheckpoint( null, 26, false,Vector( -843.745, -289.459, 10.4258 ), RGB(225, 0, 255), 6);//43
CreateCheckpoint( null, 26, false,Vector( -825.032, -774.582, 10.4491 ), RGB(225, 0, 255), 6);//44
CreateCheckpoint( null, 26, false,Vector( -971.792, -1073.91, 14.217 ), RGB(225, 0, 255), 6);//45
CreateCheckpoint( null, 26, false,Vector( -1200.94, -862.164, 14.2198 ), RGB(225, 0, 255), 6);//46
CreateCheckpoint( null, 26, false,Vector( -1247.47, -784.685, 14.217 ), RGB(225, 0, 255), 6);//47
CreateCheckpoint( null, 26, false,Vector( -1458.03,-783.488,14.6999 ), ARGB(255, 255, 0, 0), 6);//48 end drace

stats[ player.ID ] = PlayerClass( player.Name );
}

function onPlayerTeamKill( player, killer, reason, bodypart )
{
onPlayerKill( killer, killed, weapon, bodypart );
}

function onPlayerExitVehicle( player, vehicle )
{
  if ( stats[player.ID].raceplayer ){ vehicle.Locked = false; player.Vehicle = vehicle; vehicle.Locked = true; }
}

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




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 ) && ( stats[ 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(301, 26, 1, Vector(-1435.9, -790.299, 14.6437), 255, true);
 CreateMarker(26, Vector( -1435.9, -790.299, 14.6437  ), 5,RGB(255, 255, 0),2);
 local plr;
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
  {
      plr = FindPlayer( i );
      if ( ( plr ) && ( stats[ plr.ID ].raceplayer ) )
                {
                    plr.IsFrozen = false;
                }
        }
 }
}

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

}


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

if ( checkpoint.ID == 11 )
{
 if ( !stats[ player.ID ].raceplayer ) PrivMessage( player, "You are not in race");
 else if ( stats[ player.ID ].check1 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check2 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check3 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check4 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check5 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check6 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check7 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check8 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check9 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else if ( stats[ player.ID ].check10 == false ) PrivMessage( player, "You need to pickup last pickup to pickup this");
else
{
player.Cash+=1000;
   Message( player.Name + " have got 1000$.");
   Message( ""+player.Name+" has won ." );
   closerace();
   player.World = 1;
}
}

}


Cmds.nut
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "drace" ) {
        if ( driftcarraceVehLocationsIdx >= 4 ) {
            driftcarraceVehLocationsIdx = 0;
        }
       
        if ( driftcarraceVeh[ player.ID ] != null ) {
            driftcarraceVeh[ player.ID ].Remove();
            driftcarraceVeh[ player.ID ] = null;
        }
        player.World = 26;
        driftcarraceVeh[ player.ID ] = CreateVehicle( 6401, 26, driftcarraceVehVectors[ driftcarraceVehLocationsIdx ], driftcarraceVehAngles[ driftcarraceVehLocationsIdx ], -1, -1 );
        player.Vehicle = driftcarraceVeh[ player.ID ];
       driftcarraceVehLocationsIdx++;
  race = true;
   Message("Race is started by "+ player.Name +", to join the race [USAGE /drace].");
   MessagePlayer("type /draceready to prepare your self for drift race",player);
  Message("Film Studio to Airport race started.");
}

 else if( cmd == "draceready") {
 player.World = 26;
 if ( !player.Spawned )MessagePlayer("Spawn to use this command" player);
 else if ( !race ) MessagePlayer("Race is not started do /startdrace", player);
 else if ( stats[player.ID].raceplayer ) MessagePlayer("You already joined race.",player);
 else if ( racecount > 4 ) MessagePlayer("Too Late! Only 4 players can race at once", player);
 else if ( racestart ) MessagePlayer("Too Late!", player);
 else {
  racecount++;
  player.Frozen = true;
  stats[player.ID].raceplayer = true;
  Message(""+ player.Name +" has joined race.")
  NewTimer( "ClientMessageToAll", 15000, 1, "-----> (Anyone) /startdrace <------",1000, 1500, 300 );
 }
 }
 
 if(cmd == "startdrace"){
 player.World = 26;
NewTimer( "ClientMessageToAll", 1000, 1, "-> 3",28, 255, 11 );
        NewTimer( "ClientMessageToAll", 2000, 1, "-> 2",24, 255, 241 );
        NewTimer( "ClientMessageToAll", 3000, 1, "-> 1",249, 57, 56 );
        NewTimer( "ClientMessageToAll", 4000, 1, "-----> START <------",1000, 1500, 300 );
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.IsFrozen = false;
}
}
       

 }
 }


If still find any Bug do let me know,

Note: Pro scripters out there, pls stay away as we cant reach ur level, Secondly newbies if u guys have any issue do let me know!

Download

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 447
Try to UnderStand ME!

Rardodus Bruise

  • Newbie
  • Posts: 31