//****************************************************
//POR FAVOR NÃO REMOVA OS CRÉDITOS
//Sistema de GangZonas Compraveis v1.0
//****************************************************
//CRÉDITOS
//Retirado do: Las Venturas Brasil 7.0d
//Créditos Gerais: [GangstA]Kasura EX: [Rockstar]Rell
//Desenvolvedores: BcO e BnO
//MSN: guerra-mortal@hotmail.com
//****************************************************
#include <a_samp>
#pragma tabsize 0
#define COLOR_RED 0xAA3333AA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_YELLOW 0xFFFF00AA
#define CP_GZ_AUTOBASE_LV 0
#define CP_GZ_CONSTRUCAO_LV 1
#define CP_GZ_RECINTO_LV 2
#define CP_GZ_FABRICA_LV 3
#define CP_GZ_AEROPLACE_LV 4
#define CP_GZ_DISNEY_LV 5
#define CP_GZ_EXERCITO_LV 6
#define CP_GZ_CALIGULAS_LV 7
#define CP_GZ_GOLF_LV 8
#define P_GZ_AUTOBASE_LV 0
#define P_GZ_CONSTRUCAO_LV 1
#define P_GZ_RECINTO_LV 2
#define P_GZ_FABRICA_LV 3
#define P_GZ_AEROPLACE_LV 4
#define P_GZ_DISNEY_LV 5
#define P_GZ_EXERCITO_LV 6
#define P_GZ_CALIGULAS_LV 7
#define P_GZ_GOLF_LV 8
#define P_OFFSET 14
#define MAX_GZS 9
#define MAX_GANGS 50
#define MAX_GANG_NAME 50
forward GzScoreUpdate();
forward PayPlayerInGz(playerID, GzID, Float:x1, Float:y1, Float:x2, Float:y2, cash);
forward getCheckpointType(playerID);
forward isPlayerInArea(playerID, Float:data[4]);
forward checkpointUpdate();
forward PropertyScoreUpdate();
new gangNames[MAX_GANGS][MAX_GANG_NAME];
new playerCheckpoint[MAX_PLAYERS];
new gangInfo[MAX_GANGS][3];
new gz = 555;
new GZ[MAX_GZS];
new GZ_EXISTE[MAX_GZS][2];
new gangZonaId[MAX_GZS];
new gangZonaIdAnter[MAX_GZS];
new playerGang[MAX_PLAYERS];
new PLAYERLIST_authed[MAX_PLAYERS];
#define MAX_POINTS 9
new Float:checkCoords[MAX_POINTS][4] = {
{1017.134948, 1222.946899, 1096.891235, 1361.736572}, //GZ_AUTOBASE_LV
{2372.279052, 1832.521362, 2496.685302, 1962.471801}, //GZ_CONSTRUCAO_LV
{2777.4753, 833.6251, 2894.6955, 1022.9479}, //GZ_RECINTO_LV
{918.294555, 2043.856567, 996.507202, 2182.339599}, //GZ_FABRICA_LV
{1638.5530,1284.3757, 1716.3368,1319.3700}, //GZ_AEROPLACE
{2079.743,978.1417, 2329.653,1171.545},
{81.74512,1763.359, 362.0141,2055.306}, //GZ_EXERCITO
{2099.267,1535.143, 2290.605,1728.547}, //GZ_CALIGULAS_LV
{1111.341,2718.771, 1509.635,2842.55} //GZ_GOLF_LV
};
new Float:checkpoints[MAX_POINTS][3] = {
{1040.142578,1305.848266,10.820312}, //GZ_AUTOBASE_LV
{2436.580322,1913.306274,6.163729}, //GZ_CONSTRUCAO_LV
{2814.641357,969.982727,10.750000}, //GZ_RECINTO_LV
{929.612487,2068.309570,10.820312}, //GZ_FABRICA_LV
{1647.4393,1301.9464,10.8203}, //GZ_AEROPLACE
{2273.6250,1044.2716,10.8203}, //GZ_DISNEY
{202.9969,1888.7633,17.6481}, //GZ_EXERCITO
{2288.2988,1567.0795,10.8203}, //GZ_CALIGULAS_LV
{1457.4954,2773.3105,10.8203} //GZ_GOLF_LV
};
new checkpointType[MAX_POINTS] = {
CP_GZ_AUTOBASE_LV,
CP_GZ_CONSTRUCAO_LV,
CP_GZ_RECINTO_LV,
CP_GZ_FABRICA_LV,
CP_GZ_AEROPLACE_LV,
CP_GZ_DISNEY_LV,
CP_GZ_EXERCITO_LV,
CP_GZ_CALIGULAS_LV,
CP_GZ_GOLF_LV
};
#define MAX_PROPERTIES 9
new propertyNames[MAX_PROPERTIES][32] = {
"Gang Zona Auto Base",
"Gang Zona Construção",
"Gang Zona Recinto",
"Gang Zona Fabrica",
"Gang Zona Aero Place",
"Gang Zona Disney",
"Gang Zona Exercito",
"Gang Zona Caligulas",
"Gang Zona Golf"
};
new propertyValues[MAX_PROPERTIES] = {
185000,
175000,
200000,
250000,
190000,
270000,
180000,
210000,
190000
};
new propertyEarnings[MAX_PROPERTIES] = {
0,
0,
0,
0,
0,
0,
0,
0,
0
};
public getCheckpointType(playerID) {
return checkpointType[playerCheckpoint[playerID]];
}
new propertyOwner[MAX_PROPERTIES] = {999,999,999,999,999,999,999,999,999};
public PayPlayerInGz(playerID, GzID, Float:x1, Float:y1, Float:x2, Float:y2, cash) //ID_GZ
{
if(IsPlayerConnected(playerID))
{
new Float:X, Float:Y, Float:Z, Float:Health, Float:Armour;
GetPlayerPos(playerID, X, Y, Z);
GetPlayerHealth(playerID,Health);
GetPlayerArmour(playerID,Armour);
if((X >= x1) && (X <= x2) && (Y >= y1) && (Y <= y2))
{
if(playerGang[playerID] > 0)
{
if(gangZonaId[GzID] == playerGang[playerID])
{
GivePlayerMoney(playerID, cash);
GivePlayerWeapon(playerID, 31, 2);
if(Health < 105)
{
SetPlayerHealth(playerID,Health + 2);
}
if(Armour< 105)
{
SetPlayerArmour(playerID,Armour + 2);
}
}
else
{
if(GZ_EXISTE[GzID][0] == 1)
{
if(Health > 2)
{
SetPlayerHealth(playerID,Health - 2.5);
}
}
else
{
return 1;
}
}
// }
}
else
{
if(GZ_EXISTE[GzID][0] == 1)
{
if(Health > 2)
{
SetPlayerHealth(playerID,Health - 2.5);
}
}
else
{
return 1;
}
}
}
return 1;
}
return 0;
}
public GzScoreUpdate()
{
for(new i = 0 ; i < MAX_PLAYERS ; i++)
{
// GZ AUTOBASE_LV
PayPlayerInGz(i, 0, 1017.134948, 1222.946899, 1096.891235, 1361.736572, 500);
// GZ CONSTRUCAO_LV
PayPlayerInGz(i, 1, 2372.279052, 1832.521362, 2496.685302, 1962.471801, 500);
// GZ RECINTO_LV
PayPlayerInGz(i, 2, 2777.4753, 833.6251, 2894.6955, 1022.9479, 500);
// GZ FABRICA_LV
PayPlayerInGz(i, 3, 918.294555, 2043.856567, 996.507202, 2182.339599, 500);
// GZ AEROPLACE_LV
PayPlayerInGz(i, 4, 1638.5530, 1284.3757, 1716.3368, 1319.3700, 500);
// GZ Disney_LV
PayPlayerInGz(i, 5, 2079.743, 978.1417, 2329.653, 1171.545, 500);
// GZ_EXERCITO_LV
PayPlayerInGz(i, 6, 81.74512, 1763.359, 362.0141, 2055.306, 500);
// GZ CALIGULAS_LV
PayPlayerInGz(i, 7, 2099.267, 1535.143, 2290.605, 1728.547, 500);
//GZ GOLF_LV
PayPlayerInGz(i, 8, 1111.341, 2718.771, 1509.635, 2842.55, 500);
}
return 1;
}
public OnPlayerConnect(playerid)
{
playerGang[playerid]=0;
playerCheckpoint[playerid]=999;
for(new g = 0 ; g < MAX_GZS ; g++)
{
if(GZ_EXISTE[g][0] == 1)
{
GangZoneShowForPlayer(playerid, GZ[g], GZ_EXISTE[g][1]);
}
}
PLAYERLIST_authed[playerid]=false;
return false;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmdtext, "/gang zona comprar", true) == 0)
{
new property = 999;
if(IsPlayerInCheckpoint(playerid))
{
switch (playerCheckpoint[playerid])
{
case CP_GZ_AUTOBASE_LV:
{
property = P_GZ_AUTOBASE_LV;
gz = 0;
}
case CP_GZ_CONSTRUCAO_LV:
{
property = P_GZ_CONSTRUCAO_LV;
gz = 1;
}
case CP_GZ_RECINTO_LV:
{
property = P_GZ_RECINTO_LV;
gz = 2;
}
case CP_GZ_FABRICA_LV:
{
property = P_GZ_FABRICA_LV;
gz = 3;
}
case CP_GZ_AEROPLACE_LV:
{
property = P_GZ_AEROPLACE_LV;
gz = 4;
}
case CP_GZ_DISNEY_LV:
{
property = P_GZ_DISNEY_LV;
gz = 5;
}
case CP_GZ_EXERCITO_LV:
{
property = P_GZ_EXERCITO_LV;
gz = 6;
}
case CP_GZ_CALIGULAS_LV:
{
property = P_GZ_CALIGULAS_LV;
gz = 7;
}
case CP_GZ_GOLF_LV:
{
property = P_GZ_GOLF_LV;
gz = 8;
}
}
if(gz == 999 || property == 999)
{
SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Vá para o checkpoint e digite /gang zona comprar");
return 1;
}
if(GetPlayerMoney(playerid) < propertyValues[property])
{
SendClientMessage(playerid, COLOR_RED, "<GZ INFO> Você não tem dinheiro para comprar essa Gang Zona!");
return 1;
}
if(playerGang[playerid] > 0)
{
if(gangZonaId[gz] == playerGang[playerid])
{
SendClientMessage(playerid, COLOR_RED, "[GZ]: Essa Gang Zona já é da tua Gang!");
return 1;
}
new playerCor = gangInfo[playerGang[playerid]][2];
// gangInfo[playerGang[playerid]][2] = playerColors[playerid];
if(GZ_EXISTE[gz][0] == 1)
{
GangZoneDestroy(GZ[gz]);
GZ[gz] = 555;
}
if(gangZonaId[gz] > 0)
{
gangZonaIdAnter[gz] = gangZonaId[gz];
}
switch(gz)
{
case 0:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(1017.134948, 1222.946899, 1096.891235, 1361.736572);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 1:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(2372.279052, 1832.521362, 2496.685302, 1962.471801);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 2:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(2777.4753, 833.6251, 2894.6955, 1022.9479);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 3:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(918.294555, 2043.856567, 996.507202, 2182.339599);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 4:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(1638.5530, 1284.3757, 1716.3368, 1319.3700);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 5:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(2079.743, 978.1417, 2329.653, 1171.545);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 6:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(81.74512, 1763.359, 362.0141, 2055.306);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 7:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(2099.267, 1535.143, 2290.605, 1728.547);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
case 8:
{
if((!GZ[gz]) || (GZ[gz] == 555))
{
GZ[gz] = GangZoneCreate(1111.341, 2718.771, 1509.635, 2842.55);
GangZoneShowForAll(GZ[gz], playerCor);
gangZonaId[gz] = playerGang[playerid];
GZ_EXISTE[gz][0] = 1;
GZ_EXISTE[gz][1] = playerCor;
}
}
default: return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "[GZ INFO] É preciso estar em uma gang para poder comprar!");
return 1;
}
if(GZ_EXISTE[gz][0] == 1)
{
GivePlayerMoney(playerid, 0-propertyValues[property]);
format(string, sizeof(string), "A gang %s comprou a %s da gang %s!", gangNames[gangZonaId[gz]], propertyNames[property], gangNames[gangZonaIdAnter[gz]]);
SendClientMessageToAll(COLOR_GREEN, string);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Necessario estar no checkpoint para poder /gang zona comprar");
return 1;
}
return 1;
}
return 0;
}
public OnPlayerEnterCheckpoint(playerid)
{
new string[256];
switch(getCheckpointType(playerid))
{
case CP_GZ_AUTOBASE_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Auto Base:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $185000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 0;
}
case CP_GZ_CONSTRUCAO_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Construção:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $175000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 1;
}
case CP_GZ_RECINTO_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Recinto:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $200000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 2;
}
case CP_GZ_FABRICA_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Fabrica:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $250000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 3;
}
case CP_GZ_AEROPLACE_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Aero Place:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $190000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 4;
}
case CP_GZ_DISNEY_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Disney:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $270000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 5;
}
case CP_GZ_EXERCITO_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Exercito:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $180000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 6;
}
case CP_GZ_CALIGULAS_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Caligulas:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $210000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 7;
}
case CP_GZ_GOLF_LV:
{
SendClientMessage(playerid, COLOR_ORANGE, "[GZ]: Gang Zona Golf:");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Valor: $190000, Para comprar digite /gang zona comprar");
SendClientMessage(playerid, COLOR_YELLOW, "[GZ]: Ganhe dinheiro + recuperação de vida ficando nela");
gz = 8;
}
}
if(getCheckpointType(playerid) >= P_OFFSET)
{
if(GZ_EXISTE[gz][0] == 1)
{
format(string, sizeof(string), "[GZ]: Essa Gang Zona é atualmente da Gang: %s.", gangNames[gangZonaId[gz]]);
SendClientMessage(playerid, COLOR_RED, string);
}
}
}
public OnFilterScriptInit()
{
SetTimer("GzScoreUpdate", 2001, true);
SetTimer("checkpointUpdate", 1100, 1);
return 1;
}
public checkpointUpdate()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) {
for(new j=0; j < MAX_POINTS; j++) {
if(isPlayerInArea(i, checkCoords[j])) {
if(playerCheckpoint[i]!=j) {
DisablePlayerCheckpoint(i);
SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],2);
playerCheckpoint[i] = j;
}
} else {
if(playerCheckpoint[i]==j) {
DisablePlayerCheckpoint(i);
playerCheckpoint[i] = 999;
}
}
}
}
}
}
public isPlayerInArea(playerID, Float:data[4])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerID, X, Y, Z);
if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
return 1;
}
return 0;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
public PropertyScoreUpdate()
{
new owners[MAX_PROPERTIES];
new payments[MAX_PROPERTIES];
for(new i=0; i < MAX_PROPERTIES; i++)
owners[i]=999;
for(new i=0; i < MAX_PROPERTIES; i++)
{
if(propertyOwner[i] < 999) {
for(new j=0; j < MAX_PROPERTIES; j++) {
if(owners[j]==propertyOwner[i]) {
payments[j]+=propertyEarnings[i];
j = MAX_PROPERTIES;
} else if (owners[j]==999) {
owners[j]=propertyOwner[i];
payments[j]+=propertyEarnings[i];
j = MAX_PROPERTIES;
}
}
}
}
}