Jump to content
  • 0

Problema


AleX1321

Question

Am si eu o problema cand dau compile primesc eroarea asta.

C:UsersAleXDesktoptesxt.pwn(651) : error 030: compound statement not closed at the end of file (started at line 638)

[pawn]    if(response)

{

      if(listitem == 0)//daca dam click pe prima varianta, in cazul nostru Varianta1

  {

        SendClientMessage(playerid, 0x21DD00FF, "* Test..");

  TextDrawShowForPlayer(playerid, textdraw);

  DestroyPickup(pickup);

  dateren[playerid] = 1;

  Object = CreateObject(2113, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);

    }

else

    {

      SendClientMessage(playerid, 0x21DD00FF, "* Test..");

  return true;

}[/pawn]

si alta problema la fs asta primesc erori.

[pawn]/*                                          ________________________________

                      __,__                ( )

            .--.  .-"    "-.  .--.        ( Monky fix, good now, happy be!)

            / .. /  .-. .-.  / ..       (      Keep the credits! )

          | |  '|  /  Y    |'  | |    / (      )

          |     0 | 0 /  /  / |  /  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

            '- ,.-"`` ``"-./, -' /  /

            `'-' /_  ^ ^  _ '-'`  /

            .--'|  ._ _ _./  |'--.

          /`      .-.  /  /    `

          /      '._/  |-' _.'     

        /          ;  /--~'  |     

        /        .'|.---.         

      /  .'-. /.-.;  ||'~'-.|     

            `-./`|__/ `    `'.     

        '.      ;    ___)        '.`;    /

          '-.,_ ;    ___)          /  /

            ``'------'        `  /

            '.          '.      |  ;/_

          ___>    '.      _ _ _/  ,  '--.

        .'  '.  .-~~~~~-. /    |--'`~~-. 

      // / .---'/  .-~~-._/ / / /---..__.'  /

      ((_(_/    /  /      (_(_(_(---.__    .'

                | |    _              `~~`

                | |    '.

                '....' |

                  '.,___.'

#Name: [FilterScript]Don't Get Wet

    #Author: iMonk3y

    #Release Date: 31/01/2011

    #Credits:

¤ zcmd - Zeex      (http://forum.sa-mp.com/showthread.php?t=91354)

¤ foreach      - Y_Less    (http://forum.sa-mp.com/showthread.php?t=92679)

*/

#define FILTERSCRIPT

#include <a_samp>

#include <zcmd>

#include <foreach>

#define isodd(%1)

((%1) & 0x01)

#define iseven(%1)

(!isodd((%1)))

#define ALL_PLAYERS 200    //Define number of players on your server

#define MAX_SLOTS 54      //Don't change this

#define PRIZE_MONEY 10000

#define LIME 0x88AA62FF

#define WHITE 0xFFFFFFAA

#define RULE 0xFBDF89AA

#define ORANGE 0xDB881AAA

#define COL_LIME   

"{88AA62}"

#define COL_WHITE

"{FFFFFF}"

#define COL_RULE 

"{FBDF89}"

#define COL_ORANGE

"{DB881A}"

forward SpeedUp( object, Float:x, Float:y, Float:z);

forward RespawnPlayer( player );

forward MinigameWinner( player );

forward MinigameCountdown( );

forward MinigameUpdate( );

forward EndMinigame( );

new bool:Minigamer_[ALL_PLAYERS char];

new bool:VIEW_FROM_ABOVE;

new inProgress, uTimer;

new Objects_[2][MAX_SLOTS];

new pWeaponData[ALL_PLAYERS][13];

new pSavedAmmo[ALL_PLAYERS][13];

new Float:pCoords[ALL_PLAYERS][3];

new pInterior[ALL_PLAYERS];

new Iterator:_Minigamer <MAX_SLOTS>;

new Iterator:_Objects <MAX_SLOTS>;

new pReadyText[4][64] =

{

"~n~ ~n~ ~n~ ~y~stand by...",

"~n~ ~n~ ~n~ ~y~get Ready!",

"~n~ ~n~ ~n~ ~y~are you ready?",

"~n~ ~n~ ~n~ ~y~ready to get wet?"

};

new pFellOffText[5][28] =

{

"~n~ ~r~hosed",

"~n~ ~r~all wet",

"~n~ ~r~no swimming",

"~n~ ~r~you're drowning!",

"~n~ ~r~water... baaad!"

};

new Float:gCoords[MAX_SLOTS][3] = {

{ -5309.198120,-199.052383,22.593704 },

{ -5309.198120,-195.786071,22.593704 },

{ -5309.198120,-192.510620,22.593704 },

{ -5309.198120,-189.250564,22.593704 },

{ -5309.198120,-185.987960,22.593704 },

{ -5309.198120,-182.727081,22.593704 },

{ -5309.198120,-179.463394,22.593704 },

{ -5309.198120,-176.205261,22.593704 },

{ -5304.841796,-176.205261,22.593704 },

{ -5304.841796,-179.468795,22.593704 },

{ -5304.841796,-182.737884,22.593704 },

{ -5304.841796,-185.989654,22.593704 },

{ -5304.841796,-189.259185,22.593704 },

{ -5304.841796,-192.518615,22.593704 },

{ -5304.841796,-195.785491,22.593704 },

{ -5304.841796,-199.054733,22.593704 },

{ -5300.489990,-199.054733,22.593704 },

{ -5300.489990,-195.782165,22.593704 },

{ -5300.489990,-192.531250,22.593704 },

{ -5300.489990,-189.274765,22.593704 },

{ -5300.489990,-186.003005,22.593704 },

{ -5300.489990,-182.735229,22.593704 },

{ -5300.489990,-179.471069,22.593704 },

{ -5300.489990,-176.208007,22.593704 },

{ -5296.138061,-176.208007,22.593704 },

{ -5296.138061,-179.479248,22.593704 },

{ -5296.138061,-182.744735,22.593704 },

{ -5296.138061,-186.002944,22.593704 },

{ -5296.138061,-189.274505,22.593704 },

{ -5296.138061,-192.533691,22.593704 },

{ -5296.138061,-195.788970,22.593704 },

{ -5296.138061,-199.048782,22.593704 },

{ -5291.776000,-199.050140,22.593704 },

{ -5291.776000,-195.790634,22.593704 },

{ -5291.776000,-192.542922,22.593704 },

{ -5291.776000,-189.277542,22.593704 },

{ -5291.776000,-186.013275,22.593704 },

{ -5291.776000,-182.742355,22.593704 },

{ -5291.776000,-179.475021,22.593704 },

{ -5291.776000,-176.215805,22.593704 },

{ -5287.432250,-176.215805,22.593704 },

{ -5287.432250,-179.485168,22.593704 },

{ -5287.432250,-182.739608,22.593704 },

{ -5287.432250,-186.016723,22.593704 },

{ -5287.432250,-189.277816,22.593704 },

{ -5287.432250,-192.539001,22.593704 },

{ -5287.432250,-195.796325,22.593704 },

{ -5287.432250,-199.053771,22.593704 },

{ -5287.431274,-202.320648,22.593704 },

{ -5291.781616,-202.320648,22.593704 },

{ -5296.136718,-202.320648,22.593704 },

{ -5300.493652,-202.320648,22.593704 },

{ -5304.848876,-202.320648,22.593704 },

{ -5309.201660,-202.320648,22.593704 }

};

public OnFilterScriptInit( )

{

return 1;

}

public OnFilterScriptExit( )

{

    if( inProgress > 0 ) EndMinigame( );

return 1;

}

public OnPlayerDisconnect( playerid, reason )

{

    new str[128];

if( Minigamer_{ playerid } == true )

{

if( inProgress > 1 )

{

  format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer ) );

SendClientMessageToAll( LIME, str );

Iter_Remove(_Minigamer, playerid );

Minigamer_{ playerid } = false;

if( Iter_Count(_Minigamer ) < 2 )

{

    foreach(_Minigamer, i ) MinigameWinner( i );

}

}

else

{

    Iter_Remove(_Minigamer, playerid );

Minigamer_{ playerid } = false;

}

}

return 1;

}

public OnPlayerDeath( playerid, killerid, reason )

{

    new str[128];

if( Minigamer_{ playerid } == true )

{

if( inProgress > 1 )

{

  format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer ) );

SendClientMessageToAll( LIME, str );

Iter_Remove(_Minigamer, playerid );

Minigamer_{ playerid } = false;

if( Iter_Count(_Minigamer ) < 2 )

{

    foreach(_Minigamer, i ) MinigameWinner( i );

}

}

else

{

SendClientMessage( playerid, LIME, "Your sign up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame has been cancelled." );

Iter_Remove(_Minigamer, playerid );

Minigamer_{ playerid } = false;

}

}

return 1;

}

CMD:getwet( playerid, params[] )

{

    if( GetPlayerState( playerid ) == PLAYER_STATE_WASTED )

return SendClientMessage( playerid, LIME, "Command is temporary disabled because you're wasted." );

else if( Minigamer_{ playerid } != false )

return SendClientMessage( playerid, LIME, "You have already signed up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );

else if( inProgress > 1 )

return SendClientMessage( playerid, ORANGE, "Don't Get Wet "COL_LIME"minigame is currently in progress, please wait." );

else if( Iter_Count(_Minigamer ) > MAX_SLOTS-1 )

return SendClientMessage( playerid, ORANGE,"Don't Get Wet "COL_LIME"minigame is already full. Please wait untill it ends." );

    if( inProgress < 1 )

    {

    if( strcmp( params, "1", true ) == 0 )

    VIEW_FROM_ABOVE = true;

    else if( strcmp( params, "2", true ) == 0 )

VIEW_FROM_ABOVE = false;

    else return SendClientMessage( playerid, WHITE, "Use: /getwet [1 or 2]" );

new str[128];

Minigamer_{ playerid } = true;

Iter_Add(_Minigamer, playerid );

format( str, sizeof( str ), "Don't Get Wet v.%i.0 "COL_RULE"minigame will start in 20 seconds. Type "COL_ORANGE"/getwet "COL_RULE"to join!", strval(params) );

SendClientMessageToAll( ORANGE, str );

SetTimer( "MinigameCountdown", 20000, 0 );

for( new i; i < MAX_SLOTS; i++ )

    {

        //The object (window) is only visible from one side

Objects_[0] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -90.000000, 0.000000, 0.000000, 150.0 );

if(!VIEW_FROM_ABOVE) //In case /getwet 2, we need to multiply number of objects and turn them around so players would be able to see them from below

Objects_[1] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -270.000000, 0.000000, 0.000000, 150.0 );

Iter_Add(_Objects, i );

    }

    inProgress = 1;

    }

    else

    {

    Minigamer_{ playerid } = true;

Iter_Add(_Minigamer, playerid );

SendClientMessage( playerid, RULE,"You have signed up for "COL_ORANGE"Don't Get Wet "COL_RULE"minigame." );

}

return 1;

}

public MinigameCountdown( )

{

if( Iter_Count(_Minigamer ) < 2 ) //End minigame if there aren't enough sign ups

{

SendClientMessageToAll( LIME,"There wasn't enough players to start "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );

foreach(_Minigamer, i) Minigamer_{ i } = false;

return EndMinigame( );

}

if( inProgress != 2 )

{

    new spot;

foreach(_Minigamer, i )

{

    GetPlayerPos( i, pCoords[0], pCoords[1], pCoords[2]);

    pInterior = GetPlayerInterior( i );

    for( new a; a < 13; a++ )

{

      GetPlayerWeaponData( i, a, pWeaponData[a], pSavedAmmo[a] );

  }

ResetPlayerWeapons( i );

SetPlayerInterior( i, 0 );

spot = Iter_Random(_Objects );

    GameTextForPlayer( i, pReadyText[ random( sizeof( pReadyText ) ) ], 2050, 3 );

    Iter_Remove(_Objects, spot );

    SetPlayerCameraPos( i, -5298.4814,-218.4391,42.1386);

    SetPlayerCameraLookAt( i, -5298.1616,-189.6903,23.6564);

    TogglePlayerControllable( i, false );

SetPlayerPos( i, gCoords[spot][0], gCoords[spot][1], gCoords[spot][2] +0.5 );

}

Iter_Clear(_Objects);

for( new i; i < MAX_SLOTS; i++ ) Iter_Add(_Objects, i );

SetTimer( "MinigameCountdown", 2000, 0 );

inProgress = 2;

}

else

{

foreach(_Minigamer, i )

{

    if(!VIEW_FROM_ABOVE)

SetCameraBehindPlayer( i );

PlayerPlaySound( i, 1057, 0.0, 0.0, 0.0 );

TogglePlayerControllable( i, true );

}

uTimer = SetTimer( "MinigameUpdate", 2500, 1 );

}

return 1;

}

public MinigameUpdate( )

{

if( Iter_Count(_Minigamer ) < 1 ) return EndMinigame( );

new str[128], Float:playerx, Float:playery, Float:playerz[ALL_PLAYERS];

foreach(_Minigamer, i )

{

GetPlayerPos( i, playerx, playery, playerz );

if( playerz < 2.0 ) //Checks if player is in the water

{

format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( i ), Iter_Count(_Minigamer ) );

SendClientMessageToAll( LIME, str );

GameTextForPlayer( i, pFellOffText[ random( sizeof( pFellOffText ) ) ], 2500, 3 );

Iter_Remove(_Minigamer, i );

Minigamer_{ i } = false;

RespawnPlayer( i );

}

}

if( Iter_Count(_Minigamer ) < 2 )

{

foreach(_Minigamer, i ) MinigameWinner( i );

}

new objectid, Float:ObjectX, Float:ObjectY, Float:ObjectZ;

    if(!VIEW_FROM_ABOVE)

    {

foreach(_Objects, i )

{

if( isodd( random( 10 ) ) )

{

    GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );

MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );

  MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );

}

else

{

GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );

MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );

MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );

}

}

}

objectid = Iter_Random(_Objects );

GetObjectPos( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ );

SetTimerEx("SpeedUp", 500, 0, "ifff", objectid, ObjectX, ObjectY, ObjectZ);

MoveObject( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );

if(!VIEW_FROM_ABOVE)

MoveObject( Objects_[1][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );

    Iter_Remove(_Objects, objectid );

return 1;

}

public SpeedUp( object, Float:x, Float:y, Float:z )

{

MoveObject( Objects_[0][object], x, y, z -150, 20 );

if(!VIEW_FROM_ABOVE)

MoveObject( Objects_[1][object], x, y, z -150, 20 );

foreach(_Minigamer, i ) PlayerPlaySound( i, 1039, 0.0, 0.0, 0.0 );

}

public EndMinigame( )

{

for( new i; i < MAX_SLOTS; i++ )

{

    DestroyObject( Objects_[0] );

    if(!VIEW_FROM_ABOVE)

    DestroyObject( Objects_[1] );

}

inProgress = 0;

Iter_Clear(_Objects );

Iter_Clear(_Minigamer );

KillTimer( uTimer );

return 1;

}

public MinigameWinner( player )

{

new str[128];

format( str, sizeof( str ), "* %s "COL_RULE"has won "COL_ORANGE"Don't Get Wet "COL_RULE"minigame!", PlayerName( player ) );

SendClientMessageToAll( LIME, str );

GivePlayerMoney( player, PRIZE_MONEY );

Minigamer_{ player } = false;

Iter_Remove(_Minigamer, player );

SetTimerEx( "RespawnPlayer", 1400, 0, "i", player );

SetTimer( "EndMinigame", 1700, 0);

}

public RespawnPlayer ( player )

{

for( new i = 12; i > -1; i-- )

{

GivePlayerWeapon( player, pWeaponData[player], pSavedAmmo[player] );

}

SetPlayerPos( player, pCoords[player][0], pCoords[player][1], pCoords[player][2] );

  SetPlayerInterior( player, pInterior[player] );

  SetCameraBehindPlayer( player );

}

stock PlayerName( playerid )

{

new Name[MAX_PLAYER_NAME];

GetPlayerName( playerid, Name, sizeof( Name ) );

return Name;

}[/pawn]

[pawn]C:UsersAleXDesktopDontGetWet.pwn(84) : error 001: expected token: ";", but found "-identifier-"

C:UsersAleXDesktopDontGetWet.pwn(85) : error 001: expected token: ";", but found "-identifier-"

C:UsersAleXDesktopDontGetWet.pwn(180) : error 001: expected token: ")", but found "-identifier-"

C:UsersAleXDesktopDontGetWet.pwn(180) : error 029: invalid expression, assumed zero

C:UsersAleXDesktopDontGetWet.pwn(180) : warning 215: expression has no effect

C:UsersAleXDesktopDontGetWet.pwn(182) : error 017: undefined symbol "_Minigamer@YSII_Cg"

C:UsersAleXDesktopDontGetWet.pwn(182) : error 017: undefined symbol "_Minigamer@YSII_Ag"

C:UsersAleXDesktopDontGetWet.pwn(184) : error 001: expected token: ")", but found "-identifier-"

C:UsersAleXDesktopDontGetWet.pwn(184) : error 029: invalid expression, assumed zero

C:UsersAleXDesktopDontGetWet.pwn(184) : warning 215: expression has no effect

C:UsersAleXDesktopDontGetWet.pwn(184) : error 001: expected token: ";", but found ")"

C:UsersAleXDesktopDontGetWet.pwn(184) : fatal error 107: too many error messages on one line

[/pawn]

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

1.Schimba:

        return true;

    }

Cu asta:

        return true:

    }

    return false;

}

2.Incearca asta:

/*                                           ________________________________
                      __,__                 (								)
             .--.  .-"     "-.  .--.        ( Monky fix, good now, happy be!)
            / .. /  .-. .-.  / ..        (       Keep the credits! 		)
           | |  '|  /   Y     |'  | |    /	(      							)
           |       0 | 0 /  /   / |   /   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
             '- ,.-"`` ``"-./, -' /   /
             `'-' /_   ^ ^   _ '-'`   /
             .--'|  ._ _ _./  |'--.
           /`       .-.  /   /    `
          /       '._/  |-' _.'       
         /          ;  /--~'   |       
        /        .'|.---.            
       /   .'-. /.-.;  ||'~'-.|       
              `-./`|__/ `     `'.      
        '.      ;     ___)        '.`;    /
          '-.,_ ;     ___)          /   /
              ``'------'          `  /
            '.           '.      |   ;/_
          ___>     '.       _ _ _/   ,  '--.
        .'   '.   .-~~~~~-. /     |--'`~~-.  
       // / .---'/  .-~~-._/ / / /---..__.'  /
      ((_(_/    /  /      (_(_(_(---.__    .'
                | |     _              `~~`
                | |     '.
                  '....' |
                  '.,___.'

		#Name: [FilterScript]Don't Get Wet
    	#Author: iMonk3y
    	#Release Date: 31/01/2011
    	#Credits:
			¤ zcmd 			- Zeex      (http://forum.sa-mp.com/showthread.php?t=91354)
			¤ foreach       - Y_Less    (http://forum.sa-mp.com/showthread.php?t=92679)
*/

#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <foreach>

#define isodd(%1) 
	((%1) & 0x01)

#define iseven(%1) 
	(!isodd((%1)))

#define ALL_PLAYERS 	200     //Define number of players on your server
#define MAX_SLOTS 		54      //Don't change this

#define PRIZE_MONEY 	10000

#define LIME 		0x88AA62FF
#define WHITE 		0xFFFFFFAA
#define RULE 		0xFBDF89AA
#define ORANGE 		0xDB881AAA

#define COL_LIME    
	"{88AA62}"
#define COL_WHITE 	
	"{FFFFFF}"
#define COL_RULE   	
	"{FBDF89}"
#define COL_ORANGE	
	"{DB881A}"

forward SpeedUp( object, Float:x, Float:y, Float:z);
forward RespawnPlayer( player );
forward MinigameWinner( player );
forward MinigameCountdown( );
forward MinigameUpdate( );
forward EndMinigame( );

new bool:Minigamer_[ALL_PLAYERS char];
new bool:VIEW_FROM_ABOVE;
new inProgress, uTimer;
new Objects_[2][MAX_SLOTS];
new pWeaponData[ALL_PLAYERS][13];
new pSavedAmmo[ALL_PLAYERS][13];
new Float:pCoords[ALL_PLAYERS][3];
new pInterior[ALL_PLAYERS];

new Iterator:_Minigamer	<MAX_SLOTS>;
new Iterator:_Objects	<MAX_SLOTS>;

new pReadyText[4][64] =
{
	"~n~ ~n~ ~n~ ~y~stand by...",
	"~n~ ~n~ ~n~ ~y~get Ready!",
	"~n~ ~n~ ~n~ ~y~are you ready?",
	"~n~ ~n~ ~n~ ~y~ready to get wet?"
};

new pFellOffText[5][28] =
{
	"~n~ ~r~hosed",
	"~n~ ~r~all wet",
	"~n~ ~r~no swimming",
	"~n~ ~r~you're drowning!",
	"~n~ ~r~water... baaad!"
};

new Float:gCoords[MAX_SLOTS][3] = {

	{ -5309.198120,-199.052383,22.593704 },
	{ -5309.198120,-195.786071,22.593704 },
	{ -5309.198120,-192.510620,22.593704 },
	{ -5309.198120,-189.250564,22.593704 },
	{ -5309.198120,-185.987960,22.593704 },
	{ -5309.198120,-182.727081,22.593704 },
	{ -5309.198120,-179.463394,22.593704 },
	{ -5309.198120,-176.205261,22.593704 },
	{ -5304.841796,-176.205261,22.593704 },
	{ -5304.841796,-179.468795,22.593704 },
	{ -5304.841796,-182.737884,22.593704 },
	{ -5304.841796,-185.989654,22.593704 },
	{ -5304.841796,-189.259185,22.593704 },
	{ -5304.841796,-192.518615,22.593704 },
	{ -5304.841796,-195.785491,22.593704 },
	{ -5304.841796,-199.054733,22.593704 },
	{ -5300.489990,-199.054733,22.593704 },
	{ -5300.489990,-195.782165,22.593704 },
	{ -5300.489990,-192.531250,22.593704 },
	{ -5300.489990,-189.274765,22.593704 },
	{ -5300.489990,-186.003005,22.593704 },
	{ -5300.489990,-182.735229,22.593704 },
	{ -5300.489990,-179.471069,22.593704 },
	{ -5300.489990,-176.208007,22.593704 },
	{ -5296.138061,-176.208007,22.593704 },
	{ -5296.138061,-179.479248,22.593704 },
	{ -5296.138061,-182.744735,22.593704 },
	{ -5296.138061,-186.002944,22.593704 },
	{ -5296.138061,-189.274505,22.593704 },
	{ -5296.138061,-192.533691,22.593704 },
	{ -5296.138061,-195.788970,22.593704 },
	{ -5296.138061,-199.048782,22.593704 },
	{ -5291.776000,-199.050140,22.593704 },
	{ -5291.776000,-195.790634,22.593704 },
	{ -5291.776000,-192.542922,22.593704 },
	{ -5291.776000,-189.277542,22.593704 },
	{ -5291.776000,-186.013275,22.593704 },
	{ -5291.776000,-182.742355,22.593704 },
	{ -5291.776000,-179.475021,22.593704 },
	{ -5291.776000,-176.215805,22.593704 },
	{ -5287.432250,-176.215805,22.593704 },
	{ -5287.432250,-179.485168,22.593704 },
	{ -5287.432250,-182.739608,22.593704 },
	{ -5287.432250,-186.016723,22.593704 },
	{ -5287.432250,-189.277816,22.593704 },
	{ -5287.432250,-192.539001,22.593704 },
	{ -5287.432250,-195.796325,22.593704 },
	{ -5287.432250,-199.053771,22.593704 },
	{ -5287.431274,-202.320648,22.593704 },
	{ -5291.781616,-202.320648,22.593704 },
	{ -5296.136718,-202.320648,22.593704 },
	{ -5300.493652,-202.320648,22.593704 },
	{ -5304.848876,-202.320648,22.593704 },
	{ -5309.201660,-202.320648,22.593704 }
};

