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
main.nut
[noae][noae]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(){
CreateCheckpoint( null, 1, false,Vector( 10.1409, 963.899, 10.9402 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -231.318, 1079.07, 20.147 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -397.966, 1067.51, 12.9971 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -488.76, 771.059, 10.3594 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -636.525, 548.756, 10.592 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -738.273, 158.318, 10.6376 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -843.745, -289.459, 10.4258 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -825.032, -774.582, 10.4491 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -971.792, -1073.91, 14.217 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -1200.94, -862.164, 14.2198 ), RGB(225, 0, 255), 6);
CreateCheckpoint( null, 1, false,Vector( -1247.47, -784.685, 14.217 ), RGB(225, 0, 255), 6);
race <- false;
racecount <- 0;
racestart <- false;
stats <- array( GetMaxPlayers(), null );
print( "Drift Race System Loaded." );
driftcar1 <- CreateVehicle( 141, 1, -426.066, 32.066, 26.5326, 0, -1 , -1 );
driftcar2 <- CreateVehicle( 141, 1, -426.066, 32.066, 26.5326, 0, -1 , -1 );
driftcar3 <- CreateVehicle( 141, 1, -426.066, 32.066, 26.5326, 0, -1 , -1 );
driftcar4 <- CreateVehicle( 141, 1, -426.066, 32.066, 26.5326, 0, -1 , -1 );
print( "driftcar1 vehicle ID is : "+driftcar1.ID );
print( "driftcar2 vehicle ID is : "+driftcar2.ID );
print( "driftcar3 vehicle ID is : "+driftcar3.ID );
print( "driftcar4 vehicle ID is : "+driftcar4.ID );
dofile("scripts/cmds.nut");
}
function onPlayerTeamKill( killer, killed, weapon, bodypart )
{
onPlayerKill( killer, killed, weapon, bodypart );
}
function onPlayerKill( killer, player, reason, bodypart )
{
if ( stats[ player.ID ].raceplayer ) {
racecount--;
Message( ">> " + player.Name + " is out of the race." );
if ( racecount == 0 ) closerace();
stats[ player.ID ].raceplayer = false;
}
Message( ""+killer.Name + " has been drowned Reason: Stop killing racing players " );
Killer.Pos = Vector( -597.7496,-1858.9531,28.1291 );
}
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 onPlayerPart( 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 onPlayerJoin( player ){
stats[ player.ID ] = PlayerClass( player.Name );
}
function onPlayerExitVehicle( player, vehicle ) {
if ( stats[player.ID].raceplayer ){ vehicle.Locked = false; player.Vehicle = vehicle; vehicle.Locked = true; } // By Karan
}
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( 382, Vector( -1435.9, -790.299, 14.6437 ) );
CreateMarker(1, 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 onPickupPickedUp( player, pickup )
{
if ( pickup.Model == 382 )
{
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$.");
pickup.Remove();
Message( ""+player.Name+" has won ." );
closerace();
}
}
}
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");
}
}
}
[/noae][/noae]
cmds.nut
[noae][noae]function onPlayerCommand( player, cmd, text ){
if( cmd == "race") {
if( race ) MessagePlayer("Race is already started.. ",player);
else{
race = true;
Message("Race is started by "+ player.Name +", 20sec to join the race.");
Message("Film Studio to Airport race started.");
NewTimer( "raceplayers", 20000, 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 );
}
}
else if( cmd == "joinrace") {
if ( !player.Spawned )MessagePlayer("Spawn to use this command" player);
else if ( !race ) MessagePlayer("Race is not started do /race", 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++;
for( local i=0; i <= racecount; i++ )
{
local plr = FindPlayer( i );
player.Vehicle = FindVehicle( i );
}
player.Frozen = true;
stats[player.ID].raceplayer = true;
Message(""+ player.Name +" has joined race.")
}
}
}
[/noae][/noae]
If still find any Bug do let me know, This script aint mine, just was bored so was wandering scripts which were bugged a bit or were incompleted so thought of fixing this one ^^
Note: Pro scripters out there, pls sta away as we cant reach ur level, Secondly newbies if u guys have any issue do let me know!
Download
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Ffiles.thijn.ovh%2Fimg%2F507b0d80ba1261670a06847e854e3089%2FKnsas%2520race%2520system.zip&hash=5a93abd0e651fb6f6a9b03dce2e6f3c51bb4cec8) (http://files.thijn.ovh/download/507b0d80ba1261670a06847e854e3089/Knsas%20race%20system.zip)
There is a bug when we race again it says you already pickup Checkpoint ID can you fix it?
also when I kill someone it says
"Player drowned Reason:Dont kill players in race"