Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Ksna on July 21st, 2015, 09:00 AM

Title: Race, Derby and Server name generator
Post by: Ksna on July 21st, 2015, 09:00 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()] );
}
}

Title: Re: Race and Derby
Post by: KAKAN on July 21st, 2015, 09:57 AM
NIce work u did, u r gonna go far kid
Title: Re: Race and Derby
Post by: Awesome_Boy on July 21st, 2015, 10:47 AM
Amazing Release. we are waiting for vccnr
Title: Re: Race and Derby
Post by: DeViL_JiN on July 21st, 2015, 10:56 AM
Quote from Samrt_Boy on July 21st, 2015, 10:47 AM
Amazing Release. we are waiting for vccnr
(facepalm)
Title: Re: Race and Derby
Post by: MatheuS 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
Title: Re: Race and Derby
Post by: Honey on July 21st, 2015, 01:18 PM
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.
Title: Re: Race and Derby
Post by: [VSS]Shawn 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
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 21st, 2015, 02:17 PM
blind??? i say no more vccnr -__- noob
Title: Re: Race and Derby
Post by: Alterito on July 21st, 2015, 02:43 PM
Stop Bumping
(http://images.rapgenius.com/a28d5da00fd636d4125fa6c5372b562b.500x282x9.gif)
Title: Re: Race and Derby
Post by: 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
Title: Re: Race and Derby
Post by: Ksna 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
Title: Re: Race and Derby
Post by: Thijn 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.
Title: Re: Race and Derby
Post by: [VSS]Shawn 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
Title: Re: Race and Derby
Post by: Alterito on July 21st, 2015, 05:42 PM
Quote from DeViL_JiN on July 21st, 2015, 10:56 AM
Quote from Samrt_Boy on July 21st, 2015, 10:47 AM
Amazing Release. we are waiting for vccnr
(facepalm)
Hey Thijn is this not a spam?
Title: Re: Race and Derby
Post by: MacTavish on July 21st, 2015, 05:53 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
Title: Re: Race and Derby
Post by: Ksna on July 21st, 2015, 06:06 PM
Quote from Beztone on July 21st, 2015, 05:53 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
i actually made race first and derby same as race with little change and show me where is that derby system.
Title: Re: Race and Derby
Post by: MacTavish on July 21st, 2015, 06:37 PM
Quote from Ksna on July 21st, 2015, 06:06 PM
Quote from Beztone on July 21st, 2015, 05:53 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
i actually made race first and derby same as race with little change and show me where is that derby system.
Actually that link was too old and @ZippyShare erased those files from their server i will take that again when my friend got active
Title: Re: Race and Derby
Post by: Ksna on July 21st, 2015, 06:56 PM
Stop lying and if you have any doubts compare my script and your's friend script and post your friend's script if possible.
Title: Re: Race and Derby
Post by: KAKAN on July 21st, 2015, 06:59 PM
Wait Ksna, u really made it?
If yes, then its a nice work!
@VssShawn Have u ever made even 1 snippet? You are totally depended on here for the shit scripts, and I'm not jealous of Ksna, Ksna is one of my friend too
Title: Re: Race and Derby
Post by: DizzasTeR on July 21st, 2015, 07:03 PM
Just because of this much mess here on the topic of "CnR", I will start working on a Cops and Robbers script from tomorrow which I will release.

On the other hand, as Thijn said the snippet could be better.
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 21st, 2015, 07:39 PM
Good Luck Rasikh..

Kakan u just become friend because u are waiting for cnr ....

And Ksna I check that system something is missing onplayerkill ??? add their same one as Playerpart
Title: Re: Race and Derby
Post by: Ksna on July 22nd, 2015, 01:55 AM
Thanks Shawn, Updated.
Title: Re: Race and Derby
Post by: Joao^ on July 22nd, 2015, 03:27 AM
You can put on pastebin?
Title: Re: Race and Derby
Post by: Joao^ on July 22nd, 2015, 03:32 AM
?
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 22nd, 2015, 05:05 AM
lol there is already code even why u want in pastebin??
anyways there it is http://pastebin.com/nV4Vd5gB
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 22nd, 2015, 05:59 AM
what about it??

 ???

Code: [Select]
function onPlayerTeamKill( killer, killed, weapon, bodypart )
{
onPlayerKill( killer, killed, weapon, bodypart );
}


Add it
Title: Re: Race and Derby
Post by: ℛḝξ☂ on July 22nd, 2015, 06:04 AM
I'm looking forward you can make the race system with some checkpoints.
Title: Re: Race and Derby
Post by: KAKAN on July 22nd, 2015, 10:53 AM
Quote from [VSS]Shawn on July 21st, 2015, 07:39 PM
Kakan u just become friend because u are waiting for cnr ....
LOL, I was his friend earlier, when I saw Doom's server 1st
Title: Re: Race and Derby
Post by: Ksna on July 22nd, 2015, 12:31 PM
Quote
Code: [Select]
function onPlayerTeamKill( killer, killed, weapon, bodypart )
{
onPlayerKill( killer, killed, weapon, bodypart );
}
Added! It is not needed for free teams ;)
Title: Re: Race and Derby
Post by: Joao^ on July 22nd, 2015, 03:36 PM
earned very good score of 10 face
Title: Re: Race and Derby
Post by: Ksna on July 25th, 2015, 09:26 AM
Fixed bugs
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 25th, 2015, 04:23 PM
when i use this crepy code without /race


Code: [Select]
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.")
 }
 }

it say race not started do /joinrace
Shawn join race :\ wtf
Title: Re: Race and Derby
Post by: Ksna on July 25th, 2015, 04:54 PM
Yes, Player should start race by typing /race then do /joinrace
Title: Re: Race and Derby
Post by: [VSS]Shawn on July 25th, 2015, 05:25 PM
LoL Wth Do u think Some newbies will come and do /race they will do /joinrace btw i have fix it
Title: Re: Race, Derby and Server name generator
Post by: Ksna on July 28th, 2015, 07:07 AM
Server name generator added.
Title: Re: Race, Derby and Server name generator
Post by: BrYaN_FuRy on July 28th, 2015, 08:15 AM
Nice Work
Title: Re: Race, Derby and Server name generator
Post by: KAKAN on July 28th, 2015, 03:59 PM
I think the server name generator will not work... anyways I didn't test it, so nice
Title: Re: Race, Derby and Server name generator
Post by: FinchDon on September 28th, 2015, 01:40 PM
Sorry For Bump but Server name generator how this code will change server name?
Title: Re: Race, Derby and Server name generator
Post by: KAKAN on September 28th, 2015, 03:15 PM
See the code again and think. I'll tell you later