/*
Version 0.2

Autor: [DPS]Riaz (email: riaz06pda@mail.ru)(http://forum.sa-mp.com/index.php?action=profile;u=16818)
Date: 16 Febrary 2008.
*/
#include <a_samp>

#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA

new rop[MAX_PLAYERS];
new ropon[MAX_PLAYERS];

public OnPlayerEnterCheckpoint(playerid)
{
    new name[ 24 ], string[ 256 ];
    GetPlayerName( playerid, name, 30 );
    format( string, sizeof( string ), "[rop]: %s - +1 point!", name );
    GameTextForAll( string, 5000, 3);
    SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
    SetPlayerPos(playerid, 0.0, 0.0, 500.0);
    GivePlayerWeapon(playerid, 46, 1);
    GivePlayerWeapon(playerid, 31, 150);
    GivePlayerMoney(playerid, 10000);
    printf("rop: %s - +1 point!", name);
	return 1;
}

public OnPlayerConnect(playerid)
{
    rop[playerid]=0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    rop[playerid]=0;
	return 1;
}

public OnPlayerSpawn(playerid)
{
    if(rop[playerid]==1)
{
    SetPlayerPos(playerid,2231.8171,-1163.5975,29.7969);
	SendClientMessage(playerid, COLOR_GREEN, "[rop] Auto-Spawning!");
    SendClientMessage(playerid, COLOR_GREEN, "Enter /sropoff if you want stop auto spawning.");
}
    else
{
}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/joinrop", cmdtext, true, 10) == 0)
	{
    new name[ 24 ], string[ 256 ];
    GetPlayerName( playerid, name, 30 );
    format( string, sizeof( string ), "[rop]: %s join to rop!", name );
    SendClientMessage(playerid, COLOR_GREEN, string);
    SetPlayerCheckpoint(playerid,-142.4057,776.3096,25.6619,10.0);
    SendClientMessage(playerid, COLOR_GREEN, "[rop]: You enter to ROP!");
    SendClientMessage(playerid, COLOR_GREEN, "Enter /sropon if you want auto-spawning!");
    SetPlayerPos(playerid, 0.0, 0.0, 500.0);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 46, 1);
    GivePlayerWeapon(playerid, 31, 150);
    ropon[playerid]=1;
	return 1;
	}
	if (strcmp("/leaverop", cmdtext, true, 10) == 0)
	{
    new name[ 24 ], string[ 256 ];
    GetPlayerName( playerid, name, 30 );
    format( string, sizeof( string ), "[rop]: %s leave rop!", name );
    SendClientMessage(playerid, COLOR_GREEN, string);
    DisablePlayerCheckpoint(playerid);
    ropon[playerid]=0;
	return 1;
	}
	if (strcmp("/sropon", cmdtext, true, 10) == 0)
	{
    if(ropon[playerid]==1)
{
	SendClientMessage(playerid, COLOR_RED, "[rop]: You are not in race!");
}
    else
{
    rop[playerid]=1;
    SendClientMessage(playerid, COLOR_GREEN, "[rop]: You on auto-spawning!");
    SendClientMessage(playerid, COLOR_GREEN, "Enter /sropoff if you want stop auto spawning.");
}
	return 1;
}
	if (strcmp("/sropoff", cmdtext, true, 10) == 0)
{
    if(ropon[playerid]==1)
{
	SendClientMessage(playerid, COLOR_RED, "[rop]: You are not in race!");
}
    else
{
    new name[ 24 ], string[ 256 ];
    GetPlayerName( playerid, name, 30 );
    format( string, sizeof( string ), "[rop]: %s leave rop!", name );
    SendClientMessage(playerid, COLOR_GREEN, string);
    DisablePlayerCheckpoint(playerid);
    rop[playerid]=0;
}
    return 1;
}
	return 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(ropon[playerid]==1)
{
    new name[ 24 ], string[ 256 ];
    GetPlayerName( playerid, name, 30 );
    format( string, sizeof( string ), "[rop]: %s dead!", name );
    SendClientMessage(playerid, COLOR_GREEN, string);
}
    else
{
}
	return 1;
}