public OnFilterScriptInit( )
{
	return 1;
}

public OnFilterScriptExit( )
{
    if( inProgress > 0 ) EndMinigame( );
	return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
    new str[128];
	if( Minigamer_{ playerid } == true )
	{
		if( inProgress > 1 )
		{
   			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer ) );
			SendClientMessageToAll( LIME, str );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
			if( Iter_Count(_Minigamer ) < 2 )
			{
			    foreach(_Minigamer, i ) MinigameWinner( i );
			}
		}
		else
		{
		    Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
		}
	}
	return 1;
}

public OnPlayerDeath( playerid, killerid, reason )
{
    new str[128];
	if( Minigamer_{ playerid } == true )
	{
		if( inProgress > 1 )
		{
   			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer ) );
			SendClientMessageToAll( LIME, str );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
			if( Iter_Count(_Minigamer ) < 2 )
			{
			    foreach(_Minigamer, i ) MinigameWinner( i );
			}
		}
		else
		{
			SendClientMessage( playerid, LIME, "Your sign up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame has been cancelled." );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
		}
	}
	return 1;
}

CMD:getwet( playerid, params[] )
{
    if( GetPlayerState( playerid ) == PLAYER_STATE_WASTED )
		return SendClientMessage( playerid, LIME, "Command is temporary disabled because you're wasted." );
	else if( Minigamer_{ playerid } != false )
		return SendClientMessage( playerid, LIME, "You have already signed up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );
	else if( inProgress > 1 )
		return SendClientMessage( playerid, ORANGE, "Don't Get Wet "COL_LIME"minigame is currently in progress, please wait." );
	else if( Iter_Count(_Minigamer ) > MAX_SLOTS-1 )
		return SendClientMessage( playerid, ORANGE,"Don't Get Wet "COL_LIME"minigame is already full. Please wait untill it ends." );
    if( inProgress < 1 )
    {
	    if( strcmp( params, "1", true ) == 0 )
	    VIEW_FROM_ABOVE = true;
	    else if( strcmp( params, "2", true ) == 0 )
		VIEW_FROM_ABOVE = false;
	    else return SendClientMessage( playerid, WHITE, "Use: /getwet [1 or 2]" );

		new str[128];
		Minigamer_{ playerid } = true;
		Iter_Add(_Minigamer, playerid );
		format( str, sizeof( str ), "Don't Get Wet v.%i.0 "COL_RULE"minigame will start in 20 seconds. Type "COL_ORANGE"/getwet "COL_RULE"to join!", strval(params) );
		SendClientMessageToAll( ORANGE, str );
		SetTimer( "MinigameCountdown", 20000, 0 );
		for( new i; i < MAX_SLOTS; i++ )
	    {
	        //The object (window) is only visible from one side
			Objects_[0] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -90.000000, 0.000000, 0.000000, 150.0 );
			if(!VIEW_FROM_ABOVE) //In case /getwet 2, we need to multiply number of objects and turn them around so players would be able to see them from below
			Objects_[1] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -270.000000, 0.000000, 0.000000, 150.0 );
			Iter_Add(_Objects, i );
	    }
	    inProgress = 1;
    }
    else
    {
    	Minigamer_{ playerid } = true;
 		Iter_Add(_Minigamer, playerid );
		SendClientMessage( playerid, RULE,"You have signed up for "COL_ORANGE"Don't Get Wet "COL_RULE"minigame." );
	}
	return 1;
}

public MinigameCountdown( )
{
	if( Iter_Count(_Minigamer ) < 2 ) //End minigame if there aren't enough sign ups
	{
		SendClientMessageToAll( LIME,"There wasn't enough players to start "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );
		foreach(_Minigamer, i) Minigamer_{ i } = false;
		return EndMinigame( );
	}
	if( inProgress != 2 )
	{
	    new spot;
		foreach(_Minigamer, i )
		{
     		GetPlayerPos( i, pCoords[0], pCoords[1], pCoords[2]);
     		pInterior = GetPlayerInterior( i );
     		for( new a; a < 13; a++ )
			{
		      	GetPlayerWeaponData( i, a, pWeaponData[a], pSavedAmmo[a] );
  			}
			ResetPlayerWeapons( i );
			SetPlayerInterior( i, 0 );
			spot = Iter_Random(_Objects );
     		GameTextForPlayer( i, pReadyText[ random( sizeof( pReadyText ) ) ], 2050, 3 );
     		Iter_Remove(_Objects, spot );
     		SetPlayerCameraPos( i, -5298.4814,-218.4391,42.1386);
     		SetPlayerCameraLookAt( i, -5298.1616,-189.6903,23.6564);
     		TogglePlayerControllable( i, false );
			SetPlayerPos( i, gCoords[spot][0], gCoords[spot][1], gCoords[spot][2] +0.5 );
		}
		Iter_Clear(_Objects);
		for( new i; i < MAX_SLOTS; i++ ) Iter_Add(_Objects, i );
		SetTimer( "MinigameCountdown", 2000, 0 );
		inProgress = 2;
	}
	else
	{
		foreach(_Minigamer, i )
		{
		    if(!VIEW_FROM_ABOVE)
			SetCameraBehindPlayer( i );
			PlayerPlaySound( i, 1057, 0.0, 0.0, 0.0 );
			TogglePlayerControllable( i, true );
		}
		uTimer = SetTimer( "MinigameUpdate", 2500, 1 );
	}
	return 1;
}

public MinigameUpdate( )
{
	if( Iter_Count(_Minigamer ) < 1 ) return EndMinigame( );

	new str[128], Float:playerx, Float:playery, Float:playerz[ALL_PLAYERS];
	foreach(_Minigamer, i )
	{
		GetPlayerPos( i, playerx, playery, playerz );
		if( playerz < 2.0 ) //Checks if player is in the water
		{
			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( i ), Iter_Count(_Minigamer ) );
			SendClientMessageToAll( LIME, str );
			GameTextForPlayer( i, pFellOffText[ random( sizeof( pFellOffText ) ) ], 2500, 3 );
			Iter_Remove(_Minigamer, i );
			Minigamer_{ i } = false;
			RespawnPlayer( i );
		}
	}
	if( Iter_Count(_Minigamer ) < 2 )
	{
 		foreach(_Minigamer, i ) MinigameWinner( i );
	}
 	new objectid, Float:ObjectX, Float:ObjectY, Float:ObjectZ;

    if(!VIEW_FROM_ABOVE)
    {
	 	foreach(_Objects, i )
		{
			if( isodd( random( 10 ) ) )
			{
		 	    GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );
				MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );
	   			MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );
			}
			else
			{
				GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );
				MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );
				MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );
			}
		}
	}

 	objectid = Iter_Random(_Objects );
	GetObjectPos( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ );
	SetTimerEx("SpeedUp", 500, 0, "ifff", objectid, ObjectX, ObjectY, ObjectZ);
	MoveObject( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );
	if(!VIEW_FROM_ABOVE)
	MoveObject( Objects_[1][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );
    Iter_Remove(_Objects, objectid );
	return 1;
}

public SpeedUp( object, Float:x, Float:y, Float:z )
{
	MoveObject( Objects_[0][object], x, y, z -150, 20 );
	if(!VIEW_FROM_ABOVE)
	MoveObject( Objects_[1][object], x, y, z -150, 20 );
	foreach(_Minigamer, i ) PlayerPlaySound( i, 1039, 0.0, 0.0, 0.0 );
}

public EndMinigame( )
{
	for( new i; i < MAX_SLOTS; i++ )
 	{
 	    DestroyObject( Objects_[0] );
 	    if(!VIEW_FROM_ABOVE)
 	    DestroyObject( Objects_[1] );
 	}
 	inProgress = 0;
	Iter_Clear(_Objects );
	Iter_Clear(_Minigamer );
	KillTimer( uTimer );
	return 1;
}

public MinigameWinner( player )
{
	new str[128];
	format( str, sizeof( str ), "* %s "COL_RULE"has won "COL_ORANGE"Don't Get Wet "COL_RULE"minigame!", PlayerName( player ) );
	SendClientMessageToAll( LIME, str );
 	GivePlayerMoney( player, PRIZE_MONEY );
 	Minigamer_{ player } = false;
	Iter_Remove(_Minigamer, player );
	SetTimerEx( "RespawnPlayer", 1400, 0, "i", player );
	SetTimer( "EndMinigame", 1700, 0);
}

public RespawnPlayer ( player )
{
	for( new i = 12; i > -1; i-- )
	{
		GivePlayerWeapon( player, pWeaponData[player], pSavedAmmo[player] );
	}
	SetPlayerPos( player, pCoords[player][0], pCoords[player][1], pCoords[player][2] );
   	SetPlayerInterior( player, pInterior[player] );
   	SetCameraBehindPlayer( player );
}

stock PlayerName( playerid )
{
	new Name[MAX_PLAYER_NAME];
	GetPlayerName( playerid, Name, sizeof( Name ) );
	return Name;
}

Link to comment
Share on other sites

1.Tot la fel

2.Tot la fel ,aceleasi erori.

1.Da-mi tot public-ul.

2.Incearca asta:

/*                                           ________________________________
                      __,__                 (								)
             .--.  .-"     "-.  .--.        ( Monky fix, good now, happy be!)
            / .. /  .-. .-.  / ..        (       Keep the credits! 		)
           | |  '|  /   Y     |'  | |    /	(      							)
           |       0 | 0 /  /   / |   /   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
             '- ,.-"`` ``"-./, -' /   /
             `'-' /_   ^ ^   _ '-'`   /
             .--'|  ._ _ _./  |'--.
           /`       .-.  /   /    `
          /       '._/  |-' _.'       
         /          ;  /--~'   |       
        /        .'|.---.            
       /   .'-. /.-.;  ||'~'-.|       
              `-./`|__/ `     `'.      
        '.      ;     ___)        '.`;    /
          '-.,_ ;     ___)          /   /
              ``'------'          `  /
            '.           '.      |   ;/_
          ___>     '.       _ _ _/   ,  '--.
        .'   '.   .-~~~~~-. /     |--'`~~-.  
       // / .---'/  .-~~-._/ / / /---..__.'  /
      ((_(_/    /  /      (_(_(_(---.__    .'
                | |     _              `~~`
                | |     '.
                  '....' |
                  '.,___.'

		#Name: [FilterScript]Don't Get Wet
    	#Author: iMonk3y
    	#Release Date: 31/01/2011
    	#Credits:
			¤ zcmd 			- Zeex      (http://forum.sa-mp.com/showthread.php?t=91354)
			¤ foreach       - Y_Less    (http://forum.sa-mp.com/showthread.php?t=92679)
*/

#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <foreach>

#define isodd(%1) 
	((%1) & 0x01)

#define iseven(%1) 
	(!isodd((%1)))

#define ALL_PLAYERS 	200     //Define number of players on your server
#define MAX_SLOTS 		54      //Don't change this

#define PRIZE_MONEY 	10000

#define LIME 		0x88AA62FF
#define WHITE 		0xFFFFFFAA
#define RULE 		0xFBDF89AA
#define ORANGE 		0xDB881AAA

#define COL_LIME    
	"{88AA62}"
#define COL_WHITE 	
	"{FFFFFF}"
#define COL_RULE   	
	"{FBDF89}"
#define COL_ORANGE	
	"{DB881A}"

forward SpeedUp( object, Float:x, Float:y, Float:z);
forward RespawnPlayer( player );
forward MinigameWinner( player );
forward MinigameCountdown( );
forward MinigameUpdate( );
forward EndMinigame( );

new bool:Minigamer_[ALL_PLAYERS char];
new bool:VIEW_FROM_ABOVE;
new inProgress, uTimer;
new Objects_[2][MAX_SLOTS];
new pWeaponData[ALL_PLAYERS][13];
new pSavedAmmo[ALL_PLAYERS][13];
new Float:pCoords[ALL_PLAYERS][3];
new pInterior[ALL_PLAYERS];

new Iterator:_Minigamer<MAX_SLOTS>;
new Iterator:_Objects<MAX_SLOTS>;

new pReadyText[4][64] =
{
	"~n~ ~n~ ~n~ ~y~stand by...",
	"~n~ ~n~ ~n~ ~y~get Ready!",
	"~n~ ~n~ ~n~ ~y~are you ready?",
	"~n~ ~n~ ~n~ ~y~ready to get wet?"
};

new pFellOffText[5][28] =
{
	"~n~ ~r~hosed",
	"~n~ ~r~all wet",
	"~n~ ~r~no swimming",
	"~n~ ~r~you're drowning!",
	"~n~ ~r~water... baaad!"
};

new Float:gCoords[MAX_SLOTS][3] = {

	{ -5309.198120,-199.052383,22.593704 },
	{ -5309.198120,-195.786071,22.593704 },
	{ -5309.198120,-192.510620,22.593704 },
	{ -5309.198120,-189.250564,22.593704 },
	{ -5309.198120,-185.987960,22.593704 },
	{ -5309.198120,-182.727081,22.593704 },
	{ -5309.198120,-179.463394,22.593704 },
	{ -5309.198120,-176.205261,22.593704 },
	{ -5304.841796,-176.205261,22.593704 },
	{ -5304.841796,-179.468795,22.593704 },
	{ -5304.841796,-182.737884,22.593704 },
	{ -5304.841796,-185.989654,22.593704 },
	{ -5304.841796,-189.259185,22.593704 },
	{ -5304.841796,-192.518615,22.593704 },
	{ -5304.841796,-195.785491,22.593704 },
	{ -5304.841796,-199.054733,22.593704 },
	{ -5300.489990,-199.054733,22.593704 },
	{ -5300.489990,-195.782165,22.593704 },
	{ -5300.489990,-192.531250,22.593704 },
	{ -5300.489990,-189.274765,22.593704 },
	{ -5300.489990,-186.003005,22.593704 },
	{ -5300.489990,-182.735229,22.593704 },
	{ -5300.489990,-179.471069,22.593704 },
	{ -5300.489990,-176.208007,22.593704 },
	{ -5296.138061,-176.208007,22.593704 },
	{ -5296.138061,-179.479248,22.593704 },
	{ -5296.138061,-182.744735,22.593704 },
	{ -5296.138061,-186.002944,22.593704 },
	{ -5296.138061,-189.274505,22.593704 },
	{ -5296.138061,-192.533691,22.593704 },
	{ -5296.138061,-195.788970,22.593704 },
	{ -5296.138061,-199.048782,22.593704 },
	{ -5291.776000,-199.050140,22.593704 },
	{ -5291.776000,-195.790634,22.593704 },
	{ -5291.776000,-192.542922,22.593704 },
	{ -5291.776000,-189.277542,22.593704 },
	{ -5291.776000,-186.013275,22.593704 },
	{ -5291.776000,-182.742355,22.593704 },
	{ -5291.776000,-179.475021,22.593704 },
	{ -5291.776000,-176.215805,22.593704 },
	{ -5287.432250,-176.215805,22.593704 },
	{ -5287.432250,-179.485168,22.593704 },
	{ -5287.432250,-182.739608,22.593704 },
	{ -5287.432250,-186.016723,22.593704 },
	{ -5287.432250,-189.277816,22.593704 },
	{ -5287.432250,-192.539001,22.593704 },
	{ -5287.432250,-195.796325,22.593704 },
	{ -5287.432250,-199.053771,22.593704 },
	{ -5287.431274,-202.320648,22.593704 },
	{ -5291.781616,-202.320648,22.593704 },
	{ -5296.136718,-202.320648,22.593704 },
	{ -5300.493652,-202.320648,22.593704 },
	{ -5304.848876,-202.320648,22.593704 },
	{ -5309.201660,-202.320648,22.593704 }
};

public OnFilterScriptInit( )
{
	return 1;
}

public OnFilterScriptExit( )
{
    if( inProgress > 0 ) EndMinigame( );
	return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
    new str[128];
	if( Minigamer_{ playerid } == true )
	{
		if( inProgress > 1 )
		{
   			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer) );
			SendClientMessageToAll( LIME, str );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
			if( Iter_Count(_Minigamer) < 2 )
			{
			    foreach(_Minigamer, i ) MinigameWinner( i );
			}
		}
		else
		{
		    Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
		}
	}
	return 1;
}

public OnPlayerDeath( playerid, killerid, reason )
{
    new str[128];
	if( Minigamer_{ playerid } == true )
	{
		if( inProgress > 1 )
		{
   			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( playerid ), Iter_Count(_Minigamer) );
			SendClientMessageToAll( LIME, str );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
			if( Iter_Count(_Minigamer) < 2 )
			{
			    foreach(_Minigamer, i ) MinigameWinner( i );
			}
		}
		else
		{
			SendClientMessage( playerid, LIME, "Your sign up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame has been cancelled." );
			Iter_Remove(_Minigamer, playerid );
			Minigamer_{ playerid } = false;
		}
	}
	return 1;
}

CMD:getwet( playerid, params[] )
{
    if( GetPlayerState( playerid ) == PLAYER_STATE_WASTED )
		return SendClientMessage( playerid, LIME, "Command is temporary disabled because you're wasted." );
	else if( Minigamer_{ playerid } != false )
		return SendClientMessage( playerid, LIME, "You have already signed up for "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );
	else if( inProgress > 1 )
		return SendClientMessage( playerid, ORANGE, "Don't Get Wet "COL_LIME"minigame is currently in progress, please wait." );
	else if( Iter_Count(_Minigamer) > MAX_SLOTS-1 )
		return SendClientMessage( playerid, ORANGE,"Don't Get Wet "COL_LIME"minigame is already full. Please wait untill it ends." );
    if( inProgress < 1 )
    {
	    if( strcmp( params, "1", true ) == 0 )
	    VIEW_FROM_ABOVE = true;
	    else if( strcmp( params, "2", true ) == 0 )
		VIEW_FROM_ABOVE = false;
	    else return SendClientMessage( playerid, WHITE, "Use: /getwet [1 or 2]" );

		new str[128];
		Minigamer_{ playerid } = true;
		Iter_Add(_Minigamer, playerid );
		format( str, sizeof( str ), "Don't Get Wet v.%i.0 "COL_RULE"minigame will start in 20 seconds. Type "COL_ORANGE"/getwet "COL_RULE"to join!", strval(params) );
		SendClientMessageToAll( ORANGE, str );
		SetTimer( "MinigameCountdown", 20000, 0 );
		for( new i; i < MAX_SLOTS; i++ )
	    {
	        //The object (window) is only visible from one side
			Objects_[0] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -90.000000, 0.000000, 0.000000, 150.0 );
			if(!VIEW_FROM_ABOVE) //In case /getwet 2, we need to multiply number of objects and turn them around so players would be able to see them from below
			Objects_[1] = CreateObject( 1649, gCoords[0], gCoords[1], gCoords[2], -270.000000, 0.000000, 0.000000, 150.0 );
			Iter_Add(_Objects, i );
	    }
	    inProgress = 1;
    }
    else
    {
    	Minigamer_{ playerid } = true;
 		Iter_Add(_Minigamer, playerid );
		SendClientMessage( playerid, RULE,"You have signed up for "COL_ORANGE"Don't Get Wet "COL_RULE"minigame." );
	}
	return 1;
}

public MinigameCountdown( )
{
	if( Iter_Count(_Minigamer) < 2 ) //End minigame if there aren't enough sign ups
	{
		SendClientMessageToAll( LIME,"There wasn't enough players to start "COL_ORANGE"Don't Get Wet"COL_LIME" minigame." );
		foreach(_Minigamer, i) Minigamer_{ i } = false;
		return EndMinigame( );
	}
	if( inProgress != 2 )
	{
	    new spot;
		foreach(_Minigamer, i )
		{
     		GetPlayerPos( i, pCoords[0], pCoords[1], pCoords[2]);
     		pInterior = GetPlayerInterior( i );
     		for( new a; a < 13; a++ )
			{
		      	GetPlayerWeaponData( i, a, pWeaponData[a], pSavedAmmo[a] );
  			}
			ResetPlayerWeapons( i );
			SetPlayerInterior( i, 0 );
			spot = Iter_Random(_Objects);
     		GameTextForPlayer( i, pReadyText[ random( sizeof( pReadyText ) ) ], 2050, 3 );
     		Iter_Remove(_Objects, spot );
     		SetPlayerCameraPos( i, -5298.4814,-218.4391,42.1386);
     		SetPlayerCameraLookAt( i, -5298.1616,-189.6903,23.6564);
     		TogglePlayerControllable( i, false );
			SetPlayerPos( i, gCoords[spot][0], gCoords[spot][1], gCoords[spot][2] +0.5 );
		}
		Iter_Clear(_Objects);
		for( new i; i < MAX_SLOTS; i++ ) Iter_Add(_Objects, i );
		SetTimer( "MinigameCountdown", 2000, 0 );
		inProgress = 2;
	}
	else
	{
		foreach(_Minigamer, i )
		{
		    if(!VIEW_FROM_ABOVE)
			SetCameraBehindPlayer( i );
			PlayerPlaySound( i, 1057, 0.0, 0.0, 0.0 );
			TogglePlayerControllable( i, true );
		}
		uTimer = SetTimer( "MinigameUpdate", 2500, 1 );
	}
	return 1;
}

