if(strcmp(cmd, "/buy", true) == 0) {
new property=999;
tmp = dini_Get(FILE_SETTINGS, "properties");
if (strval(tmp) == 0) {
SendClientMessage(playerid, COLOR_RED, "* Properties are not allowed on this server!");
return 1;
}
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;
}
case CP_JIZZY:{
property = P_JIZZY;
}
case CP_PIZZA:{
property = P_PIZZA;
}
case CP_VICTIM:{
property = P_VICTIM;
}
case CP_STRIPCLUB:{
property = P_STRIPCLUB;
}
case CP_WANGCARS:{
property = P_WANGCARS;
}
case CP_EMERALD:{
property = P_EMERALD;
}
case CP_VISAGE:{
property = P_VISAGE;
}
case CP_SUBURBAN:{
property = P_SUBURBAN;
}
case CP_PROLAPS:{
property = P_PROLAPS;
}
case CP_BURGER:{
property = P_BURGER;
}
case CP_CLUCKIN:{
property = P_CLUCKIN;
}
case CP_CLUB:{
property = P_CLUB;
}
case CP_DS:{
property = P_DS;
}
case CP_ZOMBO:{
property = P_ZOMBO;
}
}
if (property == 999) {
SendClientMessage(playerid, COLOR_YELLOW, "* You need to be in a property checkpoint to /buy it.");
return 1;
}
if (GetPlayerMoney(playerid) < propertyValues[property]) {
SendClientMessage(playerid, COLOR_RED, "* You don't have enough money!");
return 1;
}
if (propertyOwner[property] == playerid) {
SendClientMessage(playerid, COLOR_RED, "* You already own this property.");
return 1;
}
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
if (propertyOwner[property] < 999) {
StatGivePlayerMoney(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);
}
StatGivePlayerMoney(playerid, -propertyValues[property]);
propertyOwner[property] = playerid;
format(string, sizeof(string), "--- %s (id: %d) bought %s for $%d.", giveplayer,playerid,propertyNames[property],propertyValues[property]);
printf(string);
format(string, sizeof(string), "* You have purchased the %s!", propertyNames[property]);
SendClientMessage(playerid, COLOR_GREEN, string);
}
else {
SendClientMessage(playerid, COLOR_YELLOW, "* You need to be in a property checkpoint to /buy it.");
return 1;
}
return 1;
}