Código:
//sistema derby LOS_SANTOS
#include <a_samp>
#include <zcmd>
#define spawnX 1310.000000
#define spawnY -1370.199951
#define spawnZ 13.500000
new startvar[8];
forward RewardCalc(playerid,min,max);
new playerinminigame[MAX_PLAYERS];
new bloodring[15],derbyon,derbyplaying,playercarid[MAX_PLAYERS],playerinderby[MAX_PLAYERS],derbyrank,reward,bloodringfull[15],playerinbloodring[MAX_PLAYERS];
new dtimer;
forward Spawnbloodrings();// Derby
forward Destroybloodrings();
forward Respawnbloodrings();
forward StartDerby();
// Derby cars:
new Float:derbycars[15][4] = {
{-1362.9799,932.8219,1036.0580,9.0890}, // 0
{-1346.4526,935.4996,1036.0889,13.6811}, // 1
{-1335.6995,938.2600,1036.1177,16.8043}, // 2
{-1320.8756,944.9904,1036.2062,27.0307}, // 3
{-1306.8385,953.5919,1036.3212,37.8366}, // 4
{-1353.9670,934.0486,1036.2421,11.5836}, // 5
{-1328.6377,941.0197,1036.3208,18.9670}, // 6
{-1313.9012,948.6513,1036.4198,29.5596}, // 7
{-1501.0956,960.3203,1036.9474,313.0457}, // 8
{-1506.8105,968.1082,1037.0840,304.3027}, // 9
{-1513.0317,976.8713,1037.2457,301.9500}, // 10
{-1516.0858,988.2343,1037.4362,274.5044}, // 11
{-1517.6569,995.6628,1037.5626,272.2782}, // 12
{-1515.1127,1004.8807,1037.6969,262.3869}, // 13
{-1510.7020,1014.6202,1037.8568,249.1825} // 14
};
public OnPlayerConnect(playerid)
{
playerinminigame[playerid] = 0;
playercarid[playerid] = -1;
playerinderby[playerid] = 0; // Derby
playerinbloodring[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new string[256];
if(playerinderby[playerid] == 1)
{
new DerbyPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
format(string, sizeof(string), "%s foi derrubado fora do derby, classificação: %d", DerbyPlayerName, derbyrank);
SendClientMessageToAll(0x33AA33AA, string);
playerinderby[playerid] = 0;
playerinminigame[playerid] = 0;
bloodringfull[playerinbloodring[playerid]] = 0;
playerinbloodring[playerid] = -1;
if(derbyrank <= 2)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && playerinderby[i] == 1)
{
new winnername[256];
GetPlayerName(i,winnername, sizeof(winnername));
RewardCalc(i,100,1000);
format(string, sizeof(string), "%s ganhou o derby e ganhou $%d", winnername, reward);
SendClientMessageToAll(0x33AA33AA, string);
GivePlayerMoney(i,reward);
playerinderby[i] = 0;
playerinminigame[i] = 0;
SetPlayerVirtualWorld(i,0);
SetPlayerInterior(playerid, 0);
SetPlayerPos(i, spawnX, spawnY, spawnZ);
}
}
derbyplaying = 0;
derbyrank = 0;
derbyon = 0;
KillTimer(dtimer);
Respawnbloodrings();
return 1;
}
derbyrank--;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new string[256];
if(playerinderby[playerid] == 1)
{
new DerbyPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
format(string, sizeof(string), "%s foi derrubado fora do derby, classificação: %d", DerbyPlayerName, derbyrank);
SendClientMessageToAll(0x33AA33AA, string);
playerinderby[playerid] = 0;
playerinminigame[playerid] = 0;
bloodringfull[playerinbloodring[playerid]] = 0;
playerinbloodring[playerid] = -1;
if(derbyrank <= 2)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && playerinderby[i] == 1)
{
new winnername[256];
GetPlayerName(i,winnername, sizeof(winnername));
RewardCalc(i,100,1000);
format(string, sizeof(string), "%s ganhou o derby e ganhou $%d", winnername, reward);
SendClientMessageToAll(0x33AA33AA, string);
GivePlayerMoney(i,reward);
playerinderby[i] = 0;
playerinminigame[i] = 0;
SetPlayerVirtualWorld(i,0);
SetPlayerInterior(playerid, 0);
SetPlayerPos(i, spawnX, spawnY, spawnZ);
}
}
derbyplaying = 0;
derbyrank = 0;
derbyon = 0;
KillTimer(dtimer);
Respawnbloodrings();
return 1;
}
derbyrank--;
}
return 1;
}
//comandos do minigame derby
CMD:derby(playerid)
{
if(derbyplaying == 1)return SendClientMessage(playerid, 0xB4B5B7AA, "O derby já começou");
if(playerinminigame[playerid] == 1)return SendClientMessage(playerid, 0xB4B5B7AA, "Voce já esta em um minigame");
new pname[256];
GetPlayerName(playerid, pname, 256);
if(derbyon == 0)
{
derbyon = 1;
playerinminigame[playerid] = 1;
playerinderby[playerid] = 1;
derbyrank = 1;
SetPlayerInterior(playerid, 15);
SetPlayerVirtualWorld(playerid, 7);
SetVehicleVirtualWorld(bloodring[0], 7);
bloodringfull[0] = 1;
PutPlayerInVehicle(playerid, bloodring[0], 0);
playerinbloodring[playerid] = 0;
TogglePlayerControllable(playerid, 0);
startvar[0] = 1;
new string[256];
dtimer = SetTimer("StartDerby", 60000, 0);
format(string, sizeof(string), "%s iniciou um derby, você tem um minuto para escrever /derby e juntar-se", pname);
SendClientMessageToAll(0x33AA33AA, string);
return 1;
}
else if(derbyon == 1 && derbyrank < 15)
{
playerinminigame[playerid] = 1;
playerinderby[playerid] = 1;
derbyrank++;
SetPlayerInterior(playerid, 15);
for(new i = 0; i < 15; i++)
{
if(bloodringfull[i] == 0)
{
SetPlayerVirtualWorld(playerid, 7);
SetVehicleVirtualWorld(bloodring[i], 7);
bloodringfull[i] = 1;
PutPlayerInVehicle(playerid, bloodring[i], 0);
TogglePlayerControllable(playerid, 0);
playerinbloodring[playerid] = i;
new string[256];
format(string, sizeof(string), "%s juntou-se ao derby", pname);
SendClientMessageToAll(0x33AA33AA, string);
return 1;
}
}
}
else if(derbyon == 1 && derbyrank >= 15)
{
new string[256];
format(string, sizeof(string), "Evento Derby Cheio, Tente na próxima rodada", pname);
SendClientMessage(playerid, 0x33AA33AA, string);
return 1;
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
playercarid[playerid] = GetPlayerVehicleID(playerid);
}
if(oldstate == 2)
{
if(playerinderby[playerid])
{
PutPlayerInVehicle(playerid,playercarid[playerid],0);
}
}
return 1;
}
public Spawnbloodrings()
{
for(new i=0; i<15; i++)
{
bloodring[i] = CreateVehicle(504,derbycars[i][0],derbycars[i][1],derbycars[i][2],derbycars[i][3],-1,-1,-1);
LinkVehicleToInterior(bloodring[i],15);
SetVehicleVirtualWorld(bloodring[i],1);
bloodringfull[i] = 0;
}
return 1;
}
public Destroybloodrings()
{
for(new i=0; i<15; i++)
{
DestroyVehicle(bloodring[i]);
bloodringfull[i] = 0;
}
}
public Respawnbloodrings()
{
for(new i=0; i<15; i++)
{
SetVehicleToRespawn(bloodring[i]);
SetVehicleVirtualWorld(bloodring[i],1);
bloodringfull[i] = 0;
}
}
public StartDerby()
{
new delay = 1000;
new string[32];
if(startvar[0] == 1)
{
if( derbyrank <= 1 )
{
SendClientMessageToAll(0x33AA33AA, "Derby cancelado. Motivo: jogadores Insuficientes (Minimo = 2)");
derbyplaying = 0;
derbyrank = 0;
derbyon = 0;
startvar[0] = 0;
Respawnbloodrings();
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinderby[i] == 1)
{
playerinderby[i] = 0;
playerinminigame[i] = 0;
playerinbloodring[i] = -1;
SetPlayerVirtualWorld(i,0);
SetPlayerInterior(i, 0);
SetPlayerPos(i, spawnX, spawnY, spawnZ);
TogglePlayerControllable(i, 1);
}
}
}
return 1;
}
format(string, sizeof(string), "~r~3");
derbyplaying = 1;
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinderby[i] == 1)
{
GameTextForPlayer(i, string, delay, 6);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
startvar[0] = 2;
SetTimer("StartDerby", delay, 0);
} else if(startvar[0] == 2) {
format(string, sizeof(string), "~r~2");
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinderby[i] == 1)
{
GameTextForPlayer(i, string, delay, 6);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
startvar[0] = 3;
SetTimer("StartDerby", delay, 0);
} else if(startvar[0] == 3) {
format(string, sizeof(string), "~g~1");
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinderby[i] == 1)
{
GameTextForPlayer(i, string, delay, 6);
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
TogglePlayerControllable(i, 1);
}
}
}
startvar[0] = 0;
}
return 1;
}
public RewardCalc(playerid,min,max)//Originally from PenLS
{
reward = (min + (random(max-min)));
}