public MinigameUpdate( )
{
	if( Iter_Count(_Minigamer) < 1 ) return EndMinigame( );

	new str[128], Float:playerx, Float:playery, Float:playerz[ALL_PLAYERS];
	foreach(_Minigamer, i )
	{
		GetPlayerPos( i, playerx, playery, playerz );
		if( playerz < 2.0 ) //Checks if player is in the water
		{
			format( str, sizeof( str ), "* %s "COL_RULE"has dropped out of "COL_ORANGE"Don't Get Wet"COL_RULE" minigame, "COL_LIME"rank %d", PlayerName( i ), Iter_Count(_Minigamer) );
			SendClientMessageToAll( LIME, str );
			GameTextForPlayer( i, pFellOffText[ random( sizeof( pFellOffText ) ) ], 2500, 3 );
			Iter_Remove(_Minigamer, i );
			Minigamer_{ i } = false;
			RespawnPlayer( i );
		}
	}
	if( Iter_Count(_Minigamer) < 2 )
	{
 		foreach(_Minigamer, i ) MinigameWinner( i );
	}
 	new objectid, Float:ObjectX, Float:ObjectY, Float:ObjectZ;

    if(!VIEW_FROM_ABOVE)
    {
	 	foreach(_Objects, i )
		{
			if( isodd( random( 10 ) ) )
			{
		 	    GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );
				MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );
	   			MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ -1.5, 0.2 );
			}
			else
			{
				GetObjectPos( Objects_[0], ObjectX, ObjectY, ObjectZ );
				MoveObject( Objects_[0], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );
				MoveObject( Objects_[1], ObjectX, ObjectY, ObjectZ +1.5, 0.2 );
			}
		}
	}

 	objectid = Iter_Random(_Objects);
	GetObjectPos( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ );
	SetTimerEx("SpeedUp", 500, 0, "ifff", objectid, ObjectX, ObjectY, ObjectZ);
	MoveObject( Objects_[0][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );
	if(!VIEW_FROM_ABOVE)
	MoveObject( Objects_[1][objectid], ObjectX, ObjectY, ObjectZ -5, 1 );
    Iter_Remove(_Objects, objectid );
	return 1;
}

public SpeedUp( object, Float:x, Float:y, Float:z )
{
	MoveObject( Objects_[0][object], x, y, z -150, 20 );
	if(!VIEW_FROM_ABOVE)
	MoveObject( Objects_[1][object], x, y, z -150, 20 );
	foreach(_Minigamer, i ) PlayerPlaySound( i, 1039, 0.0, 0.0, 0.0 );
}

public EndMinigame( )
{
	for( new i; i < MAX_SLOTS; i++ )
 	{
 	    DestroyObject( Objects_[0] );
 	    if(!VIEW_FROM_ABOVE)
 	    DestroyObject( Objects_[1] );
 	}
 	inProgress = 0;
	Iter_Clear(_Objects);
	Iter_Clear(_Minigamer);
	KillTimer( uTimer );
	return 1;
}

public MinigameWinner( player )
{
	new str[128];
	format( str, sizeof( str ), "* %s "COL_RULE"has won "COL_ORANGE"Don't Get Wet "COL_RULE"minigame!", PlayerName( player ) );
	SendClientMessageToAll( LIME, str );
 	GivePlayerMoney( player, PRIZE_MONEY );
 	Minigamer_{ player } = false;
	Iter_Remove(_Minigamer, player );
	SetTimerEx( "RespawnPlayer", 1400, 0, "i", player );
	SetTimer( "EndMinigame", 1700, 0);
}

public RespawnPlayer ( player )
{
	for( new i = 12; i > -1; i-- )
	{
		GivePlayerWeapon( player, pWeaponData[player], pSavedAmmo[player] );
	}
	SetPlayerPos( player, pCoords[player][0], pCoords[player][1], pCoords[player][2] );
   	SetPlayerInterior( player, pInterior[player] );
   	SetCameraBehindPlayer( player );
}

stock PlayerName( playerid )
{
	new Name[MAX_PLAYER_NAME];
	GetPlayerName( playerid, Name, sizeof( Name ) );
	return Name;
}

Link to comment
Share on other sites

[pawn]public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

