rendered paste body//required includes
#include <a_samp> //includes, todos precisam de vc
#include <dutils>
#include <dudb>
//defines
#define GetPlayerRank
#define CP_BANK 0
#define CP_PIRATE 1
#define CP_AMMU 2
#define CP_DRAGON 3
#define CP_SEXSHOP 4
#define CP_BAR 5
#define CP_CALIGULA 6
#define CP_ZIP 7
#define CP_BINCO 8
#define CP_TATOO 9
#define CP_BOTIQUE 10
#define P_DRAGON 0
#define P_SEXSHOP 1
#define P_BAR 2
#define P_CALIGULA 3
#define P_ZIP 4
#define P_BINCO 5
#define P_TATOO 6
#define P_BOTIQUE 7
#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define P_OFFSET 3
//forwards
forward getCheckpointType(playerID);
forward checkpointUpdate();
forward PropertyScoreUpdate();
forward isPlayerInArea(playerID, Float:data[4]);
//agora vem os news
#define MAX_POINTS 11
new string[256];
new playerCheckpoint[MAX_PLAYERS];
new Float:checkCoords[MAX_POINTS][4] = {
{-36.5483,-57.9948, -17.2655,-49.2967}, //BANK
{1894.6128,1445.3431, 2084.9739,1637.8186}, //PIRATE
{284.0546,-86.4384, 302.9315,-56.6674}, //AMMUNATION
{1925.1511,968.2358, 2019.0715,1067.4276}, //DRAGON
{-115.9544,-24.2706, -99.1631,-7.1391}, //SEXSHOP
{487.6558,-88.5900, 512.0635, -67.7503}, //BAR
{2216.7971,1638.0493, 2255.2097,1714.0806}, //CALIGULA
{144.9131,-96.0927, 177.4128,-70.7923}, //ZIP
{201.4462,-112.4556, 218.5237,-95.1238}, //BINCO
{-204.7623,-44.0326, -200.2330,-39.8128}, //TATOO
{416.7485,-84.4242, 422.6890,-74.0611} //BOTIQUE
};
new Float:checkpoints[MAX_POINTS][3] = {
{-22.2549,-55.6575,1003.5469},
{2000.3132,1538.6012,13.5859},
{291.0004,-84.5168,1001.5156},
{1989.0619,1005.5241,994.4688},
{-103.5525,-22.4661,1000.7188},
{501.4927,-75.4323,998.7578},
{2235.5408,1679.0402,1008.3594},
{161.1875,-79.9915,1001.8047},
{207.5640,-97.8188,1005.2578},
{-203.4864,-41.2045,1002.2734},
{418.5547,-80.1667,1001.8047}
};
new checkpointType[MAX_POINTS] = {
CP_BANK,
CP_PIRATE,
CP_AMMU,
CP_DRAGON,
CP_SEXSHOP,
CP_BAR,
CP_CALIGULA,
CP_ZIP,
CP_BINCO,
CP_TATOO,
CP_BOTIQUE
};
#define B_LIMIT 10
#define MAX_PROPERTIES 8
new playername[MAX_PLAYER_NAME];
new propertyNames[MAX_PROPERTIES][32] = {
"Four Dragons",
"Sex Shop",
"Shithole Bar",
"Caligula",
"Zip Shop",
"Binco Shop",
"Tatoo Parlor",
"Botique"
};
new propertyValues[MAX_PROPERTIES] = {
75000,
25000,
20000,
100000,
15000,
15000,
10000,
20000
};
new propertyEarnings[MAX_PROPERTIES] = {
5000,
2000,
1500,
7000,
1000,
1000,
700,
1500
};
new propertyOwner[MAX_PROPERTIES] = {999,999,999,999,999,999,999,999};
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new cmd[256];
new giveplayerid, moneys, idx, weaponid;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/buy", true) == 0) {
new property=999;
if(IsPlayerInCheckpoint(playerid)) {
switch (playerCheckpoint[playerid]) {
case CP_DRAGON:{
property = P_DRAGON;
}
case CP_SEXSHOP:{
property = P_SEXSHOP;
}
case CP_BAR:{
property = P_BAR;
}
case CP_CALIGULA:{
property = P_CALIGULA;
}
case CP_ZIP:{
property = P_ZIP;
}
case CP_BINCO:{
property = P_BINCO;
}
case CP_TATOO:{
property = P_TATOO;
}
case CP_BOTIQUE:{
property = P_BOTIQUE;
}
}
if(property==999) {
SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
return 1;
}
// property--;
if(GetPlayerMoney(playerid) < propertyValues[property]) {
SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this property.");
return 1;
}
if(propertyOwner[property]==playerid) {
SendClientMessage(playerid, COLOR_RED, "You already own this property.");
return 1;
}
if(propertyOwner[property] < 999) {
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
GivePlayerMoney(propertyOwner[property], propertyValues[property]);
format (string, sizeof(string), "Your property, the %s, has been bought out by %s (id: %d).",propertyNames[property],giveplayer,playerid);
SendClientMessage(propertyOwner[property], COLOR_RED, string);
}
GivePlayerMoney(playerid, 0-propertyValues[property]);
propertyOwner[property]=playerid;
format(string, sizeof(string), "You have purchased the %s!", propertyNames[property]);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
SetPlayerMapIcon(playerid, 0, X, Y, Z, 52, 0);
SendClientMessage(playerid, COLOR_GREEN, string);
new msg[256];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s comprou a propriedade %s", pname, propertyNames[property]);
SendClientMessageToAll(COLOR_YELLOW, string);
} else {
SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
return 1;
}
}
return 1;
}
//------------------- /properties
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;
}
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 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;
}
}
}
}
for(new i=0; i < MAX_PROPERTIES; i++) {
if(owners[i] < 999 && IsPlayerConnected(owners[i])) {
new string[256];
GivePlayerMoney(owners[i], payments[i]);
format(string, sizeof(string), "You earned $%d from your properties.", payments[i]);
SendClientMessage(owners[i], COLOR_GREEN, string);
}
}
}
public OnPlayerEnterCheckpoint(playerid)
{
new string[256];
new ownplayer[MAX_PLAYER_NAME];
switch(getCheckpointType(playerid))
{
case CP_DRAGON: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Four Dragons Casino for $75,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $5,000 regularly.");
return 1;
}
case CP_SEXSHOP: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Sex Shop for $25,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $2,000 regularly.");
return 1;
}
case CP_BAR: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Shithole Bar for $20,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $1,500 regularly.");
return 1;
}
case CP_CALIGULA: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Caligula Casino for $100,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $7,000 regularly.");
return 1;
}
case CP_ZIP: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Zip clothes store for $15,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $1,000 regularly.");
return 1;
}
case CP_BINCO: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Binco Shop for $15,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $700 regularly.");
return 1;
}
case CP_TATOO: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Tatoo Shop store for $15,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $1,000 regularly.");
return 1;
}
case CP_BOTIQUE: {
SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Zip clothes store for $15,000 with /buy.");
SendClientMessage(playerid, COLOR_YELLOW, "You will earn $1,000 regularly.");
return 1;
}
}
return 1;
}
public getCheckpointType(playerID) {
return checkpointType[playerCheckpoint[playerID]];
}
public OnGameModeInit()
{
SetTimer("checkpointUpdate", 1100, 1);
printf("Properties system");
}