Race, Derby and Server name generator

Ksna

  • Jr. Member
  • Posts: 86
Race, Derby and Server name generator
« on July 21st, 2015, 09:00 AM »Last edited on July 28th, 2015, 07:06 AM
Credits : Ksna
Thanks Gudio, Dany
Code: [Select]
class PlayerClass{
 raceplayer = false;
 derbyplayer = false;
}

function onScriptLoad(){
 race <- false;
 racecount <- 0;
 racestart <- false;
 
 derby <- false;
 derbycount <- 0;
 derbystart <- false;
 
 stats <- array( GetMaxPlayers(), null );
 print( "Ksna's Race System Loaded." );
}

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;
    }
 if ( stats[ player.ID ].derbyplayer ) {
 derbycount--;
 Message( ">> " + player.Name + " is out of the derby." );
    stats[ player.ID ].derbyplayer = false;
if ( derbycount == 1 ) checkderby();
    }
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;
    }
 if ( stats[ player.ID ].derbyplayer ) {
 derbycount--;
 Message( ">> " + player.Name + " is out of the derby." );
 stats[ player.ID ].derbyplayer = false;
    if ( derbycount == 1 ) checkderby();
 
    }
}


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;
    }
 if ( stats[ player.ID ].derbyplayer ) {
 derbycount--;
 Message( ">> " + player.Name + " is out of the derby." );
    stats[ player.ID ].derbyplayer = false;
if ( derbycount == 1 ) checkderby();
    }
}

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
 if ( stats[player.ID].derbyplayer ){ vehicle.Locked = false; player.Vehicle = vehicle; vehicle.Locked = true; }

}

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.")
 }
 }
 else if( cmd == "derby") {
 if( derby ) MessagePlayer("Derby is already started.. ",player);
 else{
  derby = true;
  Message("Derby is started by "+ player.Name +", 20sec to join the derby.");
  NewTimer( "derbyplayers", 20000, 1);
  FindVehicle( 11 ).Pos = Vector( -1386.75, 1001.00, 252.25 );                 // Change these values
  FindVehicle( 12 ).Pos = Vector( -1386.75, 1011.00, 252.25 );                 
  FindVehicle( 13 ).Pos = Vector( -1386.75, 1021.00, 252.25 );                 
  FindVehicle( 14 ).Pos = Vector( -1386.75, 1031.00, 252.25 );                 
 }
 }
 else if( cmd == "joinderby") {
 if ( !player.Spawned )MessagePlayer("Spawn to use this command" player);
 else if ( !derby ) MessagePlayer("Derby is not started do /derby", player);
 else if ( stats[player.ID].derbyplayer ) MessagePlayer("You already joined derby.",player);
 else if ( derbycount > 4 ) MessagePlayer("Too Late! Only 4 players can derby at once", player);
 else if ( derbystart ) MessagePlayer("Too Late!", player);
 else {
   derbycount++;
   for( local i=0; i <= derbycount + 10; i++ )
  {
   local plr = FindPlayer( i );
   player.Vehicle = FindVehicle( i );
  }
  player.Frozen = true;
  stats[player.ID].derbyplayer = true;
  Message(""+ player.Name +" has joined derby.")
 }
 }
 }


function raceplayers()
{
     if ( racecount > 1 )
  {
  NewTimer( "Ann", 1000, 1, "3" );
  NewTimer( "Ann", 2000, 1, "2" );
  NewTimer( "Ann", 3000, 1, "1" );
  } else closerace();
}
function derbyplayers()
{
if ( derbycount > 1 )
  {
  NewTimer( "DAnn", 1000, 1, "3" );
  NewTimer( "DAnn", 2000, 1, "2" );
  NewTimer( "DAnn", 3000, 1, "1" );
  } else closederby();
}

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 DAnn( number )
{
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
   local plr = FindPlayer( i );
      if ( ( plr ) && ( stats[ plr.ID ].derbyplayer ) )
                        {
      switch( number.tointeger() )
          {
       case 1:
       Announce( "1", plr );
       startderby();
       Announce( "Go!", plr );
       break;
       
       case 2:
       Announce( "2", plr );
       break;
       
       case 3:
       Announce( "3", plr );
       break;
          }
      }
  }
}


function checkderby( )
{
       for( local i=0; i <= GetMaxPlayers(); i++ )
  {
   local plr = FindPlayer( i );
      if ( ( plr ) && ( stats[ plr.ID ].derbyplayer ) )  {
    plr.Cash += 1000;
    Message(""+plr.Name+" has won derby.");
    closederby();
   }
  }
 }
 
function startderby() {
    derbystart = true;
 CreatePickup( 382, Vector( -1435.9, -790.299, 14.6437 ) );
 local plr;
       for( local i=0; i <= GetMaxPlayers(); i++ ) {
  {
      plr = FindPlayer( i );
      if ( ( plr ) && ( stats[ plr.ID ].derbyplayer ) ) {
                    plr.IsFrozen = false;
                }
   }
  }
 }
 