{

  if(dialogid==dialogtest)

{

    if(response)

{

      if(listitem == 0)

  {

      SendClientMessage(playerid, 0x21DD00FF, "* Test:..");

  TextDrawShowForPlayer(playerid, textdraw);

  DestroyPickup(pickup);

  dateren[playerid] = 1;

  Ball = CreateObject(2114, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);

    }

else

    {

      SendClientMessage(playerid, 0x21DD00FF, "* Test:..");

        return true;

    }

    return false;

}[/pawn]

2.Iti multumesc,merge.

Link to comment
Share on other sites

public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [ ] )

{

if ( dialogid == dialogtest )

{

if ( response )

{

if ( listitem == 0 )

{

#define SCM SendClientMessage

SCM ( playerid , 0x21DD00FF , "* Test:.." ) ;

TextDrawShowForPlayer ( playerid , textdraw ) ;

DestroyPickup ( pickup ) ;

dateren [ playerid ] = 1 ;

Ball = CreateObject ( 2114 , 2782.3027 , -2019.0826 , 13.5547-0.8 , 0 , 0 , 96 ) ;

}

else

{

SCM ( playerid , 0x21DD00FF , "* Test:.." ) ;

return true ;

}

}

  return false ;

   

}

Link to comment
Share on other sites

Merge,iti multumesc.

Dar mai am o problema

[pawn]/*

                            ---- TRIATHLON MINIGAME ----

                                ---- CREATED BY ----

  ______  ____      ______      ____ ___

  |    | |      /\  |  |  | |    |__|

  |    | |---- /--\  |  |---| |---- | \

    _|____| |____/    \ |  |  | |____ |  \

    - BORN TO KIL

    ---- CREDITS ----

1. ZeeX - zcmd

2. niCe - 'IsPlayerAiming' function

  ---- IMPORTANT ----

You can edit this to your satisfaction and use it in your server.

But you are not allowed to re-sell/release it as your script anywhere.

*/

#include <a_samp>

#include <zcmd>

//===================================//

#define RED 0xFF0000C7

#define GREEN 0x33AA33AA

#define ORANGE 0xFF9900AA

#define TITANIUM 0xFCFFF0AA

#define CORAL 0xEFC286FF

#define GOLD 0xB8860BAA

#define MAX_OBJS  100

#define MAX_TOBJS  29 // No of other objects

#define MAX_RAND 32767 //Donot Change!!!

#define FINAL_CP_CYCLE 16

#define FINAL_CP_SWIM 9

#define HIDE_TEXT_TIME 20000 //Time in milliseconds to display the final statistics

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

//===================================//

new Float:MiniSpawns[8][4] =

{

    {1237.001343,-2031.758545,60.551205,268.0000},

{1237.087769,-2030.034424,60.576206,268.0000},

{1237.237793,-2027.961792,60.426197,268.0000},

{1237.336670,-2025.825806,60.326191,268.0000},

{1240.417236,-2031.980713,59.476139,268.0000},

{1240.311157,-2026.085327,59.526142,268.0000},

{1240.278809,-2028.149902,59.551144,268.0000},

{1240.300537,-2030.038940,59.526142,268.0000}

};

new tObj[MAX_TOBJS];

new tVeh[8];

//I created this long time ago (Before Pvars were created) I didnt have time to change them.

new PCP[MAX_PLAYERS];

new PlayerJoined[MAX_PLAYERS];

new bool:MiniOn;

new TP;

new inctimer[MAX_PLAYERS];

new MIN[MAX_PLAYERS];

new SEC[MAX_PLAYERS];

new First;

new winner[MAX_PLAYER_NAME];

new Text:Tbg;

new Text:TT[MAX_PLAYERS];

new Text:NO[MAX_PLAYERS];

new Text:BG;

new Text:TR;

new Text:C_TT[MAX_PLAYERS];

new Text:C_CP[MAX_PLAYERS];

new Text:A_TT[MAX_PLAYERS];

new Text:A_OB[MAX_PLAYERS];

new Text:A_AC[MAX_PLAYERS];

new Text:S_CP[MAX_PLAYERS];

new Text:S_TT[MAX_PLAYERS];

new Text:Cycle;

new Text:Shoot;

new Text:Swim;

new Text:T_TT[MAX_PLAYERS];

new Text:Winner;

//***************************MOUNTAIN BIKE RACE*******************************//

new Float:CRaceCPoints[17][3] =

{

{1273.332275,-2056.174316,58.064869},

{1389.242432,-2047.083130,54.034203},

{1426.094849,-1988.133789,48.100159},

{1315.031494,-1957.947998,28.298063},

{1260.021973,-1908.830322,28.799747},

{1422.825806,-1922.275146,14.627296},

{1332.206909,-1853.607300,12.382813},

{1222.804077,-1852.206665,12.382813},

{1061.719849,-1849.264771,12.567745},

{983.637329,-1785.176270,13.074606},

{843.459045,-1769.413818,12.395102},

{827.917297,-1841.450439,11.644958},

{845.218689,-1890.641602,11.867188},

{830.854797,-1943.510010,11.867188},

{844.152771,-2001.475952,11.867188},

{835.849304,-2055.608154,11.867188},

{0.0,0.0,0.0}

};

new bool:IsPlayerRacing[MAX_PLAYERS];

new c_minutes[MAX_PLAYERS];

new c_seconds[MAX_PLAYERS];

//*******************************SHOOTING RANGE*******************************//

enum moveobjs

{

Float:obX[MAX_PLAYERS],

Float:obY[MAX_PLAYERS],

Float:obZ[MAX_PLAYERS]

};

new Float:rand_float[17] = //Speed with which the objects move

{0.8, 0.9, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9};

new AimObject[MAX_OBJS][moveobjs];

new A_Objects[MAX_OBJS][MAX_PLAYERS];

new pobjects[MAX_PLAYERS];

new robjects[MAX_PLAYERS];

new obj_hit[MAX_PLAYERS];

new shootpick[5];

new oCount = 0;

new bool:IsPlayerShooting[MAX_PLAYERS];

new a_minutes[MAX_PLAYERS];

new a_seconds[MAX_PLAYERS];

new Float:accuracy[MAX_PLAYERS];

//********************************SWIMMING RACE*******************************//

new Float:SRaceCPoints[10][3] =

{

{834.885010,-2094.992676,0.007755},

{719.189026,-2094.839844,0.009658},

{725.342163,-1969.148926,0.055709},

{724.468750,-1887.028687,-0.014958},

{724.574524,-1778.495361,-0.020918},

{723.868225,-1695.539795,-0.069923},

{724.020508,-1580.007324,0.069664},

{723.220154,-1488.487915,0.934345},

{728.4586,-1440.3844,17.6953},

{0.0,0.0,0.0}

};

new bool:IsPlayerSwimming[MAX_PLAYERS];

new s_minutes[MAX_PLAYERS];

new s_seconds[MAX_PLAYERS];

//===================================//

forward StartCycleRace();

forward StopCycleRaceForPlayer(playerid);

forward TextDrawUpdate(playerid);

forward StartAccuTest(playerid);

forward StartShootingForPlayer(playerid);

forward EndShootingForPlayer(playerid);

forward StartSwimmingForPlayer(playerid);

forward StopSwimmingForPlayer(playerid);

forward EndTriathlon();

forward HideText();

//===================================//

public OnFilterScriptInit()

{

    Tbg = TextDrawCreate(630.000000, 371.000000, "_");

TextDrawBackgroundColor(Tbg, 255);

TextDrawFont(Tbg, 1);

TextDrawLetterSize(Tbg, 0.500000, 7.200000);

TextDrawColor(Tbg, -1);

TextDrawSetOutline(Tbg, 0);

TextDrawSetProportional(Tbg, 1);

TextDrawSetShadow(Tbg, 1);

TextDrawUseBox(Tbg, 1);

TextDrawBoxColor(Tbg, 252645270);

TextDrawTextSize(Tbg, 460.000000, 40.000000);

BG = TextDrawCreate(505.000000, 129.000000, "_");

TextDrawBackgroundColor(BG, 255);

TextDrawFont(BG, 1);

TextDrawLetterSize(BG, 0.549998, 23.600002);

TextDrawColor(BG, -1);

TextDrawSetOutline(BG, 1);

TextDrawSetProportional(BG, 1);

TextDrawUseBox(BG, 1);

TextDrawBoxColor(BG, 252645270);

TextDrawTextSize(BG, 108.000000, 0.000000);

TR = TextDrawCreate(204.000000, 128.000000, "TRIATHLON RESULTS");

TextDrawBackgroundColor(TR, 255);

TextDrawFont(TR, 2);

TextDrawLetterSize(TR, 0.500000, 1.500000);

TextDrawColor(TR, 845453000);

TextDrawSetOutline(TR, 0);

TextDrawSetProportional(TR, 1);

TextDrawSetShadow(TR, 1);

Cycle = TextDrawCreate(149.000000, 150.000000, "Cycling");

TextDrawBackgroundColor(Cycle, 255);

TextDrawFont(Cycle, 1);

TextDrawLetterSize(Cycle, 0.480000, 1.200000);

TextDrawColor(Cycle, -1);

TextDrawSetOutline(Cycle, 0);

TextDrawSetProportional(Cycle, 1);

TextDrawSetShadow(Cycle, 1);

Shoot = TextDrawCreate(265.000000, 150.000000, "Shooting");

TextDrawBackgroundColor(Shoot, 255);

TextDrawFont(Shoot, 1);

TextDrawLetterSize(Shoot, 0.480000, 1.200000);

TextDrawColor(Shoot, -1);

TextDrawSetOutline(Shoot, 0);

TextDrawSetProportional(Shoot, 1);

TextDrawSetShadow(Shoot, 1);

Swim = TextDrawCreate(390.000000, 150.000000, "Swimming");

TextDrawBackgroundColor(Swim, 255);

TextDrawFont(Swim, 1);

TextDrawLetterSize(Swim, 0.480000, 1.200000);

TextDrawColor(Swim, -1);

TextDrawSetOutline(Swim, 0);

TextDrawSetProportional(Swim, 1);

TextDrawSetShadow(Swim, 1);

Winner = TextDrawCreate(290.000000, 297.000000, "Winner:");

TextDrawAlignment(Winner, 2);

TextDrawBackgroundColor(Winner, 255);

TextDrawFont(Winner, 2);

TextDrawLetterSize(Winner, 0.389999, 1.799999);

TextDrawColor(Winner, -1);

TextDrawSetOutline(Winner, 0);

TextDrawSetProportional(Winner, 1);

TextDrawSetShadow(Winner, 1);

for(new i=0; i<MAX_PLAYERS; i++)

{

TT = TextDrawCreate(470.000000, 381.000000, "Time: 00:00");

TextDrawBackgroundColor(TT, 255);

TextDrawFont(TT, 1);

TextDrawLetterSize(TT, 0.500000, 1.500000);

TextDrawColor(TT, -1);

TextDrawSetOutline(TT, 0);

TextDrawSetProportional(TT, 1);

TextDrawSetShadow(TT, 1);

NO = TextDrawCreate(470.000000, 408.000000, "Checkpoint: 0/16");

TextDrawBackgroundColor(NO, 255);

TextDrawFont(NO, 1);

TextDrawLetterSize(NO, 0.500000, 1.500000);

TextDrawColor(NO, -1);

TextDrawSetOutline(NO, 0);

TextDrawSetProportional(NO, 1);

TextDrawSetShadow(NO, 1);

C_TT = TextDrawCreate(120.000000, 170.000000, "Time Taken:");

TextDrawBackgroundColor(C_TT, 255);

TextDrawFont(C_TT, 1);

TextDrawLetterSize(C_TT, 0.330000, 1.199999);

TextDrawColor(C_TT, -1);

TextDrawSetOutline(C_TT, 0);

TextDrawSetProportional(C_TT, 1);

TextDrawSetShadow(C_TT, 1);

C_CP = TextDrawCreate(120.000000, 200.000000, "Checkpoints:");

TextDrawBackgroundColor(C_CP, 255);

TextDrawFont(C_CP, 1);

TextDrawLetterSize(C_CP, 0.330000, 1.199999);

TextDrawColor(C_CP, -1);

TextDrawSetOutline(C_CP, 0);

TextDrawSetProportional(C_CP, 1);

TextDrawSetShadow(C_CP, 1);

A_TT = TextDrawCreate(250.000000, 170.000000, "Time Taken:");

TextDrawBackgroundColor(A_TT, 255);

TextDrawFont(A_TT, 1);

TextDrawLetterSize(A_TT, 0.330000, 1.199999);

TextDrawColor(A_TT, -1);

TextDrawSetOutline(A_TT, 0);

TextDrawSetProportional(A_TT, 1);

TextDrawSetShadow(A_TT, 1);

A_OB = TextDrawCreate(250.000000, 200.000000, "Objects:");

TextDrawBackgroundColor(A_OB, 255);

TextDrawFont(A_OB, 1);

TextDrawLetterSize(A_OB, 0.330000, 1.199999);

TextDrawColor(A_OB, -1);

TextDrawSetOutline(A_OB, 0);

TextDrawSetProportional(A_OB, 1);

TextDrawSetShadow(A_OB, 1);

A_AC = TextDrawCreate(250.000000, 230.000000, "Accuracy:");

TextDrawBackgroundColor(A_AC, 255);

TextDrawFont(A_AC, 1);

TextDrawLetterSize(A_AC, 0.330000, 1.199999);

TextDrawColor(A_AC, -1);

TextDrawSetOutline(A_AC, 0);

TextDrawSetProportional(A_AC, 1) ;

TextDrawSetShadow(A_AC, 1);

S_CP = TextDrawCreate(380.000000, 200.000000, "Checkpoints:");

TextDrawBackgroundColor(S_CP, 255);

TextDrawFont(S_CP, 1);

TextDrawLetterSize(S_CP, 0.330000, 1.199999);

TextDrawColor(S_CP, -1);

TextDrawSetOutline(S_CP, 0);

TextDrawSetProportional(S_CP, 1);

TextDrawSetShadow(S_CP, 1);

S_TT = TextDrawCreate(380.000000, 170.000000, "Time Taken:");

TextDrawBackgroundColor(S_TT, 255);

TextDrawFont(S_TT, 1);

TextDrawLetterSize(S_TT, 0.330000, 1.199999);

TextDrawColor(S_TT, -1);

TextDrawSetOutline(S_TT, 0);

TextDrawSetProportional(S_TT, 1);

TextDrawSetShadow(S_TT, 1);

T_TT = TextDrawCreate(220.000000, 267.000000, "Total Time: 00:00");

TextDrawBackgroundColor(T_TT, 255);

TextDrawFont(T_TT, 2);

TextDrawLetterSize(T_TT, 0.389999, 1.799999);

TextDrawColor(T_TT, -1);

TextDrawSetOutline(T_TT, 0);

TextDrawSetProportional(T_TT, 1);

TextDrawSetShadow(T_TT, 1);

}

return 1;

}

//===================================//

public OnFilterScriptExit()

{

  EndTriathlon();

return 1;

}

//===================================//

public OnPlayerDisconnect(playerid, reason)

{

if(PlayerJoined[playerid] == 1)

    {

    PlayerJoined[playerid] = 0;

    PCP[playerid] = 0;

    MIN[playerid] = 0;

    SEC[playerid] = 0;

c_minutes[playerid] = 0;

c_seconds[playerid] = 0;

s_minutes[playerid] = 0;

s_seconds[playerid] = 0;

a_minutes[playerid] = 0;

a_seconds[playerid] = 0;

pobjects[playerid] = 0;

obj_hit[playerid] = 0;

robjects[playerid] = 0;

IsPlayerShooting[playerid] = false;

accuracy[playerid] = 0;

for(new i=0; i<MAX_TOBJS; i++)

{

    DestroyObject(tObj);

}

for(new i=0; i<8; i++)

{

    DestroyVehicle(tVeh);

}

if(TP == 2)

{

    EndTriathlon();

}

TP--;

}

return 1;

}

//===================================//

public OnPlayerDeath(playerid, killerid, reason)

{

if(PlayerJoined[playerid] == 1)

    {

    PlayerJoined[playerid] = 0;

    PCP[playerid] = 0;

    MIN[playerid] = 0;

    SEC[playerid] = 0;

c_minutes[playerid] = 0;

c_seconds[playerid] = 0;

s_minutes[playerid] = 0;

s_seconds[playerid] = 0;

a_minutes[playerid] = 0;

a_seconds[playerid] = 0;

pobjects[playerid] = 0;

obj_hit[playerid] = 0;

robjects[playerid] = 0;

IsPlayerShooting[playerid] = false;

accuracy[playerid] = 0;

DisablePlayerCheckpoint(playerid);

DisablePlayerRaceCheckpoint(playerid);

for(new i=0; i<MAX_TOBJS; i++)

{

    DestroyObject(tObj);

}

for(new i=0; i<8; i++)

{

    DestroyVehicle(tVeh);

}

if(TP == 2)

{

    EndTriathlon();

}

TP--;

}

return 1;

}

//===================================//

CMD:tinfo(playerid, params[])

{

    SendClientMessage(playerid, GREEN, "*** The Triathlon Minigame ***");

    SendClientMessage(playerid, CORAL, "To join the minigame - /triathlon");

    SendClientMessage(playerid, CORAL, "It includes 3 minigames:");

SendClientMessage(playerid, CORAL, "1. Cycling");

SendClientMessage(playerid, CORAL, "2. Shooting");

SendClientMessage(playerid, CORAL, "3. Swimming");

SendClientMessage(playerid, CORAL, "Location - Around Los Santos Beach");

SendClientMessage(playerid, CORAL, "Created By - DeatheR");

SendClientMessage(playerid, GREEN, "******************************");

return 1;

}

//===================================//

CMD:triathlon(playerid, params[])

{

if(PlayerJoined[playerid] == 1) return SendClientMessage(playerid, RED, "gBOT: You are already in the minigame!");

if(MiniOn) return SendClientMessage(playerid, RED, "gBOT: The minigame has already started!");

TP++;

if(TP == 1)

{

First = 1;

    SendClientMessage(playerid, CORAL, "gBOT: You started the minigame!");

    SetTimer("StartCycleRace", 15000, false);

    PlayerJoined[playerid] = 1;

    GameTextForAll("~y~TRIATHLON ~g~minigame is starting in 15 seconds!~n~~n~~w~Use ~g~/triathlon~w~ to join!",3000,3);

SendClientMessageToAll(TITANIUM, "gBOT: The Triathlon minigame is starting in 15 seconds! To join use: /triathlon");

}

    else if(TP != 1 && TP < 6)

{

PlayerJoined[playerid] = 1;

SendClientMessage(playerid, GREEN, "gBOT: You signed up the minigame!");

}

else

{

    SendClientMessage(playerid, RED, "gBOT: No empty slots. You cannot join the minigame!");

}

    return 1;

}

//===================================//

CMD:stoptri(playerid, params[])

{

if(!IsPlayerAdmin(playerid))/* change to your admin variable */ return SendClientMessage(playerid, RED, "gBOT: You need to be an admin!");

    if(!MiniOn) return SendClientMessage(playerid, RED, "gBOT: The Triathlon Minigame is not started!");

    for(new i=0; i<MAX_PLAYERS; i++)

    {

        if(IsPlayerConnected(playerid))

        {

            if(PlayerJoined == 1)

            {

        PlayerJoined = 0;

        MiniOn = false;

        MIN = 0;

        SEC = 0;

        c_minutes = 0;

c_seconds = 0;

s_minutes = 0;

s_seconds = 0;

a_minutes = 0;

a_seconds = 0;

pobjects = 0;

obj_hit = 0;

SetPlayerVirtualWorld(i, 0);

SpawnPlayer(playerid);

DisablePlayerCheckpoint(i);

DisablePlayerRaceCheckpoint(i);

SendClientMessage(playerid, ORANGE, "gBOT: An Administrator stopped the Triathlon Minigame!");

}

}

}

for(new i = 0; i<28; i++)

{

    DestroyObject(tObj);

}

for(new i = 0; i<8; i++)

{

    DestroyVehicle(tVeh);

}

return 1;

}

//===================================//

public StartCycleRace()

{

if(TP < 2)

{

    for(new i = 0; i<MAX_PLAYERS; i++)

{

  if(IsPlayerConnected(i))

  {

  if(PlayerJoined == 1)

    {

        PlayerJoined = 0;

        MiniOn = false;

        c_minutes = 0;

c_seconds = 0;

s_minutes = 0;

s_seconds = 0;

a_minutes = 0;

a_seconds = 0;

pobjects = 0;

obj_hit = 0;

SetPlayerVirtualWorld(i, 0);

}

}

}

for(new i = 0; i<28; i++)

{

    DestroyObject(tObj);

}

for(new i = 0; i<8; i++)

{

    DestroyVehicle(tVeh);

}

SendClientMessageToAll(RED, "gBOT: Enough no of slots weren't filled. Minigames closes!");

return 1;

}

    tObj[0] = CreateObject(16770,834.470886,-2061.860352,13.457747,0,0,-451.203690604705);

tObj[1] = CreateObject(7415,1267.988037,-2047.902588,68.010406,0,0,-18.0481705425);

tObj[2] = CreateObject(3749,827.610046,-1841.624390,17.592625,0,0,0);

tObj[3] = CreateObject(3749,845.445862,-1890.523193,17.725601,0,0,0);

tObj[4] = CreateObject(3749,829.592224,-1943.385376,17.725601,0,0,0);

tObj[5] = CreateObject(3749,844.374756,-2001.207275,17.725601,0,0,0);

tObj[6] = CreateObject(3749,836.334900,-2056.039551,17.725601,0,0,0);

tObj[7] = CreateObject(1238,835.760986,-1845.852173,12.039591,0,0,0);

tObj[8] = CreateObject(1238,835.740540,-1851.846680,12.185368,0,0,0);

tObj[9] = CreateObject(1238,835.801575,-1857.624268,12.185368,0,0,0);

tObj[10] = CreateObject(1238,836.116516,-1871.669678,12.185368,0,0,0);

tObj[11] = CreateObject(1238,836.255249,-1877.932739,12.185368,0,0,0);

tObj[12] = CreateObject(1238,836.524597,-1884.574951,12.185368,0,0,0);

tObj[13] = CreateObject(1225,835.893982,-1864.494385,12.272943,0,0,0);

tObj[14] = CreateObject(1238,838.934326,-1930.782349,12.185368,0,0,0);

tObj[15] = CreateObject(1238,838.920349,-1938.016968,12.185368,0,0,0);

tObj[16] = CreateObject(1238,838.900818,-1923.343140,12.185368,0,0,0);

tObj[17] = CreateObject(1238,838.210815,-1909.989380,12.185368,0,0,0);

tObj[18] = CreateObject(1238,838.068359,-1902.773682,12.185368,0,0,0);

tObj[19] = CreateObject(1238,837.769714,-1896.132813,12.185368,0,0,0);

tObj[20] = CreateObject(1225,838.749329,-1916.551147,12.272943,0,0,0);

tObj[21] = CreateObject(1238,837.477722,-1995.682861,12.185368,0,0,0);

tObj[22] = CreateObject(1238,837.296265,-1987.223755,12.185368,0,0,0);

tObj[23] = CreateObject(1238,837.335876,-1978.739502,12.185368,0,0,0);

tObj[24] = CreateObject(1238,836.794128,-1948.627075,12.185368,0,0,0);

tObj[25] = CreateObject(1238,836.978333,-1954.809570,12.185368,0,0,0);

tObj[26] = CreateObject(1238,837.030212,-1963.298706,12.185368,0,0,0);

tObj[27] = CreateObject(1225,837.202026,-1970.918457,12.272943,0,0,0);

tObj[28] = CreateObject(17068,836.163024,-2063.765869,10.699330,0,0.5,180);

    tVeh[0] = CreateVehicle(510,1245.325439,-2044.066650,59.406025,178,-1,-1,300);

tVeh[1] = CreateVehicle(510,1246.915039,-2044.073120,59.356022,178,-1,-1,300);

tVeh[2] = CreateVehicle(510,1248.549438,-2044.101196,59.331020,178,-1,-1,300);

tVeh[3] = CreateVehicle(510,1250.149292,-2044.238281,59.281017,178,-1,-1,300);

tVeh[4] = CreateVehicle(510,1251.678101,-2044.304932,59.131008,178,-1,-1,300);

tVeh[5] = CreateVehicle(510,1253.234863,-2044.180420,59.126118,178,-1,-1,300);

tVeh[6] = CreateVehicle(510,1254.649536,-2044.214966,59.076115,178,-1,-1,300);

for(new i=0; i<7; i++)

{

    SetVehicleVirtualWorld(tVeh, 15);

}

shootpick[0] = CreatePickup(1318, 23,841.6972,-2064.9282,12.8672,15);

shootpick[1] = CreatePickup(1318, 23,838.6654,-2065.0652,12.8672,15);

shootpick[2] = CreatePickup(1318, 23,835.5880,-2065.0959,12.8672,15);

shootpick[3] = CreatePickup(1318, 23,832.6954,-2064.6465,12.8672,15);

shootpick[4] = CreatePickup(1318, 23,829.8810,-2064.5100,12.8672,15);

for(new i=0; i<MAX_PLAYERS; i++)

{

    if(PlayerJoined == 1)

    {

        SetTriSpawn(i);

        TextDrawShowForPlayer(i, Tbg);

TextDrawShowForPlayer(i, TT);

TextDrawShowForPlayer(i, NO);

        SendClientMessage(i, ORANGE, "gBOT: Grab a Mountain Bike and start the race!");

        MiniOn = true;

    IsPlayerRacing = true;

PCP = 0;

ResetPlayerWeapons(i);

TextDrawShowForPlayer(i, TT);

TextDrawShowForPlayer(i, NO);

  SetPlayerRaceCheckpoint(i, 0, CRaceCPoints[PCP][0], CRaceCPoints[PCP][1], CRaceCPoints[PCP][2], CRaceCPoints[PCP+1][0], CRaceCPoints[PCP+1][1], CRaceCPoints[PCP+1][2], 8);

            inctimer = SetTimerEx("TextDrawUpdate", 1000, true, "d", i);

}

}

return 1;

}

//===================================//

public TextDrawUpdate(playerid)

{

if(IsPlayerRacing[playerid])

{

new string[32];

    c_seconds[playerid]++;

    if(c_seconds[playerid] < 10)

{

    format(string,sizeof(string), "Time: 0%d:0%d", c_minutes[playerid], c_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

else

{

    format(string,sizeof(string), "Time: 0%d:%d", c_minutes[playerid], c_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

if(c_seconds[playerid] == 59)

{

    c_minutes[playerid]++;

    c_seconds[playerid] = 0;

}

}

else if(IsPlayerShooting[playerid])

{

new string[32];

    a_seconds[playerid]++;

    if(a_seconds[playerid] == 59)

{

    a_minutes[playerid]++;

    a_seconds[playerid] = 0;

}

if(a_seconds[playerid] < 10)

{

    format(string,sizeof(string), "Time: 0%d:0%d", a_minutes[playerid], a_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

else

{

    format(string,sizeof(string), "Time: 0%d:%d", a_minutes[playerid], a_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

}

else if(IsPlayerSwimming[playerid])

{

new string[32];

    s_seconds[playerid]++;

    if(s_seconds[playerid] < 10)

{

    format(string,sizeof(string), "Time: 0%d:0%d", s_minutes[playerid], s_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

else

{

    format(string,sizeof(string), "Time: 0%d:%d", s_minutes[playerid], s_seconds[playerid]);

        TextDrawSetString(TT[playerid], string);

}

if(s_seconds[playerid] == 59)

{

    s_minutes[playerid]++;

    s_seconds[playerid] = 0;

}

}

return 1;

}

//===================================//

public OnPlayerEnterRaceCheckpoint(playerid)

{

    if(IsPlayerRacing[playerid])

    {

        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 510)

{

    GameTextForPlayer(playerid,"~r~You need a ~y~Mountain Bike ~r~to continue the race!",4500,4);

    return 1;

}

if(PCP[playerid] != FINAL_CP_CYCLE) PCP[playerid] ++;

new string[32];

format(string,sizeof(string), "Checkpoint: %d/16", PCP[playerid]);

    TextDrawSetString(NO[playerid], string);

if(PCP[playerid] == FINAL_CP_CYCLE)

    {

    StopCycleRaceForPlayer(playerid);

return 1;

}

if(PCP[playerid] == FINAL_CP_CYCLE-1)

{

SetPlayerRaceCheckpoint(playerid, 1, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 10);

return 1;

}

SetPlayerRaceCheckpoint(playerid, 0, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 8);

}

else if(IsPlayerSwimming[playerid])

    {

if(PCP[playerid] != FINAL_CP_SWIM) PCP[playerid] ++;

new string[32];

format(string,sizeof(string), "Checkpoint: %d/9", PCP[playerid]);

    TextDrawSetString(NO[playerid], string);

if(PCP[playerid] == FINAL_CP_SWIM)

    {

        if(First == 1)

        {

TP--;

First++;

            format(winner, MAX_PLAYER_NAME, "%s", PlayerName(playerid));

    StopSwimmingForPlayer(playerid);

    if(TP == 0)  //Just for testing

    {

        SetTimer("EndTriathlon", 1000, false);

}

}

else

{

    TP--;

    StopSwimmingForPlayer(playerid);

    if(TP == 0)

    {

        SetTimer("EndTriathlon", 1000, false);

}

}

return 1;

}

if(PCP[playerid] == FINAL_CP_SWIM-1)

{

SetPlayerRaceCheckpoint(playerid, 1, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 10);

return 1;

}

SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);

}

return 1;

}

//===================================//

public StopCycleRaceForPlayer(playerid)

{

DisablePlayerRaceCheckpoint(playerid);

PCP[playerid] = 0;

IsPlayerRacing[playerid] = false;

MIN[playerid] += c_minutes[playerid];

SEC[playerid] += c_seconds[playerid];

KillTimer(inctimer[playerid]);

TextDrawHideForPlayer(playerid, Tbg);

TextDrawHideForPlayer(playerid, TT[playerid]);

TextDrawHideForPlayer(playerid, NO[playerid]);

SendClientMessage(playerid, ORANGE, "gBOT: Well Done! Now Start the Shooting!");

return 1;

}

//===================================//

public OnPlayerPickUpPickup(playerid, pickupid)

{

for(new i=0; i<5; i++)

{

    if(pickupid == shootpick)

{

    DestroyPickup(shootpick);

    StartShootingForPlayer(playerid);

    break;

}

}

return 1;

}

//===================================//

public StartShootingForPlayer(playerid)

{

    TextDrawShowForPlayer(playerid, Tbg);

    TextDrawSetString(TT[playerid], "Time: 00:00");

TextDrawShowForPlayer(playerid, TT[playerid]);

TextDrawSetString(NO[playerid], "Hits: 0");

TextDrawShowForPlayer(playerid, NO[playerid]);

    IsPlayerShooting[playerid] = true;

    ResetPlayerWeapons(playerid);

    SetPlayerVirtualWorld(playerid, getIntRand(20, 30));

    GivePlayerWeapon(playerid, 34, 500);

    MoveShootingObjectsForPlayer(playerid);

GameTextForPlayer(playerid, "~g~Start Shooting!", 1000, 4);

inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);

return 1;

}

//===================================//

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)

{

    if (PRESSED(KEY_FIRE))

    {

        if(MiniOn && PlayerJoined[playerid] == 1)

        {

for(new i = 0; i <MAX_OBJECTS; i++)

{

    if(IsValidPlayerObject(playerid, A_Objects[playerid]))

    {

new Float:X, Float:Y, Float:Z;

GetPlayerObjectPos(playerid, A_Objects[playerid], X, Y, Z);

        if(IsPlayerAiming(playerid, X, Y, Z, 0.2))

        {

            if(pobjects[playerid] > 0)

            {

            DestroyPlayerObject(playerid, A_Objects[playerid]);

            pobjects[playerid]--;

            obj_hit[playerid]++;

            new string[32];

format(string,sizeof(string), "Hits: %d/20",  obj_hit[playerid]);

TextDrawSetString(NO[playerid], string);

if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)

      {

      robjects[playerid] = 20 - obj_hit[playerid];

      MoveObjectsForPlayerAgain(playerid);

}

else if(obj_hit[playerid] == 20)

{

    DestroyPlayerObject(playerid, A_Objects[playerid]);

            pobjects[playerid]--;

            EndShootingForPlayer(playerid);

}

}

}

}

}

}

}

return 1;

}

//===================================//

public OnPlayerObjectMoved(playerid,objectid)

{

    for(new i = 0; i <MAX_OBJECTS; i++)

{

    if(objectid == A_Objects[playerid])

    {

    if(IsValidPlayerObject(playerid, A_Objects[playerid]))

    {

          DestroyPlayerObject(playerid, A_Objects[playerid]);

        pobjects[playerid]--;

if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)

      {

      robjects[playerid] = 20 - obj_hit[playerid];

      MoveObjectsForPlayerAgain(playerid);

}

}

}

}

return 1;

}

//===================================//

public EndShootingForPlayer(playerid)

{

new timetaken = (a_minutes[playerid]*60) + a_seconds[playerid];

new objs = 20;

SetPlayerVirtualWorld(playerid, 0);

accuracy[playerid] = (float(objs) / float(timetaken))*100;

for(new i=0; i<pobjects[playerid]; i++)

{

    DestroyPlayerObject(playerid, A_Objects[playerid]);

}

IsPlayerShooting[playerid] = false;

MIN[playerid] += a_minutes[playerid];

SEC[playerid] += a_seconds[playerid];

KillTimer(inctimer[playerid]);

TextDrawHideForPlayer(playerid, Tbg);

TextDrawHideForPlayer(playerid, TT[playerid]);

TextDrawHideForPlayer(playerid, NO[playerid]);

SendClientMessage(playerid, ORANGE, "gBOT: You shot all the objects! Its time for Swimming!");

StartSwimmingForPlayer(playerid);

return 1;

}

//===================================//

public StartSwimmingForPlayer(playerid)

{

    ResetPlayerWeapons(playerid);

    SetPlayerPos(playerid, 836.2539, -2069.1489, 10.8726);

    SetPlayerVirtualWorld(playerid, 16);

TextDrawShowForPlayer(playerid, Tbg);

    TextDrawSetString(TT[playerid], "Time: 00:00");

TextDrawShowForPlayer(playerid, TT[playerid]);

TextDrawSetString(NO[playerid], "Checkpoint: 0/9");

TextDrawShowForPlayer(playerid, NO[playerid]);

    IsPlayerSwimming[playerid] = true;

PCP[playerid] = 0;

TextDrawShowForPlayer(playerid, TT[playerid]);

TextDrawShowForPlayer(playerid, NO[playerid]);

SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);

inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);

return 1;

}

//===================================//

public StopSwimmingForPlayer(playerid)

{

DisablePlayerRaceCheckpoint(playerid);

PCP[playerid] = 0;

IsPlayerSwimming[playerid] = false;

MIN[playerid] += s_minutes[playerid];

SEC[playerid] += s_seconds[playerid];

KillTimer(inctimer[playerid]);

TextDrawHideForPlayer(playerid, Tbg);

TextDrawHideForPlayer(playerid, TT[playerid]);

TextDrawHideForPlayer(playerid, NO[playerid]);

SendClientMessage(playerid, GOLD, "gBOT: Great! You have completed the minigame. Now wait for the results");

return 1;

}

//===================================//

public EndTriathlon()

{

for(new i = 0; i<MAX_PLAYERS; i++)

{

    if(IsPlayerConnected(i))

    {

    if(PlayerJoined == 1)

    {

        new textstr[64];

        PlayerJoined = 0;

        MiniOn = false;

        format(textstr, 64, "Time Taken: ~g~0%d:%d", c_minutes, c_seconds);

        TextDrawSetString(C_TT, textstr);

       

        TextDrawSetString(C_CP, "Checkpoints: ~g~16/16");

       

        format(textstr, 64, "Time Taken: ~g~0%d:%d", a_minutes, a_seconds);

        TextDrawSetString(A_TT, textstr);

       

        format(textstr, 64, "Objects: ~g~%d/20", obj_hit);

        TextDrawSetString(A_OB, textstr);

       

        format(textstr, 64, "Accuracy: ~g~%.2f", accuracy);

        TextDrawSetString(A_AC, textstr);

       

        format(textstr, 64, "Time Taken: ~g~%d:%d", s_minutes, s_seconds);

        TextDrawSetString(S_TT, textstr);

       

        TextDrawSetString(S_CP, "Checkpoints: ~g~9/9");

        if(SEC>59)

        {

            MIN++;

            SEC -= 60;

}

        format(textstr, 64, "Total Time: ~g~%d:%d", MIN, SEC);

        TextDrawSetString(T_TT, textstr);

       

        format(textstr, 64, "Winner: ~y~%s", winner);

        TextDrawSetString(Winner, textstr);

       

        TextDrawShowForPlayer(i, BG);

        TextDrawShowForPlayer(i, TR);

        TextDrawShowForPlayer(i, C_TT);

        TextDrawShowForPlayer(i, C_CP);

        TextDrawShowForPlayer(i, A_TT);

        TextDrawShowForPlayer(i, A_OB);

        TextDrawShowForPlayer(i, A_AC);

        TextDrawShowForPlayer(i, S_CP);

        TextDrawShowForPlayer(i, S_TT);

        TextDrawShowForPlayer(i, Cycle);

        TextDrawShowForPlayer(i, Shoot);

        TextDrawShowForPlayer(i, Swim);

        TextDrawShowForPlayer(i, T_TT);

        TextDrawShowForPlayer(i, Winner);

        c_minutes = 0;

c_seconds = 0;

s_minutes = 0;

s_seconds = 0;

a_minutes = 0;

a_seconds = 0;

pobjects = 0;

obj_hit = 0;

SetTimer("HideText", HIDE_TEXT_TIME, 1);

SetPlayerVirtualWorld(i, 0);

}

}

}

for(new i = 0; i<28; i++)

{

    DestroyObject(tObj);

}

for(new i = 0; i<8; i++)

{

    DestroyVehicle(tVeh);

}

return 1;

}

//===================================//

public HideText()

{

    for(new i = 0; i<MAX_PLAYERS; i++)

{

    if(IsPlayerConnected(i))

    {

        TextDrawHideForPlayer(i, BG);

        TextDrawHideForPlayer(i, TR);

        TextDrawHideForPlayer(i, C_TT);

        TextDrawHideForPlayer(i, C_CP);

        TextDrawHideForPlayer(i, A_TT);

        TextDrawHideForPlayer(i, A_OB);

        TextDrawHideForPlayer(i, A_AC);

        TextDrawHideForPlayer(i, S_CP);

        TextDrawHideForPlayer(i, S_TT);

        TextDrawHideForPlayer(i, Cycle);

        TextDrawHideForPlayer(i, Shoot);

        TextDrawHideForPlayer(i, Swim);

        TextDrawHideForPlayer(i, T_TT);

        TextDrawHideForPlayer(i, Winner);

}

}

return 1;

}

//===================================//

stock SetTriSpawn(playerid)

{

new pos;

pos = random(sizeof(MiniSpawns));

SetPlayerPos(playerid, MiniSpawns[pos][0], MiniSpawns[pos][1], MiniSpawns[pos][2]);

SetPlayerFacingAngle(playerid,MiniSpawns[pos][3]);

SetPlayerVirtualWorld(playerid, 15);

return 1;

}

//===================================//

stock getIntRand(ll, ul)

{

new range = ul-ll;

new number = ll+(rand()%range);

return number;

}

//===================================//

Float:getRand(Float:ll, Float:ul)

{

    new ulv = floatround(ul, floatround_ceil);

    new llv = floatround(ll, floatround_floor);

new range = ulv-llv;

new Float:number = ll+(rand()%range);

return number;

}

//===================================//

stock CreateAimObject(playerid)

{

oCount++;

pobjects[playerid]++;

new oid = oCount;

new Float:x = getRand(870.8545, 875.5131);

new Float:y = getRand(-2128.3379, -2134.1309);

new Float:z = getRand(9.6219, 17.1911);

AimObject[oid][obX][playerid] = x;

AimObject[oid][obY][playerid] = y;

AimObject[oid][obZ][playerid] = z;

A_Objects[oid][playerid] = CreatePlayerObject(playerid, 1600, AimObject[oid][obX][playerid], AimObject[oid][obY][playerid], AimObject[oid][obZ][playerid], 0.00000000,16.32929716,97.11634627);

return 1;

}

//===================================//

stock MoveShootingObjectsForPlayer(playerid)

{

    for(new i=0; i<20; i++)

{

CreateAimObject(playerid);

}

    for(new i=0; i<=20; i++)

{

new rand_val = random(sizeof(rand_float));

    MovePlayerObject(playerid, A_Objects[playerid], 790.6284, AimObject[obY][playerid], AimObject[obZ][playerid], rand_float[rand_val]);

}

return 1;

}

//===================================//

stock MoveObjectsForPlayerAgain(playerid)

{

new ObjNo = robjects[playerid];

pobjects[playerid] = 0;

    for(new i=0; i<ObjNo; i++)

{

CreateAimObject(playerid);

    }

    for(new i=0; i<=ObjNo; i++)

{

  new rand_val = random(sizeof(rand_float));

    MovePlayerObject(playerid, A_Objects[playerid], 790.6284, AimObject[obY][playerid], AimObject[obZ][playerid], rand_float[rand_val]);

}

return 1;

}

//===================================//

stock rand()

{

new rand_num = random(MAX_RAND);

return rand_num;

}

//===================================//

Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)

{

new Float:TGTDistance;

TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

new Float:tmpX, Float:tmpY, Float:tmpZ;

tmpX = FrX * TGTDistance + CamX;

tmpY = FrY * TGTDistance + CamY;

tmpZ = FrZ * TGTDistance + CamZ;

return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));

}

//===================================//

stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)

{

new Float:DX, Float:DY;

  new Float:angle;

  DX = floatabs(floatsub(x2,X));

  DY = floatabs(floatsub(y2,Y));

  if (DY == 0.0 || DX == 0.0)

{

if(DY == 0 && DX > 0) angle = 0.0;

    else if(DY == 0 && DX < 0) angle = 180.0;

    else if(DY > 0 && DX == 0) angle = 90.0;

    else if(DY < 0 && DX == 0) angle = 270.0;

    else if(DY == 0 && DX == 0) angle = 0.0;

  }

  else

  {

angle = atan(DX/DY);

    if(X > x2 && Y <= y2) angle += 90.0;

    else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);

    else if(X < x2 && Y >= y2) angle -= 90.0;

    else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);

  }

  return floatadd(angle, 90.0);

}

//===================================//

stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)

{

x += (distance * floatsin(-angle, degrees));

y += (distance * floatcos(-angle, degrees));

}

//===================================//

stock IsPlayerAiming(playerid, Float:x, Float:y, Float:z, Float:radius)

{

new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;

  GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);

  GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);

new Float:vertical, Float:horizontal;

switch (GetPlayerWeapon(playerid))

{

  case 34,35,36:

{

  if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;

  return false;

  }

  case 30,31:

  {

  vertical = 4.0;

horizontal = -1.6;

  }

  case 33:

  {

  vertical = 2.7;

horizontal = -1.0;

  }

  default:

{

vertical = 6.0;

horizontal = -2.2;

}

}

  new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;

  new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);

  GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));

  if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;

  return false;

}

//===================================//

stock PlayerName(playerid)

{

new n[MAX_PLAYER_NAME];

GetPlayerName(playerid, n, MAX_PLAYER_NAME);

return n;

}[/pawn]

Am FS asta imi apar checkpointurile,obiecte,dar textdraw-urile nu imi apar de nici un fel,care ar putea fi problema?

Link to comment
Share on other sites

/*
                            ---- TRIATHLON MINIGAME ----

                                ---- CREATED BY ----
					  ______   ____      ______      ____ ___
					   |    | |      /\   |   |   | |     |__|
					   |    | |---- /--\  |   |---| |---- | \
  					  _|____| |____/    \ |   |   | |____ |  \
    				 	 									 - BORN TO KIL

    				 	 		---- CREDITS ----
			 	 1. ZeeX - zcmd
			 	 2. niCe - 'IsPlayerAiming' function

				 	 		   ---- IMPORTANT ----
		You can edit this to your satisfaction and use it in your server.
		But you are not allowed to re-sell/release it as your script anywhere.
*/
#include <a_samp>
#include <zcmd>
//===================================//
#define RED 		0xFF0000C7
#define GREEN 		0x33AA33AA
#define ORANGE 		0xFF9900AA
#define TITANIUM 	0xFCFFF0AA
#define CORAL 		0xEFC286FF
#define GOLD 		0xB8860BAA

#define MAX_OBJS  		100
#define MAX_TOBJS   	29 // No of other objects
#define MAX_RAND 		32767 //Donot Change!!!
#define FINAL_CP_CYCLE 	16
#define FINAL_CP_SWIM	9

#define HIDE_TEXT_TIME 20000 //Time in milliseconds to display the final statistics

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
//===================================//
new Float:MiniSpawns[8][4] =
{
    {1237.001343,-2031.758545,60.551205,268.0000},
	{1237.087769,-2030.034424,60.576206,268.0000},
	{1237.237793,-2027.961792,60.426197,268.0000},
	{1237.336670,-2025.825806,60.326191,268.0000},
	{1240.417236,-2031.980713,59.476139,268.0000},
	{1240.311157,-2026.085327,59.526142,268.0000},
	{1240.278809,-2028.149902,59.551144,268.0000},
	{1240.300537,-2030.038940,59.526142,268.0000}
};

new tObj[MAX_TOBJS];
new tVeh[8];
//I created this long time ago (Before Pvars were created) I didnt have time to change them.
new PCP[MAX_PLAYERS];
new PlayerJoined[MAX_PLAYERS];
new bool:MiniOn;
new TP;

new inctimer[MAX_PLAYERS];
new MIN[MAX_PLAYERS];
new SEC[MAX_PLAYERS];
new First;
new winner[MAX_PLAYER_NAME];

new Text:Tbg;
new Text:TT[MAX_PLAYERS];
new Text:NO[MAX_PLAYERS];
new Text:BG;
new Text:TR;
new Text:C_TT[MAX_PLAYERS];
new Text:C_CP[MAX_PLAYERS];
new Text:A_TT[MAX_PLAYERS];
new Text:A_OB[MAX_PLAYERS];
new Text:A_AC[MAX_PLAYERS];
new Text:S_CP[MAX_PLAYERS];
new Text:S_TT[MAX_PLAYERS];
new Text:Cycle;
new Text:Shoot;
new Text:Swim;
new Text:T_TT[MAX_PLAYERS];
new Text:Winner;
//***************************MOUNTAIN BIKE RACE*******************************//
new Float:CRaceCPoints[17][3] =
{
	{1273.332275,-2056.174316,58.064869},
	{1389.242432,-2047.083130,54.034203},
	{1426.094849,-1988.133789,48.100159},
	{1315.031494,-1957.947998,28.298063},
	{1260.021973,-1908.830322,28.799747},
	{1422.825806,-1922.275146,14.627296},
	{1332.206909,-1853.607300,12.382813},
	{1222.804077,-1852.206665,12.382813},
	{1061.719849,-1849.264771,12.567745},
	{983.637329,-1785.176270,13.074606},
	{843.459045,-1769.413818,12.395102},
	{827.917297,-1841.450439,11.644958},
	{845.218689,-1890.641602,11.867188},
	{830.854797,-1943.510010,11.867188},
	{844.152771,-2001.475952,11.867188},
	{835.849304,-2055.608154,11.867188},
	{0.0,0.0,0.0}
};
new bool:IsPlayerRacing[MAX_PLAYERS];
new c_minutes[MAX_PLAYERS];
new c_seconds[MAX_PLAYERS];
//*******************************SHOOTING RANGE*******************************//
enum moveobjs
{
	Float:obX[MAX_PLAYERS],
	Float:obY[MAX_PLAYERS],
	Float:obZ[MAX_PLAYERS]
};

new Float:rand_float[17] = //Speed with which the objects move
{0.8, 0.9, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9};

new AimObject[MAX_OBJS][moveobjs];