function closederby() {
    Message( "Derby cancelled!" );
    derby = false;
 derbystart = false;
    derbycount = 0;
    local plr;
     for( local i=0; i <= GetMaxPlayers(); i++ ){
   {
      plr = FindPlayer( i );
      if ( plr )
            {
    if( stats[ plr.ID ].derbyplayer )
    {
                    stats[ plr.ID ].derbyplayer = false;
                    plr.IsFrozen = false;
                    plr.Pos = Vector( 496.26, -83.9443, 10.0302  );
    }
            }
        }
 }
}

function startrace()
{
    racestart = true;
 CreatePickup( 382, Vector( -1435.9, -790.299, 14.6437 ) );
 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 ) {
   player.Cash+=1000;
   Message( player.Name + " have got 1000$.");
   pickup.Remove();
   Message( ""+player.Name+" has won ." );
   closerace();
  }
  }
}


Server Name Generator

Code: [Select]

text1 <- [ "Vice City", "Extreme", "Low Gravity", "GTA", "Grand Theft Auto :", "ClanWars", "Mega", "Infinity", "Downtown", "Twilight", "Advanced", "Hardcore", "Ultimate" ];
text2 <- [ "Deathmatch", "Cops and Robbers", "RPG", "Warzone", "ClanWars", "Adventure", "War + Roleplay", "Hell", "Survival", "Roleplay", "Rush", "VC", "Worlds" ];

function onPlayerCommand( player, cmd, text ){

if ( cmd == "gen" ){
Message( ""+text1[rand()% text1.len()]+" "+text2[rand()% text2.len()] );
}
else if ( cmd == "name" ){
Message( ""+player.Name+"'s "+text2[rand()% text2.len()] );
}
}


KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: Race and Derby
« Reply #1, on July 21st, 2015, 09:57 AM »
NIce work u did, u r gonna go far kid
oh no

Awesome_Boy

  • Newbie
  • Posts: 26
Re: Race and Derby
« Reply #2, on July 21st, 2015, 10:47 AM »
Amazing Release. we are waiting for vccnr

DeViL_JiN

  • Full Member
  • Posts: 103

MatheuS

  • Wiki Contributor
  • LBR | Co-Leader & Brasil Real RPG | Developer
  • Posts: 470
Re: Race and Derby
« Reply #4, on July 21st, 2015, 12:07 PM »
good script.

PS: There can be no more than 1 vccnr?
      So there could be no more than 1 DM
Code: [Select]
if( !sucess ) tryAgain();

Honey

  • Full Member
  • Posts: 136
Re: Race and Derby
« Reply #5, on July 21st, 2015, 01:18 PM »Last edited on July 21st, 2015, 04:42 PM by Thijn
Quote from DeViL_JiN on July 21st, 2015, 01:16 PM
-- Posts removed.
I never get urdu swearings :/

Anyways on the topic, great work I'm sure it will come handy to many users haven't gone through the code yet though.

[VSS]Shawn

  • Full Member
  • Posts: 210
Re: Race and Derby
« Reply #6, on July 21st, 2015, 02:04 PM »
3 Things

1.Thijn Remove Useless post
2.Great Work For it
3.Please No More Vccnr Seby is already angry

Ps Off:Devil Is Ki maa hi nhi ha xD


Sorry
Re: Race and Derby
« Reply #7, on July 21st, 2015, 02:17 PM »
blind??? i say no more vccnr -__- noob

Alterito

  • Newbie
  • Posts: 24

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: Race and Derby
« Reply #9, on July 21st, 2015, 03:36 PM »
Woa nice drama!
Thijin, pls delete the useless posts, I can't tolerate the bad words said here, and also lock the topic to prevent further things ahead
oh no

Ksna

  • Jr. Member
  • Posts: 86
Re: Race and Derby
« Reply #10, on July 21st, 2015, 04:30 PM »
Quote from KAKAN on July 21st, 2015, 03:36 PM
Woa nice drama!
Thijin, pls delete the useless posts, I can't tolerate the bad words said here, and also lock the topic to prevent further things ahead
Oh, Kid Listen your the first person to start insulting and you can't tolerate the bad words? lol

Thijn

  • VC:MP Beta Tester
  • Posts: 1,688
Re: Race and Derby
« Reply #11, on July 21st, 2015, 04:45 PM »
Useless posts removed. It's pointless, I will remove them anyways... Why can't you make your point without swearing?
I agree with most removed posts though. There's, what, 2 VCCNR servers? They aren't even full. What makes you think releasing a VCCNR script will change that? You will end up with the same shit SA:MP has: A million empty servers.

On topic though: The snippet could be better, but may prove a nice example to some beginner scripters. Keep 'em coming.

[VSS]Shawn

  • Full Member
  • Posts: 210
Re: Race and Derby
« Reply #12, on July 21st, 2015, 05:38 PM »
(y) for Thijn and  ....

Kakan always jealous of Ksna Reason..
Kakan don't know how to make good snippets

Alterito

  • Newbie
  • Posts: 24

MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 811
Re: Race and Derby
« Reply #14, on July 21st, 2015, 05:53 PM »Last edited on July 21st, 2015, 05:58 PM
Maybe yea but he didnt posted that again and again like you

One more thing this derby system isnt created by ksna my an friend given me this derby system few months ago

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P