new A_Objects[MAX_OBJS][MAX_PLAYERS];
new pobjects[MAX_PLAYERS];
new robjects[MAX_PLAYERS];
new obj_hit[MAX_PLAYERS];
new shootpick[5];
new oCount = 0;
new bool:IsPlayerShooting[MAX_PLAYERS];
new a_minutes[MAX_PLAYERS];
new a_seconds[MAX_PLAYERS];
new Float:accuracy[MAX_PLAYERS];
//********************************SWIMMING RACE*******************************//
new Float:SRaceCPoints[10][3] =
{
	{834.885010,-2094.992676,0.007755},
	{719.189026,-2094.839844,0.009658},
	{725.342163,-1969.148926,0.055709},
	{724.468750,-1887.028687,-0.014958},
	{724.574524,-1778.495361,-0.020918},
	{723.868225,-1695.539795,-0.069923},
	{724.020508,-1580.007324,0.069664},
	{723.220154,-1488.487915,0.934345},
	{728.4586,-1440.3844,17.6953},
	{0.0,0.0,0.0}
};
new bool:IsPlayerSwimming[MAX_PLAYERS];
new s_minutes[MAX_PLAYERS];
new s_seconds[MAX_PLAYERS];
//===================================//
forward StartCycleRace();
forward StopCycleRaceForPlayer(playerid);
forward TextDrawUpdate(playerid);
forward StartAccuTest(playerid);
forward StartShootingForPlayer(playerid);
forward EndShootingForPlayer(playerid);
forward StartSwimmingForPlayer(playerid);
forward StopSwimmingForPlayer(playerid);
forward EndTriathlon();
forward HideText();
//===================================//
public OnFilterScriptInit()
{
    Tbg = TextDrawCreate(630.000000, 371.000000, "_");
	TextDrawBackgroundColor(Tbg, 255);
	TextDrawFont(Tbg, 1);
	TextDrawLetterSize(Tbg, 0.500000, 7.200000);
	TextDrawColor(Tbg, -1);
	TextDrawSetOutline(Tbg, 0);
	TextDrawSetProportional(Tbg, 1);
	TextDrawSetShadow(Tbg, 1);
	TextDrawUseBox(Tbg, 1);
	TextDrawBoxColor(Tbg, 252645270);
	TextDrawTextSize(Tbg, 460.000000, 40.000000);

	BG = TextDrawCreate(505.000000, 129.000000, "_");
	TextDrawBackgroundColor(BG, 255);
	TextDrawFont(BG, 1);
	TextDrawLetterSize(BG, 0.549998, 23.600002);
	TextDrawColor(BG, -1);
	TextDrawSetOutline(BG, 1);
	TextDrawSetProportional(BG, 1);
	TextDrawUseBox(BG, 1);
	TextDrawBoxColor(BG, 252645270);
	TextDrawTextSize(BG, 108.000000, 0.000000);

	TR = TextDrawCreate(204.000000, 128.000000, "TRIATHLON RESULTS");
	TextDrawBackgroundColor(TR, 255);
	TextDrawFont(TR, 2);
	TextDrawLetterSize(TR, 0.500000, 1.500000);
	TextDrawColor(TR, 845453000);
	TextDrawSetOutline(TR, 0);
	TextDrawSetProportional(TR, 1);
	TextDrawSetShadow(TR, 1);

	Cycle = TextDrawCreate(149.000000, 150.000000, "Cycling");
	TextDrawBackgroundColor(Cycle, 255);
	TextDrawFont(Cycle, 1);
	TextDrawLetterSize(Cycle, 0.480000, 1.200000);
	TextDrawColor(Cycle, -1);
	TextDrawSetOutline(Cycle, 0);
	TextDrawSetProportional(Cycle, 1);
	TextDrawSetShadow(Cycle, 1);

	Shoot = TextDrawCreate(265.000000, 150.000000, "Shooting");
	TextDrawBackgroundColor(Shoot, 255);
	TextDrawFont(Shoot, 1);
	TextDrawLetterSize(Shoot, 0.480000, 1.200000);
	TextDrawColor(Shoot, -1);
	TextDrawSetOutline(Shoot, 0);
	TextDrawSetProportional(Shoot, 1);
	TextDrawSetShadow(Shoot, 1);

	Swim = TextDrawCreate(390.000000, 150.000000, "Swimming");
	TextDrawBackgroundColor(Swim, 255);
	TextDrawFont(Swim, 1);
	TextDrawLetterSize(Swim, 0.480000, 1.200000);
	TextDrawColor(Swim, -1);
	TextDrawSetOutline(Swim, 0);
	TextDrawSetProportional(Swim, 1);
	TextDrawSetShadow(Swim, 1);

	Winner = TextDrawCreate(290.000000, 297.000000, "Winner:");
	TextDrawAlignment(Winner, 2);
	TextDrawBackgroundColor(Winner, 255);
	TextDrawFont(Winner, 2);
	TextDrawLetterSize(Winner, 0.389999, 1.799999);
	TextDrawColor(Winner, -1);
	TextDrawSetOutline(Winner, 0);
	TextDrawSetProportional(Winner, 1);
	TextDrawSetShadow(Winner, 1);

	for(new i=0; i<MAX_PLAYERS; i++)
	{
		TT[i] = TextDrawCreate(470.000000, 381.000000, "Time: 00:00");
		TextDrawBackgroundColor(TT[i], 255);
		TextDrawFont(TT[i], 1);
		TextDrawLetterSize(TT[i], 0.500000, 1.500000);
		TextDrawColor(TT[i], -1);
		TextDrawSetOutline(TT[i], 0);
		TextDrawSetProportional(TT[i], 1);
		TextDrawSetShadow(TT[i], 1);

		NO[i] = TextDrawCreate(470.000000, 408.000000, "Checkpoint: 0/16");
		TextDrawBackgroundColor(NO[i], 255);
		TextDrawFont(NO[i], 1);
		TextDrawLetterSize(NO[i], 0.500000, 1.500000);
		TextDrawColor(NO[i], -1);
		TextDrawSetOutline(NO[i], 0);
		TextDrawSetProportional(NO[i], 1);
		TextDrawSetShadow(NO[i], 1);

		C_TT[i] = TextDrawCreate(120.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(C_TT[i], 255);
		TextDrawFont(C_TT[i], 1);
		TextDrawLetterSize(C_TT[i], 0.330000, 1.199999);
		TextDrawColor(C_TT[i], -1);
		TextDrawSetOutline(C_TT[i], 0);
		TextDrawSetProportional(C_TT[i], 1);
		TextDrawSetShadow(C_TT[i], 1);

		C_CP[i] = TextDrawCreate(120.000000, 200.000000, "Checkpoints:");
		TextDrawBackgroundColor(C_CP[i], 255);
		TextDrawFont(C_CP[i], 1);
		TextDrawLetterSize(C_CP[i], 0.330000, 1.199999);
		TextDrawColor(C_CP[i], -1);
		TextDrawSetOutline(C_CP[i], 0);
		TextDrawSetProportional(C_CP[i], 1);
		TextDrawSetShadow(C_CP[i], 1);

		A_TT[i] = TextDrawCreate(250.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(A_TT[i], 255);
		TextDrawFont(A_TT[i], 1);
		TextDrawLetterSize(A_TT[i], 0.330000, 1.199999);
		TextDrawColor(A_TT[i], -1);
		TextDrawSetOutline(A_TT[i], 0);
		TextDrawSetProportional(A_TT[i], 1);
		TextDrawSetShadow(A_TT[i], 1);

		A_OB[i] = TextDrawCreate(250.000000, 200.000000, "Objects:");
		TextDrawBackgroundColor(A_OB[i], 255);
		TextDrawFont(A_OB[i], 1);
		TextDrawLetterSize(A_OB[i], 0.330000, 1.199999);
		TextDrawColor(A_OB[i], -1);
		TextDrawSetOutline(A_OB[i],	 0);
		TextDrawSetProportional(A_OB[i], 1);
		TextDrawSetShadow(A_OB[i], 1);

		A_AC[i] = TextDrawCreate(250.000000, 230.000000, "Accuracy:");
		TextDrawBackgroundColor(A_AC[i], 255);
		TextDrawFont(A_AC[i], 1);
		TextDrawLetterSize(A_AC[i], 0.330000, 1.199999);
		TextDrawColor(A_AC[i], -1);
		TextDrawSetOutline(A_AC[i], 0);
		TextDrawSetProportional(A_AC[i], 1)	;
		TextDrawSetShadow(A_AC[i], 1);

		S_CP[i] = TextDrawCreate(380.000000, 200.000000, "Checkpoints:");
		TextDrawBackgroundColor(S_CP[i], 255);
		TextDrawFont(S_CP[i], 1);
		TextDrawLetterSize(S_CP[i], 0.330000, 1.199999);
		TextDrawColor(S_CP[i], -1);
		TextDrawSetOutline(S_CP[i], 0);
		TextDrawSetProportional(S_CP[i], 1);
		TextDrawSetShadow(S_CP[i], 1);

		S_TT[i] = TextDrawCreate(380.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(S_TT[i], 255);
		TextDrawFont(S_TT[i], 1);
		TextDrawLetterSize(S_TT[i], 0.330000, 1.199999);
		TextDrawColor(S_TT[i], -1);
		TextDrawSetOutline(S_TT[i], 0);
		TextDrawSetProportional(S_TT[i], 1);
		TextDrawSetShadow(S_TT[i], 1);

		T_TT[i] = TextDrawCreate(220.000000, 267.000000, "Total Time: 00:00");
		TextDrawBackgroundColor(T_TT[i], 255);
		TextDrawFont(T_TT[i], 2);
		TextDrawLetterSize(T_TT[i], 0.389999, 1.799999);
		TextDrawColor(T_TT[i], -1);
		TextDrawSetOutline(T_TT[i], 0);
		TextDrawSetProportional(T_TT[i], 1);
		TextDrawSetShadow(T_TT[i], 1);
	}
	return 1;
}
//===================================//
public OnFilterScriptExit()
{
   	EndTriathlon();
	return 1;
}
//===================================//
public OnPlayerDisconnect(playerid, reason)
{
	if(PlayerJoined[playerid] == 1)
    {
    	PlayerJoined[playerid] = 0;
    	PCP[playerid] = 0;
    	MIN[playerid] = 0;
    	SEC[playerid] = 0;
		c_minutes[playerid] = 0;
		c_seconds[playerid] = 0;
		s_minutes[playerid] = 0;
		s_seconds[playerid] = 0;
		a_minutes[playerid] = 0;
		a_seconds[playerid] = 0;
		pobjects[playerid] = 0;
		obj_hit[playerid] = 0;
		robjects[playerid] = 0;
		IsPlayerShooting[playerid] = false;
		accuracy[playerid] = 0;
		for(new i=0; i<MAX_TOBJS; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i=0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		if(TP == 2)
		{
		    EndTriathlon();
		}
		TP--;
	}
	return 1;
}
//===================================//
public OnPlayerDeath(playerid, killerid, reason)
{
	if(PlayerJoined[playerid] == 1)
    {
    	PlayerJoined[playerid] = 0;
    	PCP[playerid] = 0;
    	MIN[playerid] = 0;
    	SEC[playerid] = 0;
		c_minutes[playerid] = 0;
		c_seconds[playerid] = 0;
		s_minutes[playerid] = 0;
		s_seconds[playerid] = 0;
		a_minutes[playerid] = 0;
		a_seconds[playerid] = 0;
		pobjects[playerid] = 0;
		obj_hit[playerid] = 0;
		robjects[playerid] = 0;
		IsPlayerShooting[playerid] = false;
		accuracy[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
		DisablePlayerRaceCheckpoint(playerid);
		for(new i=0; i<MAX_TOBJS; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i=0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		if(TP == 2)
		{
		    EndTriathlon();
		}
		TP--;
	}
	return 1;
}
//===================================//
CMD:tinfo(playerid, params[])
{
    SendClientMessage(playerid, GREEN, "*** The Triathlon Minigame ***");
    SendClientMessage(playerid, CORAL, "To join the minigame - /triathlon");
    SendClientMessage(playerid, CORAL, "It includes 3 minigames:");
	SendClientMessage(playerid, CORAL, "1. Cycling");
	SendClientMessage(playerid, CORAL, "2. Shooting");
	SendClientMessage(playerid, CORAL, "3. Swimming");
	SendClientMessage(playerid, CORAL, "Location - Around Los Santos Beach");
	SendClientMessage(playerid, CORAL, "Created By - DeatheR");
	SendClientMessage(playerid, GREEN, "******************************");
	return 1;
}
//===================================//
CMD:triathlon(playerid, params[])
{
	if(PlayerJoined[playerid] == 1) return SendClientMessage(playerid, RED, "gBOT: You are already in the minigame!");
	if(MiniOn) return SendClientMessage(playerid, RED, "gBOT: The minigame has already started!");
	TP++;
	if(TP == 1)
	{
		First = 1;
	    SendClientMessage(playerid, CORAL, "gBOT: You started the minigame!");
	    SetTimer("StartCycleRace", 15000, false);
	    PlayerJoined[playerid] = 1;
	    GameTextForAll("~y~TRIATHLON ~g~minigame is starting in 15 seconds!~n~~n~~w~Use ~g~/triathlon~w~ to join!",3000,3);
		SendClientMessageToAll(TITANIUM, "gBOT: The Triathlon minigame is starting in 15 seconds! To join use: /triathlon");
	}
    else if(TP != 1 && TP < 6)
	{
		PlayerJoined[playerid] = 1;
		SendClientMessage(playerid, GREEN, "gBOT: You signed up the minigame!");
	}
	else
	{
	    SendClientMessage(playerid, RED, "gBOT: No empty slots. You cannot join the minigame!");
	}
    return 1;
}
//===================================//
CMD:stoptri(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))/* change to your admin variable */ return SendClientMessage(playerid, RED, "gBOT: You need to be an admin!");
    if(!MiniOn) return SendClientMessage(playerid, RED, "gBOT: The Triathlon Minigame is not started!");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerJoined[i] == 1)
            {
	    	    PlayerJoined[i] = 0;
	    	    MiniOn = false;
	    	    MIN[i] = 0;
	    	    SEC[i] = 0;
	    	    c_minutes[i] = 0;
				c_seconds[i] = 0;
				s_minutes[i] = 0;
				s_seconds[i] = 0;
				a_minutes[i] = 0;
				a_seconds[i] = 0;
				pobjects[i] = 0;
				obj_hit[i] = 0;
				SetPlayerVirtualWorld(i, 0);
				SpawnPlayer(playerid);
				DisablePlayerCheckpoint(i);
				DisablePlayerRaceCheckpoint(i);
				SendClientMessage(playerid, ORANGE, "gBOT: An Administrator stopped the Triathlon Minigame!");
			}
		}
	}
	for(new i = 0; i<28; i++)
	{
	    DestroyObject(tObj[i]);
	}
	for(new i = 0; i<8; i++)
	{
	    DestroyVehicle(tVeh[i]);
	}
	return 1;
}
//===================================//
public StartCycleRace()
{
	if(TP < 2)
	{
	    for(new i = 0; i<MAX_PLAYERS; i++)
		{
	   	 	if(IsPlayerConnected(i))
	   	 	{
	   	 		if(PlayerJoined[i] == 1)
	    		{
	    	    	PlayerJoined[i] = 0;
	    	    	MiniOn = false;
	    	    	c_minutes[i] = 0;
					c_seconds[i] = 0;
					s_minutes[i] = 0;
					s_seconds[i] = 0;
					a_minutes[i] = 0;
					a_seconds[i] = 0;
					pobjects[i] = 0;
					obj_hit[i] = 0;
					SetPlayerVirtualWorld(i, 0);
				}
			}
		}
		for(new i = 0; i<28; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i = 0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		SendClientMessageToAll(RED, "gBOT: Enough no of slots weren't filled. Minigames closes!");
		return 1;
	}
    tObj[0] = CreateObject(16770,834.470886,-2061.860352,13.457747,0,0,-451.203690604705);
	tObj[1] = CreateObject(7415,1267.988037,-2047.902588,68.010406,0,0,-18.0481705425);
	tObj[2] = CreateObject(3749,827.610046,-1841.624390,17.592625,0,0,0);
	tObj[3] = CreateObject(3749,845.445862,-1890.523193,17.725601,0,0,0);
	tObj[4] = CreateObject(3749,829.592224,-1943.385376,17.725601,0,0,0);
	tObj[5] = CreateObject(3749,844.374756,-2001.207275,17.725601,0,0,0);
	tObj[6] = CreateObject(3749,836.334900,-2056.039551,17.725601,0,0,0);
	tObj[7] = CreateObject(1238,835.760986,-1845.852173,12.039591,0,0,0);
	tObj[8] = CreateObject(1238,835.740540,-1851.846680,12.185368,0,0,0);
	tObj[9] = CreateObject(1238,835.801575,-1857.624268,12.185368,0,0,0);
	tObj[10] = CreateObject(1238,836.116516,-1871.669678,12.185368,0,0,0);
	tObj[11] = CreateObject(1238,836.255249,-1877.932739,12.185368,0,0,0);
	tObj[12] = CreateObject(1238,836.524597,-1884.574951,12.185368,0,0,0);
	tObj[13] = CreateObject(1225,835.893982,-1864.494385,12.272943,0,0,0);
	tObj[14] = CreateObject(1238,838.934326,-1930.782349,12.185368,0,0,0);
	tObj[15] = CreateObject(1238,838.920349,-1938.016968,12.185368,0,0,0);
	tObj[16] = CreateObject(1238,838.900818,-1923.343140,12.185368,0,0,0);
	tObj[17] = CreateObject(1238,838.210815,-1909.989380,12.185368,0,0,0);
	tObj[18] = CreateObject(1238,838.068359,-1902.773682,12.185368,0,0,0);
	tObj[19] = CreateObject(1238,837.769714,-1896.132813,12.185368,0,0,0);
	tObj[20] = CreateObject(1225,838.749329,-1916.551147,12.272943,0,0,0);
	tObj[21] = CreateObject(1238,837.477722,-1995.682861,12.185368,0,0,0);
	tObj[22] = CreateObject(1238,837.296265,-1987.223755,12.185368,0,0,0);
	tObj[23] = CreateObject(1238,837.335876,-1978.739502,12.185368,0,0,0);
	tObj[24] = CreateObject(1238,836.794128,-1948.627075,12.185368,0,0,0);
	tObj[25] = CreateObject(1238,836.978333,-1954.809570,12.185368,0,0,0);
	tObj[26] = CreateObject(1238,837.030212,-1963.298706,12.185368,0,0,0);
	tObj[27] = CreateObject(1225,837.202026,-1970.918457,12.272943,0,0,0);
	tObj[28] = CreateObject(17068,836.163024,-2063.765869,10.699330,0,0.5,180);

    tVeh[0] = CreateVehicle(510,1245.325439,-2044.066650,59.406025,178,-1,-1,300);
	tVeh[1] = CreateVehicle(510,1246.915039,-2044.073120,59.356022,178,-1,-1,300);
	tVeh[2] = CreateVehicle(510,1248.549438,-2044.101196,59.331020,178,-1,-1,300);
	tVeh[3] = CreateVehicle(510,1250.149292,-2044.238281,59.281017,178,-1,-1,300);
	tVeh[4] = CreateVehicle(510,1251.678101,-2044.304932,59.131008,178,-1,-1,300);
	tVeh[5] = CreateVehicle(510,1253.234863,-2044.180420,59.126118,178,-1,-1,300);
	tVeh[6] = CreateVehicle(510,1254.649536,-2044.214966,59.076115,178,-1,-1,300);
	for(new i=0; i<7; i++)
	{
	    SetVehicleVirtualWorld(tVeh[i], 15);
	}
	shootpick[0] = CreatePickup(1318, 23,841.6972,-2064.9282,12.8672,15);
	shootpick[1] = CreatePickup(1318, 23,838.6654,-2065.0652,12.8672,15);
	shootpick[2] = CreatePickup(1318, 23,835.5880,-2065.0959,12.8672,15);
	shootpick[3] = CreatePickup(1318, 23,832.6954,-2064.6465,12.8672,15);
	shootpick[4] = CreatePickup(1318, 23,829.8810,-2064.5100,12.8672,15);

	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(PlayerJoined[i] == 1)
	    {
	        SetTriSpawn(i);
	        TextDrawShowForPlayer(i, Tbg);
			TextDrawShowForPlayer(i, TT[i]);
			TextDrawShowForPlayer(i, NO[i]);
	        SendClientMessage(i, ORANGE, "gBOT: Grab a Mountain Bike and start the race!");
	        MiniOn = true;
    		IsPlayerRacing[i] = true;
			PCP[i] = 0;
			ResetPlayerWeapons(i);
			TextDrawShowForPlayer(i, TT[i]);
			TextDrawShowForPlayer(i, NO[i]);
  			SetPlayerRaceCheckpoint(i, 0, CRaceCPoints[PCP[i]][0], CRaceCPoints[PCP[i]][1], CRaceCPoints[PCP[i]][2], CRaceCPoints[PCP[i]+1][0], CRaceCPoints[PCP[i]+1][1], CRaceCPoints[PCP[i]+1][2], 8);
            inctimer[i] = SetTimerEx("TextDrawUpdate", 1000, true, "d", i);
		}
	}
	return 1;
}
//===================================//
public TextDrawUpdate(playerid)
{
	if(IsPlayerRacing[playerid])
	{
		new string[32];
    	c_seconds[playerid]++;
    	if(c_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", c_minutes[playerid], c_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", c_minutes[playerid], c_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}

		if(c_seconds[playerid] == 59)
		{
		    c_minutes[playerid]++;
		    c_seconds[playerid] = 0;
		}
	}
	else if(IsPlayerShooting[playerid])
	{
		new string[32];
    	a_seconds[playerid]++;
    	if(a_seconds[playerid] == 59)
		{
		    a_minutes[playerid]++;
		    a_seconds[playerid] = 0;
		}
		if(a_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", a_minutes[playerid], a_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", a_minutes[playerid], a_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
	}
	else if(IsPlayerSwimming[playerid])
	{
		new string[32];
    	s_seconds[playerid]++;
    	if(s_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", s_minutes[playerid], s_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", s_minutes[playerid], s_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}

		if(s_seconds[playerid] == 59)
		{
		    s_minutes[playerid]++;
		    s_seconds[playerid] = 0;
		}
	}
	return 1;
}
//===================================//
public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(IsPlayerRacing[playerid])
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 510)
		{
		    GameTextForPlayer(playerid,"~r~You need a ~y~Mountain Bike ~r~to continue the race!",4500,4);
		    return 1;
		}
		if(PCP[playerid] != FINAL_CP_CYCLE) PCP[playerid] ++;
		new string[32];
		format(string,sizeof(string), "Checkpoint: %d/16", PCP[playerid]);
    	TextDrawSetString(NO[playerid], string);
		if(PCP[playerid] == FINAL_CP_CYCLE)
	    {
	    	StopCycleRaceForPlayer(playerid);
			return 1;
		}
		if(PCP[playerid] == FINAL_CP_CYCLE-1)
		{
			SetPlayerRaceCheckpoint(playerid, 1, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 10);
			return 1;
		}
	 	SetPlayerRaceCheckpoint(playerid, 0, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 8);
	}
	else if(IsPlayerSwimming[playerid])
    {
		if(PCP[playerid] != FINAL_CP_SWIM) PCP[playerid] ++;
		new string[32];
		format(string,sizeof(string), "Checkpoint: %d/9", PCP[playerid]);
    	TextDrawSetString(NO[playerid], string);
		if(PCP[playerid] == FINAL_CP_SWIM)
	    {
	        if(First == 1)
	        {
				TP--;
				First++;
	            format(winner, MAX_PLAYER_NAME, "%s", PlayerName(playerid));
	    		StopSwimmingForPlayer(playerid);
	    		if(TP == 0)  //Just for testing
			    {
			        SetTimer("EndTriathlon", 1000, false);
				}
			}
			else
			{
			    TP--;
			    StopSwimmingForPlayer(playerid);
			    if(TP == 0)
			    {
			        SetTimer("EndTriathlon", 1000, false);
				}
			}
			return 1;
		}
		if(PCP[playerid] == FINAL_CP_SWIM-1)
		{
			SetPlayerRaceCheckpoint(playerid, 1, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 10);
			return 1;
		}
	 	SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);
	}
	return 1;
}
//===================================//
public StopCycleRaceForPlayer(playerid)
{
	DisablePlayerRaceCheckpoint(playerid);
	PCP[playerid] = 0;
	IsPlayerRacing[playerid] = false;
	MIN[playerid] += c_minutes[playerid];
	SEC[playerid] += c_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);

	SendClientMessage(playerid, ORANGE, "gBOT: Well Done! Now Start the Shooting!");
	return 1;
}
//===================================//
public OnPlayerPickUpPickup(playerid, pickupid)
{
	for(new i=0; i<5; i++)
	{
	    if(pickupid == shootpick[i])
		{
		    DestroyPickup(shootpick[i]);
		    StartShootingForPlayer(playerid);
		    break;
		}
	}
	return 1;
}
//===================================//
public StartShootingForPlayer(playerid)
{
    TextDrawShowForPlayer(playerid, Tbg);
    TextDrawSetString(TT[playerid], "Time: 00:00");
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawSetString(NO[playerid], "Hits: 0");
	TextDrawShowForPlayer(playerid, NO[playerid]);
    IsPlayerShooting[playerid] = true;
    ResetPlayerWeapons(playerid);
    SetPlayerVirtualWorld(playerid, getIntRand(20, 30));
    GivePlayerWeapon(playerid, 34, 500);
    MoveShootingObjectsForPlayer(playerid);
	GameTextForPlayer(playerid, "~g~Start Shooting!", 1000, 4);
	inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);
	return 1;
}
//===================================//
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if(MiniOn && PlayerJoined[playerid] == 1)
        {
			for(new i = 0; i <MAX_OBJECTS; i++)
			{
			    if(IsValidPlayerObject(playerid, A_Objects[i][playerid]))
			    {
					new Float:X, Float:Y, Float:Z;
					GetPlayerObjectPos(playerid, A_Objects[i][playerid], X, Y, Z);
			        if(IsPlayerAiming(playerid, X, Y, Z, 0.2))
			        {
			            if(pobjects[playerid] > 0)
			            {
			            	DestroyPlayerObject(playerid, A_Objects[i][playerid]);
			            	pobjects[playerid]--;
			            	obj_hit[playerid]++;
			            	new string[32];
							format(string,sizeof(string), "Hits: %d/20",  obj_hit[playerid]);
							TextDrawSetString(NO[playerid], string);
					 		if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)
	    	  				{
	      						robjects[playerid] = 20 - obj_hit[playerid];
	    	   	 				MoveObjectsForPlayerAgain(playerid);
							}
							else if(obj_hit[playerid] == 20)
							{
							    DestroyPlayerObject(playerid, A_Objects[i][playerid]);
			            		pobjects[playerid]--;
			            		EndShootingForPlayer(playerid);
							}
						}
					}
				}
			}
		}
	}
	return 1;
}
//===================================//
public OnPlayerObjectMoved(playerid,objectid)
{
    for(new i = 0; i <MAX_OBJECTS; i++)
	{
	    if(objectid == A_Objects[i][playerid])
	    {
	    	if(IsValidPlayerObject(playerid, A_Objects[i][playerid]))
	    	{
          		DestroyPlayerObject(playerid, A_Objects[i][playerid]);
	    	    pobjects[playerid]--;
				if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)
	    	  	{
	      			robjects[playerid] = 20 - obj_hit[playerid];
	    	   	 	MoveObjectsForPlayerAgain(playerid);
				}
			}
		}
	}
	return 1;
}
//===================================//
public EndShootingForPlayer(playerid)
{
 	new timetaken = (a_minutes[playerid]*60) + a_seconds[playerid];
	new objs = 20;
	SetPlayerVirtualWorld(playerid, 0);
	accuracy[playerid] = (float(objs) / float(timetaken))*100;
	for(new i=0; i<pobjects[playerid]; i++)
	{
	    DestroyPlayerObject(playerid, A_Objects[i][playerid]);
	}
	IsPlayerShooting[playerid] = false;
	MIN[playerid] += a_minutes[playerid];
	SEC[playerid] += a_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);
	SendClientMessage(playerid, ORANGE, "gBOT: You shot all the objects! Its time for Swimming!");
	StartSwimmingForPlayer(playerid);
	return 1;
}
//===================================//
public StartSwimmingForPlayer(playerid)
{
    ResetPlayerWeapons(playerid);
    SetPlayerPos(playerid, 836.2539, -2069.1489, 10.8726);
    SetPlayerVirtualWorld(playerid, 16);
	TextDrawShowForPlayer(playerid, Tbg);
    TextDrawSetString(TT[playerid], "Time: 00:00");
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawSetString(NO[playerid], "Checkpoint: 0/9");
	TextDrawShowForPlayer(playerid, NO[playerid]);
    IsPlayerSwimming[playerid] = true;
	PCP[playerid] = 0;
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawShowForPlayer(playerid, NO[playerid]);
	SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);
 	inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);
	return 1;
}
//===================================//
public StopSwimmingForPlayer(playerid)
{
	DisablePlayerRaceCheckpoint(playerid);
	PCP[playerid] = 0;
	IsPlayerSwimming[playerid] = false;
	MIN[playerid] += s_minutes[playerid];
	SEC[playerid] += s_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);
	SendClientMessage(playerid, GOLD, "gBOT: Great! You have completed the minigame. Now wait for the results");
	return 1;
}
//===================================//
public EndTriathlon()
{
	for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	    	if(PlayerJoined[i] == 1)
	    	{
	    	    new textstr[64];
	    	    PlayerJoined[i] = 0;
	    	    MiniOn = false;
	    	    format(textstr, 64, "Time Taken: ~g~0%d:%d", c_minutes[i], c_seconds[i]);
	    	    TextDrawSetString(C_TT[i], textstr);
	    	    
	    	    TextDrawSetString(C_CP[i], "Checkpoints: ~g~16/16");
	    	    
	    	    format(textstr, 64, "Time Taken: ~g~0%d:%d", a_minutes[i], a_seconds[i]);
	    	    TextDrawSetString(A_TT[i], textstr);
	    	    
	    	    format(textstr, 64, "Objects: ~g~%d/20", obj_hit[i]);
	    	    TextDrawSetString(A_OB[i], textstr);
	    	    
	    	    format(textstr, 64, "Accuracy: ~g~%.2f", accuracy[i]);
	    	    TextDrawSetString(A_AC[i], textstr);
	    	    
	    	    format(textstr, 64, "Time Taken: ~g~%d:%d", s_minutes[i], s_seconds[i]);
	    	    TextDrawSetString(S_TT[i], textstr);
	    	    
	    	    TextDrawSetString(S_CP[i], "Checkpoints: ~g~9/9");
	    	    if(SEC[i]>59)
	    	    {
	    	        MIN[i]++;
	    	        SEC[i] -= 60;
				}
	    	    format(textstr, 64, "Total Time: ~g~%d:%d", MIN[i], SEC[i]);
	    	    TextDrawSetString(T_TT[i], textstr);
	    	    
	    	    format(textstr, 64, "Winner: ~y~%s", winner);
	    	    TextDrawSetString(Winner, textstr);
	    	    
	    	    TextDrawShowForPlayer(i, BG);
	    	    TextDrawShowForPlayer(i, TR);
	    	    TextDrawShowForPlayer(i, C_TT[i]);
	    	    TextDrawShowForPlayer(i, C_CP[i]);
	    	    TextDrawShowForPlayer(i, A_TT[i]);
	    	    TextDrawShowForPlayer(i, A_OB[i]);
	    	    TextDrawShowForPlayer(i, A_AC[i]);
	    	    TextDrawShowForPlayer(i, S_CP[i]);
	    	    TextDrawShowForPlayer(i, S_TT[i]);
	    	    TextDrawShowForPlayer(i, Cycle);
	    	    TextDrawShowForPlayer(i, Shoot);
	    	    TextDrawShowForPlayer(i, Swim);
	    	    TextDrawShowForPlayer(i, T_TT[i]);
	    	    TextDrawShowForPlayer(i, Winner);
	    	    c_minutes[i] = 0;
				c_seconds[i] = 0;
				s_minutes[i] = 0;
				s_seconds[i] = 0;
				a_minutes[i] = 0;
				a_seconds[i] = 0;
				pobjects[i] = 0;
				obj_hit[i] = 0;
				SetTimer("HideText", HIDE_TEXT_TIME, 1);
				SetPlayerVirtualWorld(i, 0);
			}
		}
	}
	for(new i = 0; i<28; i++)
	{
	    DestroyObject(tObj[i]);
	}
	for(new i = 0; i<8; i++)
	{
	    DestroyVehicle(tVeh[i]);
	}
	return 1;
}
//===================================//
public HideText()
{
    for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	        TextDrawHideForPlayer(i, BG);
	        TextDrawHideForPlayer(i, TR);
	        TextDrawHideForPlayer(i, C_TT[i]);
	        TextDrawHideForPlayer(i, C_CP[i]);
	        TextDrawHideForPlayer(i, A_TT[i]);
	        TextDrawHideForPlayer(i, A_OB[i]);
	        TextDrawHideForPlayer(i, A_AC[i]);
	        TextDrawHideForPlayer(i, S_CP[i]);
    	    TextDrawHideForPlayer(i, S_TT[i]);
	        TextDrawHideForPlayer(i, Cycle);
	        TextDrawHideForPlayer(i, Shoot);
	        TextDrawHideForPlayer(i, Swim);
    	    TextDrawHideForPlayer(i, T_TT[i]);
	        TextDrawHideForPlayer(i, Winner);
		}
	}
	return 1;
}
//===================================//
stock SetTriSpawn(playerid)
{
	new pos;
	pos = random(sizeof(MiniSpawns));
	SetPlayerPos(playerid, MiniSpawns[pos][0], MiniSpawns[pos][1], MiniSpawns[pos][2]);
	SetPlayerFacingAngle(playerid,MiniSpawns[pos][3]);
	SetPlayerVirtualWorld(playerid, 15);
	return 1;
}
//===================================//
stock getIntRand(ll, ul)
{
	new range = ul-ll;
	new number = ll+(rand()%range);
	return number;
}
//===================================//
Float:getRand(Float:ll, Float:ul)
{
    new ulv = floatround(ul, floatround_ceil);
    new llv = floatround(ll, floatround_floor);
	new range = ulv-llv;
	new Float:number = ll+(rand()%range);
	return number;
}
//===================================//
stock CreateAimObject(playerid)
{
	oCount++;
	pobjects[playerid]++;
	new oid = oCount;
	new Float:x = getRand(870.8545, 875.5131);
	new Float:y = getRand(-2128.3379, -2134.1309);
	new Float:z = getRand(9.6219, 17.1911);

	AimObject[oid][obX][playerid] = x;
	AimObject[oid][obY][playerid] = y;
	AimObject[oid][obZ][playerid] = z;
	A_Objects[oid][playerid] = CreatePlayerObject(playerid, 1600, AimObject[oid][obX][playerid], AimObject[oid][obY][playerid], AimObject[oid][obZ][playerid], 0.00000000,16.32929716,97.11634627);
	return 1;
}
//===================================//
stock MoveShootingObjectsForPlayer(playerid)
{
    for(new i=0; i<20; i++)
	{
		CreateAimObject(playerid);
	}
    for(new i=0; i<=20; i++)
	{
		new rand_val = random(sizeof(rand_float));
	    MovePlayerObject(playerid, A_Objects[i][playerid], 790.6284, AimObject[i][obY][playerid], AimObject[i][obZ][playerid], rand_float[rand_val]);
	}
	return 1;
}
//===================================//
stock MoveObjectsForPlayerAgain(playerid)
{
	new ObjNo = robjects[playerid];
	pobjects[playerid] = 0;
    for(new i=0; i<ObjNo; i++)
	{
		CreateAimObject(playerid);
    }
    for(new i=0; i<=ObjNo; i++)
	{
  		new rand_val = random(sizeof(rand_float));
	    MovePlayerObject(playerid, A_Objects[i][playerid], 790.6284, AimObject[i][obY][playerid], AimObject[i][obZ][playerid], rand_float[rand_val]);
	}
	return 1;
}
//===================================//
stock rand()
{
	new rand_num = random(MAX_RAND);
	return rand_num;
}
//===================================//
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
{
	new Float:TGTDistance;

	TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

	new Float:tmpX, Float:tmpY, Float:tmpZ;

	tmpX = FrX * TGTDistance + CamX;
	tmpY = FrY * TGTDistance + CamY;
	tmpZ = FrZ * TGTDistance + CamZ;

	return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
//===================================//
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)
{
	new Float:DX, Float:DY;
  	new Float:angle;

  	DX = floatabs(floatsub(x2,X));
  	DY = floatabs(floatsub(y2,Y));

  	if (DY == 0.0 || DX == 0.0)
	{
		if(DY == 0 && DX > 0) angle = 0.0;
    	else if(DY == 0 && DX < 0) angle = 180.0;
    	else if(DY > 0 && DX == 0) angle = 90.0;
    	else if(DY < 0 && DX == 0) angle = 270.0;
    	else if(DY == 0 && DX == 0) angle = 0.0;
  	}
  	else
  	{
		angle = atan(DX/DY);
    	if(X > x2 && Y <= y2) angle += 90.0;
    	else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
    	else if(X < x2 && Y >= y2) angle -= 90.0;
    	else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
  	}
  	return floatadd(angle, 90.0);
}
//===================================//
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
{
	x += (distance * floatsin(-angle, degrees));
	y += (distance * floatcos(-angle, degrees));
}
//===================================//
stock IsPlayerAiming(playerid, Float:x, Float:y, Float:z, Float:radius)
{
	new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
  	GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
  	GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);

	new Float:vertical, Float:horizontal;

	switch (GetPlayerWeapon(playerid))
	{
	  	case 34,35,36:
 		{
	  		if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
	  		return false;
	  	}
	  	case 30,31:
	  	{
		  	vertical = 4.0;
			horizontal = -1.6;
	  	}
	  	case 33:
	  	{
	  		vertical = 2.7;
			horizontal = -1.0;
	  	}
	  	default:
 		{
		 	vertical = 6.0;
			horizontal = -2.2;
 		}
	}
  	new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  	new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  	GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));

  	if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  	return false;
}
//===================================//
stock PlayerName(playerid)
{
	new n[MAX_PLAYER_NAME];
	GetPlayerName(playerid, n, MAX_PLAYER_NAME);
	return n;
}

Link to comment
Share on other sites

/*
                            ---- TRIATHLON MINIGAME ----

                                ---- CREATED BY ----
					  ______   ____      ______      ____ ___
					   |    | |      /\   |   |   | |     |__|
					   |    | |---- /--\  |   |---| |---- | \
  					  _|____| |____/    \ |   |   | |____ |  \
    				 	 									 - BORN TO KIL

    				 	 		---- CREDITS ----
			 	 1. ZeeX - zcmd
			 	 2. niCe - 'IsPlayerAiming' function

				 	 		   ---- IMPORTANT ----
		You can edit this to your satisfaction and use it in your server.
		But you are not allowed to re-sell/release it as your script anywhere.
*/
#include <a_samp>
#include <zcmd>
//===================================//
#define RED 		0xFF0000C7
#define GREEN 		0x33AA33AA
#define ORANGE 		0xFF9900AA
#define TITANIUM 	0xFCFFF0AA
#define CORAL 		0xEFC286FF
#define GOLD 		0xB8860BAA

#define MAX_OBJS  		100
#define MAX_TOBJS   	29 // No of other objects
#define MAX_RAND 		32767 //Donot Change!!!
#define FINAL_CP_CYCLE 	16
#define FINAL_CP_SWIM	9

#define HIDE_TEXT_TIME 20000 //Time in milliseconds to display the final statistics

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
//===================================//
new Float:MiniSpawns[8][4] =
{
    {1237.001343,-2031.758545,60.551205,268.0000},
	{1237.087769,-2030.034424,60.576206,268.0000},
	{1237.237793,-2027.961792,60.426197,268.0000},
	{1237.336670,-2025.825806,60.326191,268.0000},
	{1240.417236,-2031.980713,59.476139,268.0000},
	{1240.311157,-2026.085327,59.526142,268.0000},
	{1240.278809,-2028.149902,59.551144,268.0000},
	{1240.300537,-2030.038940,59.526142,268.0000}
};

new tObj[MAX_TOBJS];
new tVeh[8];
//I created this long time ago (Before Pvars were created) I didnt have time to change them.
new PCP[MAX_PLAYERS];
new PlayerJoined[MAX_PLAYERS];
new bool:MiniOn;
new TP;

new inctimer[MAX_PLAYERS];
new MIN[MAX_PLAYERS];
new SEC[MAX_PLAYERS];
new First;
new winner[MAX_PLAYER_NAME];

new Text:Tbg;
new Text:TT[MAX_PLAYERS];
new Text:NO[MAX_PLAYERS];
new Text:BG;
new Text:TR;
new Text:C_TT[MAX_PLAYERS];
new Text:C_CP[MAX_PLAYERS];
new Text:A_TT[MAX_PLAYERS];
new Text:A_OB[MAX_PLAYERS];
new Text:A_AC[MAX_PLAYERS];
new Text:S_CP[MAX_PLAYERS];
new Text:S_TT[MAX_PLAYERS];
new Text:Cycle;
new Text:Shoot;
new Text:Swim;
new Text:T_TT[MAX_PLAYERS];
new Text:Winner;
//***************************MOUNTAIN BIKE RACE*******************************//
new Float:CRaceCPoints[17][3] =
{
	{1273.332275,-2056.174316,58.064869},
	{1389.242432,-2047.083130,54.034203},
	{1426.094849,-1988.133789,48.100159},
	{1315.031494,-1957.947998,28.298063},
	{1260.021973,-1908.830322,28.799747},
	{1422.825806,-1922.275146,14.627296},
	{1332.206909,-1853.607300,12.382813},
	{1222.804077,-1852.206665,12.382813},
	{1061.719849,-1849.264771,12.567745},
	{983.637329,-1785.176270,13.074606},
	{843.459045,-1769.413818,12.395102},
	{827.917297,-1841.450439,11.644958},
	{845.218689,-1890.641602,11.867188},
	{830.854797,-1943.510010,11.867188},
	{844.152771,-2001.475952,11.867188},
	{835.849304,-2055.608154,11.867188},
	{0.0,0.0,0.0}
};
new bool:IsPlayerRacing[MAX_PLAYERS];
new c_minutes[MAX_PLAYERS];
new c_seconds[MAX_PLAYERS];
//*******************************SHOOTING RANGE*******************************//
enum moveobjs
{
	Float:obX[MAX_PLAYERS],
	Float:obY[MAX_PLAYERS],
	Float:obZ[MAX_PLAYERS]
};

new Float:rand_float[17] = //Speed with which the objects move
{0.8, 0.9, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9};

new AimObject[MAX_OBJS][moveobjs];

new A_Objects[MAX_OBJS][MAX_PLAYERS];
new pobjects[MAX_PLAYERS];
new robjects[MAX_PLAYERS];
new obj_hit[MAX_PLAYERS];
new shootpick[5];
new oCount = 0;
new bool:IsPlayerShooting[MAX_PLAYERS];
new a_minutes[MAX_PLAYERS];
new a_seconds[MAX_PLAYERS];
new Float:accuracy[MAX_PLAYERS];
//********************************SWIMMING RACE*******************************//
new Float:SRaceCPoints[10][3] =
{
	{834.885010,-2094.992676,0.007755},
	{719.189026,-2094.839844,0.009658},
	{725.342163,-1969.148926,0.055709},
	{724.468750,-1887.028687,-0.014958},
	{724.574524,-1778.495361,-0.020918},
	{723.868225,-1695.539795,-0.069923},
	{724.020508,-1580.007324,0.069664},
	{723.220154,-1488.487915,0.934345},
	{728.4586,-1440.3844,17.6953},
	{0.0,0.0,0.0}
};
new bool:IsPlayerSwimming[MAX_PLAYERS];
new s_minutes[MAX_PLAYERS];
new s_seconds[MAX_PLAYERS];
//===================================//
forward StartCycleRace();
forward StopCycleRaceForPlayer(playerid);
forward TextDrawUpdate(playerid);
forward StartAccuTest(playerid);
forward StartShootingForPlayer(playerid);
forward EndShootingForPlayer(playerid);
forward StartSwimmingForPlayer(playerid);
forward StopSwimmingForPlayer(playerid);
forward EndTriathlon();
forward HideText();
//===================================//
public OnFilterScriptInit()
{
    Tbg = TextDrawCreate(630.000000, 371.000000, "_");
	TextDrawBackgroundColor(Tbg, 255);
	TextDrawFont(Tbg, 1);
	TextDrawLetterSize(Tbg, 0.500000, 7.200000);
	TextDrawColor(Tbg, -1);
	TextDrawSetOutline(Tbg, 0);
	TextDrawSetProportional(Tbg, 1);
	TextDrawSetShadow(Tbg, 1);
	TextDrawUseBox(Tbg, 1);
	TextDrawBoxColor(Tbg, 252645270);
	TextDrawTextSize(Tbg, 460.000000, 40.000000);

	BG = TextDrawCreate(505.000000, 129.000000, "_");
	TextDrawBackgroundColor(BG, 255);
	TextDrawFont(BG, 1);
	TextDrawLetterSize(BG, 0.549998, 23.600002);
	TextDrawColor(BG, -1);
	TextDrawSetOutline(BG, 1);
	TextDrawSetProportional(BG, 1);
	TextDrawUseBox(BG, 1);
	TextDrawBoxColor(BG, 252645270);
	TextDrawTextSize(BG, 108.000000, 0.000000);

	TR = TextDrawCreate(204.000000, 128.000000, "TRIATHLON RESULTS");
	TextDrawBackgroundColor(TR, 255);
	TextDrawFont(TR, 2);
	TextDrawLetterSize(TR, 0.500000, 1.500000);
	TextDrawColor(TR, 845453000);
	TextDrawSetOutline(TR, 0);
	TextDrawSetProportional(TR, 1);
	TextDrawSetShadow(TR, 1);

	Cycle = TextDrawCreate(149.000000, 150.000000, "Cycling");
	TextDrawBackgroundColor(Cycle, 255);
	TextDrawFont(Cycle, 1);
	TextDrawLetterSize(Cycle, 0.480000, 1.200000);
	TextDrawColor(Cycle, -1);
	TextDrawSetOutline(Cycle, 0);
	TextDrawSetProportional(Cycle, 1);
	TextDrawSetShadow(Cycle, 1);

	Shoot = TextDrawCreate(265.000000, 150.000000, "Shooting");
	TextDrawBackgroundColor(Shoot, 255);
	TextDrawFont(Shoot, 1);
	TextDrawLetterSize(Shoot, 0.480000, 1.200000);
	TextDrawColor(Shoot, -1);
	TextDrawSetOutline(Shoot, 0);
	TextDrawSetProportional(Shoot, 1);
	TextDrawSetShadow(Shoot, 1);

	Swim = TextDrawCreate(390.000000, 150.000000, "Swimming");
	TextDrawBackgroundColor(Swim, 255);
	TextDrawFont(Swim, 1);
	TextDrawLetterSize(Swim, 0.480000, 1.200000);
	TextDrawColor(Swim, -1);
	TextDrawSetOutline(Swim, 0);
	TextDrawSetProportional(Swim, 1);
	TextDrawSetShadow(Swim, 1);

	Winner = TextDrawCreate(290.000000, 297.000000, "Winner:");
	TextDrawAlignment(Winner, 2);
	TextDrawBackgroundColor(Winner, 255);
	TextDrawFont(Winner, 2);
	TextDrawLetterSize(Winner, 0.389999, 1.799999);
	TextDrawColor(Winner, -1);
	TextDrawSetOutline(Winner, 0);
	TextDrawSetProportional(Winner, 1);
	TextDrawSetShadow(Winner, 1);

	for(new i=0; i<MAX_PLAYERS; i++)
	{
		TT[i] = TextDrawCreate(470.000000, 381.000000, "Time: 00:00");
		TextDrawBackgroundColor(TT[i], 255);
		TextDrawFont(TT[i], 1);
		TextDrawLetterSize(TT[i], 0.500000, 1.500000);
		TextDrawColor(TT[i], -1);
		TextDrawSetOutline(TT[i], 0);
		TextDrawSetProportional(TT[i], 1);
		TextDrawSetShadow(TT[i], 1);

		NO[i] = TextDrawCreate(470.000000, 408.000000, "Checkpoint: 0/16");
		TextDrawBackgroundColor(NO[i], 255);
		TextDrawFont(NO[i], 1);
		TextDrawLetterSize(NO[i], 0.500000, 1.500000);
		TextDrawColor(NO[i], -1);
		TextDrawSetOutline(NO[i], 0);
		TextDrawSetProportional(NO[i], 1);
		TextDrawSetShadow(NO[i], 1);

		C_TT[i] = TextDrawCreate(120.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(C_TT[i], 255);
		TextDrawFont(C_TT[i], 1);
		TextDrawLetterSize(C_TT[i], 0.330000, 1.199999);
		TextDrawColor(C_TT[i], -1);
		TextDrawSetOutline(C_TT[i], 0);
		TextDrawSetProportional(C_TT[i], 1);
		TextDrawSetShadow(C_TT[i], 1);

		C_CP[i] = TextDrawCreate(120.000000, 200.000000, "Checkpoints:");
		TextDrawBackgroundColor(C_CP[i], 255);
		TextDrawFont(C_CP[i], 1);
		TextDrawLetterSize(C_CP[i], 0.330000, 1.199999);
		TextDrawColor(C_CP[i], -1);
		TextDrawSetOutline(C_CP[i], 0);
		TextDrawSetProportional(C_CP[i], 1);
		TextDrawSetShadow(C_CP[i], 1);

		A_TT[i] = TextDrawCreate(250.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(A_TT[i], 255);
		TextDrawFont(A_TT[i], 1);
		TextDrawLetterSize(A_TT[i], 0.330000, 1.199999);
		TextDrawColor(A_TT[i], -1);
		TextDrawSetOutline(A_TT[i], 0);
		TextDrawSetProportional(A_TT[i], 1);
		TextDrawSetShadow(A_TT[i], 1);

		A_OB[i] = TextDrawCreate(250.000000, 200.000000, "Objects:");
		TextDrawBackgroundColor(A_OB[i], 255);
		TextDrawFont(A_OB[i], 1);
		TextDrawLetterSize(A_OB[i], 0.330000, 1.199999);
		TextDrawColor(A_OB[i], -1);
		TextDrawSetOutline(A_OB[i],	 0);
		TextDrawSetProportional(A_OB[i], 1);
		TextDrawSetShadow(A_OB[i], 1);

		A_AC[i] = TextDrawCreate(250.000000, 230.000000, "Accuracy:");
		TextDrawBackgroundColor(A_AC[i], 255);
		TextDrawFont(A_AC[i], 1);
		TextDrawLetterSize(A_AC[i], 0.330000, 1.199999);
		TextDrawColor(A_AC[i], -1);
		TextDrawSetOutline(A_AC[i], 0);
		TextDrawSetProportional(A_AC[i], 1)	;
		TextDrawSetShadow(A_AC[i], 1);

		S_CP[i] = TextDrawCreate(380.000000, 200.000000, "Checkpoints:");
		TextDrawBackgroundColor(S_CP[i], 255);
		TextDrawFont(S_CP[i], 1);
		TextDrawLetterSize(S_CP[i], 0.330000, 1.199999);
		TextDrawColor(S_CP[i], -1);
		TextDrawSetOutline(S_CP[i], 0);
		TextDrawSetProportional(S_CP[i], 1);
		TextDrawSetShadow(S_CP[i], 1);

		S_TT[i] = TextDrawCreate(380.000000, 170.000000, "Time Taken:");
		TextDrawBackgroundColor(S_TT[i], 255);
		TextDrawFont(S_TT[i], 1);
		TextDrawLetterSize(S_TT[i], 0.330000, 1.199999);
		TextDrawColor(S_TT[i], -1);
		TextDrawSetOutline(S_TT[i], 0);
		TextDrawSetProportional(S_TT[i], 1);
		TextDrawSetShadow(S_TT[i], 1);

		T_TT[i] = TextDrawCreate(220.000000, 267.000000, "Total Time: 00:00");
		TextDrawBackgroundColor(T_TT[i], 255);
		TextDrawFont(T_TT[i], 2);
		TextDrawLetterSize(T_TT[i], 0.389999, 1.799999);
		TextDrawColor(T_TT[i], -1);
		TextDrawSetOutline(T_TT[i], 0);
		TextDrawSetProportional(T_TT[i], 1);
		TextDrawSetShadow(T_TT[i], 1);
	}
	return 1;
}
//===================================//
public OnFilterScriptExit()
{
   	EndTriathlon();
	return 1;
}
//===================================//
public OnPlayerDisconnect(playerid, reason)
{
	if(PlayerJoined[playerid] == 1)
    {
    	PlayerJoined[playerid] = 0;
    	PCP[playerid] = 0;
    	MIN[playerid] = 0;
    	SEC[playerid] = 0;
		c_minutes[playerid] = 0;
		c_seconds[playerid] = 0;
		s_minutes[playerid] = 0;
		s_seconds[playerid] = 0;
		a_minutes[playerid] = 0;
		a_seconds[playerid] = 0;
		pobjects[playerid] = 0;
		obj_hit[playerid] = 0;
		robjects[playerid] = 0;
		IsPlayerShooting[playerid] = false;
		accuracy[playerid] = 0;
		for(new i=0; i<MAX_TOBJS; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i=0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		if(TP == 2)
		{
		    EndTriathlon();
		}
		TP--;
	}
	return 1;
}
//===================================//
public OnPlayerDeath(playerid, killerid, reason)
{
	if(PlayerJoined[playerid] == 1)
    {
    	PlayerJoined[playerid] = 0;
    	PCP[playerid] = 0;
    	MIN[playerid] = 0;
    	SEC[playerid] = 0;
		c_minutes[playerid] = 0;
		c_seconds[playerid] = 0;
		s_minutes[playerid] = 0;
		s_seconds[playerid] = 0;
		a_minutes[playerid] = 0;
		a_seconds[playerid] = 0;
		pobjects[playerid] = 0;
		obj_hit[playerid] = 0;
		robjects[playerid] = 0;
		IsPlayerShooting[playerid] = false;
		accuracy[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
		DisablePlayerRaceCheckpoint(playerid);
		for(new i=0; i<MAX_TOBJS; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i=0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		if(TP == 2)
		{
		    EndTriathlon();
		}
		TP--;
	}
	return 1;
}
//===================================//
CMD:tinfo(playerid, params[])
{
    SendClientMessage(playerid, GREEN, "*** The Triathlon Minigame ***");
    SendClientMessage(playerid, CORAL, "To join the minigame - /triathlon");
    SendClientMessage(playerid, CORAL, "It includes 3 minigames:");
	SendClientMessage(playerid, CORAL, "1. Cycling");
	SendClientMessage(playerid, CORAL, "2. Shooting");
	SendClientMessage(playerid, CORAL, "3. Swimming");
	SendClientMessage(playerid, CORAL, "Location - Around Los Santos Beach");
	SendClientMessage(playerid, CORAL, "Created By - DeatheR");
	SendClientMessage(playerid, GREEN, "******************************");
	return 1;
}
//===================================//
CMD:triathlon(playerid, params[])
{
	if(PlayerJoined[playerid] == 1) return SendClientMessage(playerid, RED, "gBOT: You are already in the minigame!");
	if(MiniOn) return SendClientMessage(playerid, RED, "gBOT: The minigame has already started!");
	TP++;
	if(TP == 1)
	{
		First = 1;
	    SendClientMessage(playerid, CORAL, "gBOT: You started the minigame!");
	    SetTimer("StartCycleRace", 15000, false);
	    PlayerJoined[playerid] = 1;
	    GameTextForAll("~y~TRIATHLON ~g~minigame is starting in 15 seconds!~n~~n~~w~Use ~g~/triathlon~w~ to join!",3000,3);
		SendClientMessageToAll(TITANIUM, "gBOT: The Triathlon minigame is starting in 15 seconds! To join use: /triathlon");
	}
    else if(TP != 1 && TP < 6)
	{
		PlayerJoined[playerid] = 1;
		SendClientMessage(playerid, GREEN, "gBOT: You signed up the minigame!");
	}
	else
	{
	    SendClientMessage(playerid, RED, "gBOT: No empty slots. You cannot join the minigame!");
	}
    return 1;
}
//===================================//
CMD:stoptri(playerid, params[])
{
	if(!IsPlayerAdmin(playerid))/* change to your admin variable */ return SendClientMessage(playerid, RED, "gBOT: You need to be an admin!");
    if(!MiniOn) return SendClientMessage(playerid, RED, "gBOT: The Triathlon Minigame is not started!");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerJoined[i] == 1)
            {
	    	    PlayerJoined[i] = 0;
	    	    MiniOn = false;
	    	    MIN[i] = 0;
	    	    SEC[i] = 0;
	    	    c_minutes[i] = 0;
				c_seconds[i] = 0;
				s_minutes[i] = 0;
				s_seconds[i] = 0;
				a_minutes[i] = 0;
				a_seconds[i] = 0;
				pobjects[i] = 0;
				obj_hit[i] = 0;
				SetPlayerVirtualWorld(i, 0);
				SpawnPlayer(playerid);
				DisablePlayerCheckpoint(i);
				DisablePlayerRaceCheckpoint(i);
				SendClientMessage(playerid, ORANGE, "gBOT: An Administrator stopped the Triathlon Minigame!");
			}
		}
	}
	for(new i = 0; i<28; i++)
	{
	    DestroyObject(tObj[i]);
	}
	for(new i = 0; i<8; i++)
	{
	    DestroyVehicle(tVeh[i]);
	}
	return 1;
}
//===================================//
public StartCycleRace()
{
	if(TP < 2)
	{
	    for(new i = 0; i<MAX_PLAYERS; i++)
		{
	   	 	if(IsPlayerConnected(i))
	   	 	{
	   	 		if(PlayerJoined[i] == 1)
	    		{
	    	    	PlayerJoined[i] = 0;
	    	    	MiniOn = false;
	    	    	c_minutes[i] = 0;
					c_seconds[i] = 0;
					s_minutes[i] = 0;
					s_seconds[i] = 0;
					a_minutes[i] = 0;
					a_seconds[i] = 0;
					pobjects[i] = 0;
					obj_hit[i] = 0;
					SetPlayerVirtualWorld(i, 0);
				}
			}
		}
		for(new i = 0; i<28; i++)
		{
		    DestroyObject(tObj[i]);
		}
		for(new i = 0; i<8; i++)
		{
		    DestroyVehicle(tVeh[i]);
		}
		SendClientMessageToAll(RED, "gBOT: Enough no of slots weren't filled. Minigames closes!");
		return 1;
	}
    tObj[0] = CreateObject(16770,834.470886,-2061.860352,13.457747,0,0,-451.203690604705);
	tObj[1] = CreateObject(7415,1267.988037,-2047.902588,68.010406,0,0,-18.0481705425);
	tObj[2] = CreateObject(3749,827.610046,-1841.624390,17.592625,0,0,0);
	tObj[3] = CreateObject(3749,845.445862,-1890.523193,17.725601,0,0,0);
	tObj[4] = CreateObject(3749,829.592224,-1943.385376,17.725601,0,0,0);
	tObj[5] = CreateObject(3749,844.374756,-2001.207275,17.725601,0,0,0);
	tObj[6] = CreateObject(3749,836.334900,-2056.039551,17.725601,0,0,0);
	tObj[7] = CreateObject(1238,835.760986,-1845.852173,12.039591,0,0,0);
	tObj[8] = CreateObject(1238,835.740540,-1851.846680,12.185368,0,0,0);
	tObj[9] = CreateObject(1238,835.801575,-1857.624268,12.185368,0,0,0);
	tObj[10] = CreateObject(1238,836.116516,-1871.669678,12.185368,0,0,0);
	tObj[11] = CreateObject(1238,836.255249,-1877.932739,12.185368,0,0,0);
	tObj[12] = CreateObject(1238,836.524597,-1884.574951,12.185368,0,0,0);
	tObj[13] = CreateObject(1225,835.893982,-1864.494385,12.272943,0,0,0);
	tObj[14] = CreateObject(1238,838.934326,-1930.782349,12.185368,0,0,0);
	tObj[15] = CreateObject(1238,838.920349,-1938.016968,12.185368,0,0,0);
	tObj[16] = CreateObject(1238,838.900818,-1923.343140,12.185368,0,0,0);
	tObj[17] = CreateObject(1238,838.210815,-1909.989380,12.185368,0,0,0);
	tObj[18] = CreateObject(1238,838.068359,-1902.773682,12.185368,0,0,0);
	tObj[19] = CreateObject(1238,837.769714,-1896.132813,12.185368,0,0,0);
	tObj[20] = CreateObject(1225,838.749329,-1916.551147,12.272943,0,0,0);
	tObj[21] = CreateObject(1238,837.477722,-1995.682861,12.185368,0,0,0);
	tObj[22] = CreateObject(1238,837.296265,-1987.223755,12.185368,0,0,0);
	tObj[23] = CreateObject(1238,837.335876,-1978.739502,12.185368,0,0,0);
	tObj[24] = CreateObject(1238,836.794128,-1948.627075,12.185368,0,0,0);
	tObj[25] = CreateObject(1238,836.978333,-1954.809570,12.185368,0,0,0);
	tObj[26] = CreateObject(1238,837.030212,-1963.298706,12.185368,0,0,0);
	tObj[27] = CreateObject(1225,837.202026,-1970.918457,12.272943,0,0,0);
	tObj[28] = CreateObject(17068,836.163024,-2063.765869,10.699330,0,0.5,180);

    tVeh[0] = CreateVehicle(510,1245.325439,-2044.066650,59.406025,178,-1,-1,300);
	tVeh[1] = CreateVehicle(510,1246.915039,-2044.073120,59.356022,178,-1,-1,300);
	tVeh[2] = CreateVehicle(510,1248.549438,-2044.101196,59.331020,178,-1,-1,300);
	tVeh[3] = CreateVehicle(510,1250.149292,-2044.238281,59.281017,178,-1,-1,300);
	tVeh[4] = CreateVehicle(510,1251.678101,-2044.304932,59.131008,178,-1,-1,300);
	tVeh[5] = CreateVehicle(510,1253.234863,-2044.180420,59.126118,178,-1,-1,300);
	tVeh[6] = CreateVehicle(510,1254.649536,-2044.214966,59.076115,178,-1,-1,300);
	for(new i=0; i<7; i++)
	{
	    SetVehicleVirtualWorld(tVeh[i], 15);
	}
	shootpick[0] = CreatePickup(1318, 23,841.6972,-2064.9282,12.8672,15);
	shootpick[1] = CreatePickup(1318, 23,838.6654,-2065.0652,12.8672,15);
	shootpick[2] = CreatePickup(1318, 23,835.5880,-2065.0959,12.8672,15);
	shootpick[3] = CreatePickup(1318, 23,832.6954,-2064.6465,12.8672,15);
	shootpick[4] = CreatePickup(1318, 23,829.8810,-2064.5100,12.8672,15);

	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(PlayerJoined[i] == 1)
	    {
	        SetTriSpawn(i);
	        TextDrawShowForPlayer(i, Tbg);
			TextDrawShowForPlayer(i, TT[i]);
			TextDrawShowForPlayer(i, NO[i]);
	        SendClientMessage(i, ORANGE, "gBOT: Grab a Mountain Bike and start the race!");
	        MiniOn = true;
    		IsPlayerRacing[i] = true;
			PCP[i] = 0;
			ResetPlayerWeapons(i);
			TextDrawShowForPlayer(i, TT[i]);
			TextDrawShowForPlayer(i, NO[i]);
  			SetPlayerRaceCheckpoint(i, 0, CRaceCPoints[PCP[i]][0], CRaceCPoints[PCP[i]][1], CRaceCPoints[PCP[i]][2], CRaceCPoints[PCP[i]+1][0], CRaceCPoints[PCP[i]+1][1], CRaceCPoints[PCP[i]+1][2], 8);
            inctimer[i] = SetTimerEx("TextDrawUpdate", 1000, true, "d", i);
		}
	}
	return 1;
}
//===================================//
public TextDrawUpdate(playerid)
{
	if(IsPlayerRacing[playerid])
	{
		new string[32];
    	c_seconds[playerid]++;
    	if(c_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", c_minutes[playerid], c_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", c_minutes[playerid], c_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}

		if(c_seconds[playerid] == 59)
		{
		    c_minutes[playerid]++;
		    c_seconds[playerid] = 0;
		}
	}
	else if(IsPlayerShooting[playerid])
	{
		new string[32];
    	a_seconds[playerid]++;
    	if(a_seconds[playerid] == 59)
		{
		    a_minutes[playerid]++;
		    a_seconds[playerid] = 0;
		}
		if(a_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", a_minutes[playerid], a_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", a_minutes[playerid], a_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
	}
	else if(IsPlayerSwimming[playerid])
	{
		new string[32];
    	s_seconds[playerid]++;
    	if(s_seconds[playerid] < 10)
		{
		    format(string,sizeof(string), "Time: 0%d:0%d", s_minutes[playerid], s_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}
		else
		{
		    format(string,sizeof(string), "Time: 0%d:%d", s_minutes[playerid], s_seconds[playerid]);
    	    TextDrawSetString(TT[playerid], string);
		}

		if(s_seconds[playerid] == 59)
		{
		    s_minutes[playerid]++;
		    s_seconds[playerid] = 0;
		}
	}
	return 1;
}
//===================================//
public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(IsPlayerRacing[playerid])
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 510)
		{
		    GameTextForPlayer(playerid,"~r~You need a ~y~Mountain Bike ~r~to continue the race!",4500,4);
		    return 1;
		}
		if(PCP[playerid] != FINAL_CP_CYCLE) PCP[playerid] ++;
		new string[32];
		format(string,sizeof(string), "Checkpoint: %d/16", PCP[playerid]);
    	TextDrawSetString(NO[playerid], string);
		if(PCP[playerid] == FINAL_CP_CYCLE)
	    {
	    	StopCycleRaceForPlayer(playerid);
			return 1;
		}
		if(PCP[playerid] == FINAL_CP_CYCLE-1)
		{
			SetPlayerRaceCheckpoint(playerid, 1, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 10);
			return 1;
		}
	 	SetPlayerRaceCheckpoint(playerid, 0, CRaceCPoints[PCP[playerid]][0], CRaceCPoints[PCP[playerid]][1], CRaceCPoints[PCP[playerid]][2], CRaceCPoints[PCP[playerid]+1][0], CRaceCPoints[PCP[playerid]+1][1], CRaceCPoints[PCP[playerid]+1][2], 8);
	}
	else if(IsPlayerSwimming[playerid])
    {
		if(PCP[playerid] != FINAL_CP_SWIM) PCP[playerid] ++;
		new string[32];
		format(string,sizeof(string), "Checkpoint: %d/9", PCP[playerid]);
    	TextDrawSetString(NO[playerid], string);
		if(PCP[playerid] == FINAL_CP_SWIM)
	    {
	        if(First == 1)
	        {
				TP--;
				First++;
	            format(winner, MAX_PLAYER_NAME, "%s", PlayerName(playerid));
	    		StopSwimmingForPlayer(playerid);
	    		if(TP == 0)  //Just for testing
			    {
			        SetTimer("EndTriathlon", 1000, false);
				}
			}
			else
			{
			    TP--;
			    StopSwimmingForPlayer(playerid);
			    if(TP == 0)
			    {
			        SetTimer("EndTriathlon", 1000, false);
				}
			}
			return 1;
		}
		if(PCP[playerid] == FINAL_CP_SWIM-1)
		{
			SetPlayerRaceCheckpoint(playerid, 1, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 10);
			return 1;
		}
	 	SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);
	}
	return 1;
}
//===================================//
public StopCycleRaceForPlayer(playerid)
{
	DisablePlayerRaceCheckpoint(playerid);
	PCP[playerid] = 0;
	IsPlayerRacing[playerid] = false;
	MIN[playerid] += c_minutes[playerid];
	SEC[playerid] += c_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);

	SendClientMessage(playerid, ORANGE, "gBOT: Well Done! Now Start the Shooting!");
	return 1;
}
//===================================//
public OnPlayerPickUpPickup(playerid, pickupid)
{
	for(new i=0; i<5; i++)
	{
	    if(pickupid == shootpick[i])
		{
		    DestroyPickup(shootpick[i]);
		    StartShootingForPlayer(playerid);
		    break;
		}
	}
	return 1;
}
//===================================//
public StartShootingForPlayer(playerid)
{
    TextDrawShowForPlayer(playerid, Tbg);
    TextDrawSetString(TT[playerid], "Time: 00:00");
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawSetString(NO[playerid], "Hits: 0");
	TextDrawShowForPlayer(playerid, NO[playerid]);
    IsPlayerShooting[playerid] = true;
    ResetPlayerWeapons(playerid);
    SetPlayerVirtualWorld(playerid, getIntRand(20, 30));
    GivePlayerWeapon(playerid, 34, 500);
    MoveShootingObjectsForPlayer(playerid);
	GameTextForPlayer(playerid, "~g~Start Shooting!", 1000, 4);
	inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);
	return 1;
}
//===================================//
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if(MiniOn && PlayerJoined[playerid] == 1)
        {
			for(new i = 0; i <MAX_OBJECTS; i++)
			{
			    if(IsValidPlayerObject(playerid, A_Objects[i][playerid]))
			    {
					new Float:X, Float:Y, Float:Z;
					GetPlayerObjectPos(playerid, A_Objects[i][playerid], X, Y, Z);
			        if(IsPlayerAiming(playerid, X, Y, Z, 0.2))
			        {
			            if(pobjects[playerid] > 0)
			            {
			            	DestroyPlayerObject(playerid, A_Objects[i][playerid]);
			            	pobjects[playerid]--;
			            	obj_hit[playerid]++;
			            	new string[32];
							format(string,sizeof(string), "Hits: %d/20",  obj_hit[playerid]);
							TextDrawSetString(NO[playerid], string);
					 		if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)
	    	  				{
	      						robjects[playerid] = 20 - obj_hit[playerid];
	    	   	 				MoveObjectsForPlayerAgain(playerid);
							}
							else if(obj_hit[playerid] == 20)
							{
							    DestroyPlayerObject(playerid, A_Objects[i][playerid]);
			            		pobjects[playerid]--;
			            		EndShootingForPlayer(playerid);
							}
						}
					}
				}
			}
		}
	}
	return 1;
}
//===================================//
public OnPlayerObjectMoved(playerid,objectid)
{
    for(new i = 0; i <MAX_OBJECTS; i++)
	{
	    if(objectid == A_Objects[i][playerid])
	    {
	    	if(IsValidPlayerObject(playerid, A_Objects[i][playerid]))
	    	{
          		DestroyPlayerObject(playerid, A_Objects[i][playerid]);
	    	    pobjects[playerid]--;
				if(pobjects[playerid] == 0 && obj_hit[playerid] != 20)
	    	  	{
	      			robjects[playerid] = 20 - obj_hit[playerid];
	    	   	 	MoveObjectsForPlayerAgain(playerid);
				}
			}
		}
	}
	return 1;
}
//===================================//
public EndShootingForPlayer(playerid)
{
 	new timetaken = (a_minutes[playerid]*60) + a_seconds[playerid];
	new objs = 20;
	SetPlayerVirtualWorld(playerid, 0);
	accuracy[playerid] = (float(objs) / float(timetaken))*100;
	for(new i=0; i<pobjects[playerid]; i++)
	{
	    DestroyPlayerObject(playerid, A_Objects[i][playerid]);
	}
	IsPlayerShooting[playerid] = false;
	MIN[playerid] += a_minutes[playerid];
	SEC[playerid] += a_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);
	SendClientMessage(playerid, ORANGE, "gBOT: You shot all the objects! Its time for Swimming!");
	StartSwimmingForPlayer(playerid);
	return 1;
}
//===================================//
public StartSwimmingForPlayer(playerid)
{
    ResetPlayerWeapons(playerid);
    SetPlayerPos(playerid, 836.2539, -2069.1489, 10.8726);
    SetPlayerVirtualWorld(playerid, 16);
	TextDrawShowForPlayer(playerid, Tbg);
    TextDrawSetString(TT[playerid], "Time: 00:00");
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawSetString(NO[playerid], "Checkpoint: 0/9");
	TextDrawShowForPlayer(playerid, NO[playerid]);
    IsPlayerSwimming[playerid] = true;
	PCP[playerid] = 0;
	TextDrawShowForPlayer(playerid, TT[playerid]);
	TextDrawShowForPlayer(playerid, NO[playerid]);
	SetPlayerRaceCheckpoint(playerid, 0, SRaceCPoints[PCP[playerid]][0], SRaceCPoints[PCP[playerid]][1], SRaceCPoints[PCP[playerid]][2], SRaceCPoints[PCP[playerid]+1][0], SRaceCPoints[PCP[playerid]+1][1], SRaceCPoints[PCP[playerid]+1][2], 8);
 	inctimer[playerid] = SetTimerEx("TextDrawUpdate", 1000, true, "d", playerid);
	return 1;
}
//===================================//
public StopSwimmingForPlayer(playerid)
{
	DisablePlayerRaceCheckpoint(playerid);
	PCP[playerid] = 0;
	IsPlayerSwimming[playerid] = false;
	MIN[playerid] += s_minutes[playerid];
	SEC[playerid] += s_seconds[playerid];
	KillTimer(inctimer[playerid]);
	TextDrawHideForPlayer(playerid, Tbg);
	TextDrawHideForPlayer(playerid, TT[playerid]);
	TextDrawHideForPlayer(playerid, NO[playerid]);
	SendClientMessage(playerid, GOLD, "gBOT: Great! You have completed the minigame. Now wait for the results");
	return 1;
}
//===================================//
public EndTriathlon()
{
	for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	    	if(PlayerJoined[i] == 1)
	    	{
	    	    new textstr[64];
	    	    PlayerJoined[i] = 0;
	    	    MiniOn = false;
	    	    format(textstr, 64, "Time Taken: ~g~0%d:%d", c_minutes[i], c_seconds[i]);
	    	    TextDrawSetString(C_TT[i], textstr);
	    	    
	    	    TextDrawSetString(C_CP[i], "Checkpoints: ~g~16/16");
	    	    
	    	    format(textstr, 64, "Time Taken: ~g~0%d:%d", a_minutes[i], a_seconds[i]);
	    	    TextDrawSetString(A_TT[i], textstr);
	    	    
	    	    format(textstr, 64, "Objects: ~g~%d/20", obj_hit[i]);
	    	    TextDrawSetString(A_OB[i], textstr);
	    	    
	    	    format(textstr, 64, "Accuracy: ~g~%.2f", accuracy[i]);
	    	    TextDrawSetString(A_AC[i], textstr);
	    	    
	    	    format(textstr, 64, "Time Taken: ~g~%d:%d", s_minutes[i], s_seconds[i]);
	    	    TextDrawSetString(S_TT[i], textstr);
	    	    
	    	    TextDrawSetString(S_CP[i], "Checkpoints: ~g~9/9");
	    	    if(SEC[i]>59)
	    	    {
	    	        MIN[i]++;
	    	        SEC[i] -= 60;
				}
	    	    format(textstr, 64, "Total Time: ~g~%d:%d", MIN[i], SEC[i]);
	    	    TextDrawSetString(T_TT[i], textstr);
	    	    
	    	    format(textstr, 64, "Winner: ~y~%s", winner);
	    	    TextDrawSetString(Winner, textstr);
	    	    
	    	    TextDrawShowForPlayer(i, BG);
	    	    TextDrawShowForPlayer(i, TR);
	    	    TextDrawShowForPlayer(i, C_TT[i]);
	    	    TextDrawShowForPlayer(i, C_CP[i]);
	    	    TextDrawShowForPlayer(i, A_TT[i]);
	    	    TextDrawShowForPlayer(i, A_OB[i]);
	    	    TextDrawShowForPlayer(i, A_AC[i]);
	    	    TextDrawShowForPlayer(i, S_CP[i]);
	    	    TextDrawShowForPlayer(i, S_TT[i]);
	    	    TextDrawShowForPlayer(i, Cycle);
	    	    TextDrawShowForPlayer(i, Shoot);
	    	    TextDrawShowForPlayer(i, Swim);
	    	    TextDrawShowForPlayer(i, T_TT[i]);
	    	    TextDrawShowForPlayer(i, Winner);
	    	    c_minutes[i] = 0;
				c_seconds[i] = 0;
				s_minutes[i] = 0;
				s_seconds[i] = 0;
				a_minutes[i] = 0;
				a_seconds[i] = 0;
				pobjects[i] = 0;
				obj_hit[i] = 0;
				SetTimer("HideText", HIDE_TEXT_TIME, 1);
				SetPlayerVirtualWorld(i, 0);
			}
		}
	}
	for(new i = 0; i<28; i++)
	{
	    DestroyObject(tObj[i]);
	}
	for(new i = 0; i<8; i++)
	{
	    DestroyVehicle(tVeh[i]);
	}
	return 1;
}
//===================================//
public HideText()
{
    for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	        TextDrawHideForPlayer(i, BG);
	        TextDrawHideForPlayer(i, TR);
	        TextDrawHideForPlayer(i, C_TT[i]);
	        TextDrawHideForPlayer(i, C_CP[i]);
	        TextDrawHideForPlayer(i, A_TT[i]);
	        TextDrawHideForPlayer(i, A_OB[i]);
	        TextDrawHideForPlayer(i, A_AC[i]);
	        TextDrawHideForPlayer(i, S_CP[i]);
    	    TextDrawHideForPlayer(i, S_TT[i]);
	        TextDrawHideForPlayer(i, Cycle);
	        TextDrawHideForPlayer(i, Shoot);
	        TextDrawHideForPlayer(i, Swim);
    	    TextDrawHideForPlayer(i, T_TT[i]);
	        TextDrawHideForPlayer(i, Winner);
		}
	}
	return 1;
}
//===================================//
stock SetTriSpawn(playerid)
{
	new pos;
	pos = random(sizeof(MiniSpawns));
	SetPlayerPos(playerid, MiniSpawns[pos][0], MiniSpawns[pos][1], MiniSpawns[pos][2]);
	SetPlayerFacingAngle(playerid,MiniSpawns[pos][3]);
	SetPlayerVirtualWorld(playerid, 15);
	return 1;
}
//===================================//
stock getIntRand(ll, ul)
{
	new range = ul-ll;
	new number = ll+(rand()%range);
	return number;
}
//===================================//
Float:getRand(Float:ll, Float:ul)
{
    new ulv = floatround(ul, floatround_ceil);
    new llv = floatround(ll, floatround_floor);
	new range = ulv-llv;
	new Float:number = ll+(rand()%range);
	return number;
}
//===================================//
stock CreateAimObject(playerid)
{
	oCount++;
	pobjects[playerid]++;
	new oid = oCount;
	new Float:x = getRand(870.8545, 875.5131);
	new Float:y = getRand(-2128.3379, -2134.1309);
	new Float:z = getRand(9.6219, 17.1911);

	AimObject[oid][obX][playerid] = x;
	AimObject[oid][obY][playerid] = y;
	AimObject[oid][obZ][playerid] = z;
	A_Objects[oid][playerid] = CreatePlayerObject(playerid, 1600, AimObject[oid][obX][playerid], AimObject[oid][obY][playerid], AimObject[oid][obZ][playerid], 0.00000000,16.32929716,97.11634627);
	return 1;
}
//===================================//
stock MoveShootingObjectsForPlayer(playerid)
{
    for(new i=0; i<20; i++)
	{
		CreateAimObject(playerid);
	}
    for(new i=0; i<=20; i++)
	{
		new rand_val = random(sizeof(rand_float));
	    MovePlayerObject(playerid, A_Objects[i][playerid], 790.6284, AimObject[i][obY][playerid], AimObject[i][obZ][playerid], rand_float[rand_val]);
	}
	return 1;
}
//===================================//
stock MoveObjectsForPlayerAgain(playerid)
{
	new ObjNo = robjects[playerid];
	pobjects[playerid] = 0;
    for(new i=0; i<ObjNo; i++)
	{
		CreateAimObject(playerid);
    }
    for(new i=0; i<=ObjNo; i++)
	{
  		new rand_val = random(sizeof(rand_float));
	    MovePlayerObject(playerid, A_Objects[i][playerid], 790.6284, AimObject[i][obY][playerid], AimObject[i][obZ][playerid], rand_float[rand_val]);
	}
	return 1;
}
//===================================//
stock rand()
{
	new rand_num = random(MAX_RAND);
	return rand_num;
}
//===================================//
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
{
	new Float:TGTDistance;

	TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

	new Float:tmpX, Float:tmpY, Float:tmpZ;

	tmpX = FrX * TGTDistance + CamX;
	tmpY = FrY * TGTDistance + CamY;
	tmpZ = FrZ * TGTDistance + CamZ;

	return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
//===================================//
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)
{
	new Float:DX, Float:DY;
  	new Float:angle;

  	DX = floatabs(floatsub(x2,X));
  	DY = floatabs(floatsub(y2,Y));

  	if (DY == 0.0 || DX == 0.0)
	{
		if(DY == 0 && DX > 0) angle = 0.0;
    	else if(DY == 0 && DX < 0) angle = 180.0;
    	else if(DY > 0 && DX == 0) angle = 90.0;
    	else if(DY < 0 && DX == 0) angle = 270.0;
    	else if(DY == 0 && DX == 0) angle = 0.0;
  	}
  	else
  	{
		angle = atan(DX/DY);
    	if(X > x2 && Y <= y2) angle += 90.0;
    	else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
    	else if(X < x2 && Y >= y2) angle -= 90.0;
    	else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
  	}
  	return floatadd(angle, 90.0);
}
//===================================//
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
{
	x += (distance * floatsin(-angle, degrees));
	y += (distance * floatcos(-angle, degrees));
}
//===================================//
stock IsPlayerAiming(playerid, Float:x, Float:y, Float:z, Float:radius)
{
	new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
  	GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
  	GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);

	new Float:vertical, Float:horizontal;

	switch (GetPlayerWeapon(playerid))
	{
	  	case 34,35,36:
 		{
	  		if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
	  		return false;
	  	}
	  	case 30,31:
	  	{
		  	vertical = 4.0;
			horizontal = -1.6;
	  	}
	  	case 33:
	  	{
	  		vertical = 2.7;
			horizontal = -1.0;
	  	}
	  	default:
 		{
		 	vertical = 6.0;
			horizontal = -2.2;
 		}
	}
  	new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  	new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  	GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));

  	if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  	return false;
}
//===================================//
stock PlayerName(playerid)
{
	new n[MAX_PLAYER_NAME];
	GetPlayerName(playerid, n, MAX_PLAYER_NAME);
	return n;
}

Tot nu apar.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.