14.10.2013, 16:05
Alright so I'm working for a server anyways the dynamic businesses are bugged! I've tried everything I could think of, alright so if someone buys the business it'll be all good working fine but if they relog and try to edit their business it has " You do not own a business "
pawn Код:
//==========[-----Business Information-]=========//
#define MAX_BIZ 111
#define DIALOG_BIZMENU 112
#define DIALOG_BIZWITHDRAW 113
#define DIALOG_BIZDEPOSIT 114
pawn Код:
enum bizInfo
{
bType,
bStatus,
bOwner[32],
Float:bX,
Float:bY,
Float:bZ,
Float:bA,
Float: bInteriorX,
Float: bInteriorY,
Float: bInteriorZ,
Float: bInteriorA,
bPickup,
bMoney,
bProducts,
Text3D:bText,
bSold,
bLevel,
bPrice,
bAP
}
new BizInfo[MAX_BIZ][bizInfo];
stock LoadBiz()
{
if(!fexist("biz.cfg")) fcreate("biz.cfg");
new binfo[12][32];
new string[256];
new File:file = fopen("biz.cfg", io_read);
if(file)
{
new idx = 1;
while(idx < MAX_BIZ)
{
fread(file, string);
splits(string, binfo, '|');
BizInfo[idx][bType] = strval(binfo[0]);
BizInfo[idx][bStatus] = strval(binfo[1]);
format(BizInfo[idx][bOwner], 32, "%s", binfo[2]);
BizInfo[idx][bX] = floatstr(binfo[3]);
BizInfo[idx][bY] = floatstr(binfo[4]);
BizInfo[idx][bZ] = floatstr(binfo[5]);
BizInfo[idx][bMoney] = strval(binfo[6]);
BizInfo[idx][bProducts] = strval(binfo[7]);
BizInfo[idx][bSold] = strval(binfo[8]);
BizInfo[idx][bLevel] = strval(binfo[9]);
BizInfo[idx][bPrice] = strval(binfo[10]);
BizInfo[idx][bAP] = strval(binfo[11]);
if(BizInfo[idx][bType] == 1)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1274, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 2)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1275, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 3)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1242, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 4)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1582, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 5)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1650, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 6)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(19094, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(BizInfo[idx][bType] == 7)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(321, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
}
if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nFor Sale: $%d\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice], idx);
else format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.8, 4);
idx++;
}
}
print("Business system has been loaded successfully.");
return 1;
}
stock SaveBiz()
{
if(!fexist("biz.cfg")) fcreate("biz.cfg");
new idx = 1, File:file;
new string[256];
while(idx < MAX_BIZ)
{
format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\r\n", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
if(idx == 1)
{
file = fopen("biz.cfg", io_write);
}
else
{
file = fopen("biz.cfg", io_append);
}
fwrite(file, string);
fclose(file);
idx++;
}
print("Businesses saved at script file GM Brahem biz.cfg successfully.");
}
stock RBT(bizid)
{
new string[24];
if(!BizInfo[bizid][bType]) format(string, sizeof(string), "None");
else if(BizInfo[bizid][bType] == 1) format(string, sizeof(string), "24/7 Market");
else if(BizInfo[bizid][bType] == 2) format(string, sizeof(string), "Clothes Shop");
else if(BizInfo[bizid][bType] == 3) format(string, sizeof(string), "Ammunation");
else if(BizInfo[bizid][bType] == 4) format(string, sizeof(string), "Well Stacked Pizza");
else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Gas Station");
else if(BizInfo[bizid][bType] == 6) format(string, sizeof(string), "Burger Shot");
else if(BizInfo[bizid][bType] == 7) format(string, sizeof(string), "Sex Shop");
return string;
}
stock RBS(bizid)
{
new string[16];
if(!BizInfo[bizid][bStatus]) format(string, sizeof(string), "{FF0000}Closed");
else if(BizInfo[bizid][bStatus]) format(string, sizeof(string), "{00FF00}Open");
return string;
}
stock RPBP(playerid)
{
new string[32];
if(!PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "None");
else if(PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "%d", BizInfo[PlayerInfo[playerid][pBiz]][bProducts]);
return string;
}
stock RPVIPBP(playerid)
{
new string[32];
if(!PlayerInfo[playerid][pVBiz]) format(string, sizeof(string), "None");
else if(PlayerInfo[playerid][pVBiz]) format(string, sizeof(string), "%d", BizInfo[PlayerInfo[playerid][pVBiz]][bProducts]);
return string;
}
pawn Код:
stock SaveChar(playerid)
{
if(IsPlayerConnected(playerid))
{
dini_IntSet(file, "Business", PlayerInfo[playerid][pBiz]);
dini_IntSet(file, "VBusiness", PlayerInfo[playerid][pVBiz]);
dini_IntSet(file, "BizOwner", PlayerInfo[playerid][pOwner]);
}
}
stock LoadChar(playerid)
{
PlayerInfo[playerid][pBiz] = dini_Int(file, "Business");
PlayerInfo[playerid][pVBiz] = dini_Int(file, "VBusiness");
PlayerInfo[playerid][pOwner] = dini_Int(file, "BizOwner");
}
ABroadCast(COLOR_YELLOW, "{AA3333}Maintenance{FFFF00}: Force Saving Business...", 1);
SaveBiz();
pawn Код:
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
if(!BizInfo[idx][bStatus] && PlayerInfo[playerid][pBiz] != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "This business is closed.");
if(BizInfo[idx][bType] == 1) // 24/7 Business
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, -25.884498,-185.868988,1003.546875);
SetPlayerFacingAngle(playerid, 357.5915);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 17);
SetPlayerVirtualWorld(playerid, idx+6000);
format(string, sizeof(string), "** Welcome to %s's 24/7 Market (( /buy )) **", BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
return 1;
}
else if(BizInfo[idx][bType] == 2) // Clothes Shop Business
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the clothes shop.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, 226.293991,-7.431529,1002.210937);
SetPlayerFacingAngle(playerid, 356.3849);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, idx+6000);
format(string, sizeof(string), "** Welcome to %s's Clothes Shop (( /buyclothes & /buytoys )) **", BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
return 1;
}
else if(BizInfo[idx][bType] == 3) // Ammunation Business
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the ammunation.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, 314.820983,-141.431991,999.601562);
SetPlayerFacingAngle(playerid, 358.9898);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 7);
SetPlayerVirtualWorld(playerid, idx+6000);
return 1;
}
else if(BizInfo[idx][bType] == 4) // Well stacked pizza
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the well stacked pizza.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, 372.3329,-131.9212,1001.499511);
SetPlayerFacingAngle(playerid, 0.1316);
format(string, sizeof(string), "** Welcome to %s's Well stacked pizza (( /buyfood )) **", BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, idx+6000);
return 1;
}
else if(BizInfo[idx][bType] == 5) // Gas Station
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the gas station.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, -30.946699,-89.609596,1003.546875);
SetPlayerFacingAngle(playerid, 0.4216);
format(string, sizeof(string), "** Welcome to %s's Gas Station (( /buy )) **", BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 18);
SetPlayerVirtualWorld(playerid, idx+6000);
return 1;
}
else if(BizInfo[idx][bType] == 6) // Burger Shot
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the burger shot.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, 363.5979,-74.4754,1001.507812);
SetPlayerFacingAngle(playerid, 309.6378);
format(string, sizeof(string), "** Welcome to %s's Burger Shot (( /buyfood )) **", BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 10);
SetPlayerVirtualWorld(playerid, idx+6000);
return 1;
}
else if(BizInfo[idx][bType] == 7) // Sex Shop
{
new string[128];
format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPlayerPos(playerid, -103.559165,-24.225606,1000.718750);
SetPlayerFacingAngle(playerid, 0.4216);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, idx+6000);
return 1;
}
}
}
pawn Код:
CMD:bizhelp(playerid, params[])
{
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS: {FFFFFF}/buybiz");
if(PlayerInfo[playerid][pBiz]) SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS OWNER: {FFFFFF}/bizmenu /lockbiz /sellbiztomarket");
return 1;
}
CMD:bizmenu(playerid, params[])
{
for(new d = 0 ; d < MAX_BIZ; d++)
{
new idx = PlayerInfo[playerid][pVBiz];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
SetPVarInt(playerid, "bizmenu", d);
if(!IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
SendClientMessageEx(playerid, COLOR_GRAD2, " You are not near your business!");
return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
ShowPlayerDialog(playerid,DIALOG_BIZMENU,DIALOG_STYLE_LIST,"BUSINESS ACCOUNT", "Balance\nWithdraw","Select","Cancel");
return 1;
}
}
return 1;
}
CMD:lockbiz(playerid, params[])
{
new string[128], idx, done;//, lockdone
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pBiz])
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
{
if(!BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
{
BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 1;
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(PlayerInfo[playerid][pBiz]), RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], PlayerInfo[playerid][pBiz]);
UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
format(string, sizeof(string), "* %s takes out their business keys and unlocks it.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(playerid, "~g~Business Unlocked", 3500, 3);
}
else if(BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
{
BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(PlayerInfo[playerid][pBiz]), RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], PlayerInfo[playerid][pBiz]);
UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
format(string, sizeof(string), "* %s takes out their business keys and locks it.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(playerid, "~r~Business Locked", 3500, 3);
}
done = 1;
//lockdone = 1;
}
}
if(PlayerInfo[playerid][pVBiz] && !done)
{
idx = PlayerInfo[playerid][pVBiz];
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
if(!BizInfo[idx][bStatus])
{
BizInfo[idx][bStatus] = 1;
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
format(string, sizeof(string), "* %s takes out their business keys and unlocks it.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(playerid, "~g~Business Unlocked", 3500, 3);
SaveBiz();
}
else if(BizInfo[idx][bStatus])
{
BizInfo[idx][bStatus] = 0;
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
format(string, sizeof(string), "* %s takes out their business keys and locks it.", RPN(playerid));
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(playerid, "~r~Business Locked", 3500, 3);
SaveBiz();
}
done = 1;
//lockdone = 1;
}
}
return 1;
}
CMD:buybiz(playerid, params[])
{
new string[128], done;
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVBiz] && PlayerInfo[playerid][pDonateRank] >= 4) return SendClientMessage(playerid, COLOR_GREY, "You already own two businesses.");
if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
if(!strcmp("The State", BizInfo[idx][bOwner], false))
{
if(GetPVarInt(playerid, "Cash") < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") -BizInfo[idx][bPrice]);
if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
else PlayerInfo[playerid][pBiz] = idx;
format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
Log("logs/business.log", string);
idx = MAX_BIZ;
done = 1;
SaveBiz();
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
}
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
}
}
return 1;
}
CMD:sellbiztomarket(playerid, params[])
{
new string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellbiztomarket [confirm]");
if(!strcmp(params, "confirm", true))
{
new done;
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
{
GivePlayerMoney(playerid, (75*BizInfo[PlayerInfo[playerid][pBiz]][bPrice])/100);
BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
format(BizInfo[PlayerInfo[playerid][pBiz]][bOwner], 32, "The State");
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(PlayerInfo[playerid][pBiz]), RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], PlayerInfo[playerid][pBiz]);
UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), PlayerInfo[playerid][pBiz]);
Log("logs/business.log", string);
PlayerInfo[playerid][pBiz] = 0;
done = 1;
}
if(!done)
{
new idx = PlayerInfo[playerid][pVBiz];
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
GivePlayerMoney(playerid, (75*BizInfo[idx][bPrice])/100);
BizInfo[idx][bStatus] = 0;
format(BizInfo[idx][bOwner], 32, "The State");
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), idx);
Log("logs/business.log", string);
PlayerInfo[playerid][pVBiz] = 0;
done = 1;
SaveBiz();
}
}
if(!done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near your business.");
return 1;
}
}
return 1;
}
CMD:bizstats(playerid, params[])
{
new string[128], playerb = playerid, status[16], status2[16];
// Business Status for non-owners
if(PlayerInfo[playerb][pBiz]) format(status, sizeof(status), "%s", RBS(PlayerInfo[playerb][pBiz]));
else if(!PlayerInfo[playerb][pBiz]) format(status, sizeof(status), "None");
if(PlayerInfo[playerb][pVBiz]) format(status2, sizeof(status2), "%s", RBS(PlayerInfo[playerb][pVBiz]));
else if(!PlayerInfo[playerb][pVBiz]) format(status2, sizeof(status2), "None");
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "_____________________________________________________");
format(string, sizeof(string), "Businesses of %s", RPN(playerb));
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "Business 1: %s | ID: %s | Level: %s | Status: %s | Money: %s", RBT(PlayerInfo[playerb][pBiz]), RPBK(playerb), RPBL(playerb),status, RPBP(playerb), RPBM(playerb));
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "Business 2: %s | ID: %s | Level: %s | Status: %s | Money: %s", RBT(PlayerInfo[playerb][pVBiz]), RPVIPBK(playerb), RPVIPBL(playerb),status2, RPVIPBP(playerb), RPVIPBM(playerb));
SendClientMessage(playerid, COLOR_FADE2, string);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "_____________________________________________________");
return 1;
}
CMD:bused(playerid, params[])
{
new string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
SendClientMessage(playerid, COLOR_ORANGE, "[Used Businesses]:");
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(BizInfo[idx][bType])
{
format(string, sizeof(string), "ID: %d | Type: %s | Level: %d | Price: $%d | Products: %d | Vault: $%d | Owner: %s", idx, RBT(idx), BizInfo[idx][bLevel], BizInfo[idx][bPrice],BizInfo[idx][bProducts], BizInfo[idx][bMoney], BizInfo[idx][bOwner]);
SendClientMessage(playerid, COLOR_ORANGE, string);
}
}
return 1;
}
CMD:bedit(playerid, params[])
{
new bizid, string[128], input;
new Float:X, Float:Y, Float:Z;
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
if(sscanf(params, "s[32]", params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit [option] [bizid]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: location | price | level | products | vault");
return 1;
}
if(!strcmp(params, "location", true, 8))
{
if(sscanf(params, "s[32]i", params, bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit location [bizid]");
new idx=bizid;
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
GetPlayerPos(playerid, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]);
DestroyDynamicPickup(BizInfo[bizid][bPickup]);
//BizInfo[bizid][bPickup] = CreateDynamicPickup(1274, 1, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ], 0);
if(BizInfo[bizid][bType] == 1)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(1274, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 2)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(1275, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 3)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(1242, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 4)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(1582, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 5)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(1650, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 6)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(19094, 1, X, Y, Z, 0);
SaveBiz();
}
if(BizInfo[bizid][bType] == 7)
{
BizInfo[bizid][bPickup] = CreateDynamicPickup(321, 1, X, Y, Z, 0);
SaveBiz();
}
DestroyDynamic3DTextLabel(BizInfo[bizid][bText]);
if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nFor Sale: $%d\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice], idx);
else format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
BizInfo[bizid][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]+0.8, 4);
format(string, sizeof(string), "AdmWarn: %s has changed business ID %d's location.", RPN(playerid), bizid);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else if(!strcmp(params, "price", true, 5))
{
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit price [bizid] [price]");
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
if(strcmp("The State", BizInfo[bizid][bOwner])) return SendClientMessage(playerid, COLOR_GREY, "You can't edit the price of owned businesses.");
BizInfo[bizid][bPrice] = input;
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nFor Sale: $%d\nID: %d", RBS(bizid), RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice], bizid);
UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
format(string, sizeof(string), "AdmWarn: %s has set business ID %d's price to $%d.", RPN(playerid), bizid, input);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else if(!strcmp(params, "level", true, 5))
{
// L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit level [bizid] [level]");
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
if(input < 0 || input > 5) return SendClientMessage(playerid, COLOR_GREY, "Levels are between 1 and 5.");
BizInfo[bizid][bLevel] = input;
if(input == 1) BizInfo[bizid][bSold] = 0;
if(input == 2) BizInfo[bizid][bSold] = 100;
if(input == 3) BizInfo[bizid][bSold] = 300;
if(input == 4) BizInfo[bizid][bSold] = 700;
if(input == 5) BizInfo[bizid][bSold] = 1200;
format(string, sizeof(string), "AdmWarn: %s has set business ID %d's level to %d.", RPN(playerid), bizid, input);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else if(!strcmp(params, "products", true, 8))
{
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit products [bizid] [amount]");
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Products can't be negative.");
BizInfo[bizid][bProducts] = input;
format(string, sizeof(string), "AdmWarn: %s has set business ID %d's products to %d.", RPN(playerid), bizid, input);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else if(!strcmp(params, "vault", true, 5))
{
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit vault [bizid] [amount]");
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Vault money can't be negative.");
BizInfo[bizid][bMoney] = input;
format(string, sizeof(string), "AdmWarn: %s has set business ID %d's vault money to $%d.", RPN(playerid), bizid, input);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else if(!strcmp(params, "truckers", true, 8))
{
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit truckers [bizid] [type] (1=Accepting | 2=NotAccepting");
if(!BizInfo[bizid][bAP])
{
BizInfo[bizid][bAP] = 1;
format(string, sizeof(string), "AdmWarn: %s has set business ID %d to accept truckers.", RPN(playerid), bizid);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
else
{
BizInfo[bizid][bAP] = 0;
format(string, sizeof(string), "AdmWarn: %s has set business ID %d to NOT accept truckers.", RPN(playerid), bizid);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
SaveBiz();
}
}
return 1;
}
CMD:gotobiz(playerid, params[])
{
new idx, string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
if(sscanf(params, "i", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotobiz [bizid]");
if(!BizInfo[idx][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
format(string, sizeof(string), " You have teleported to business ID %d.", idx);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
CMD:asellbiz(playerid, params[])
{
new bizid, string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
if(sscanf(params, "i", bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /asellbiz [bizid]");
if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
if(!strcmp("The State", BizInfo[bizid][bOwner], true)) return SendClientMessage(playerid, COLOR_GREY, "This business is not owned by anybody.");
foreach(Player, i)
{
if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == bizid)
{
PlayerInfo[i][pBiz] = 0;
format(string, sizeof(string), " Administrator %s has sold your business.", RPN(playerid));
SendClientMessage(i, COLOR_WHITE, string);
}
}
format(string, sizeof(string), "AdmWarn: %s has sold %s's business. (ID %d)", RPN(playerid), BizInfo[bizid][bOwner], bizid);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
BizInfo[bizid][bStatus] = 0;
format(BizInfo[bizid][bOwner], 32, "The State");
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nFor Sale: $%d\nID: %d", RBS(bizid), RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice], bizid);
UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
SaveBiz();
return 1;
}
CMD:createbiz(playerid, params[])
{
new type, string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
if(sscanf(params, "i", type))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createbiz [type]");
SendClientMessage(playerid, COLOR_GREY, "TYPES: 1) 24/7 | 2) Clothes Shop | 3) Ammunation | 4) Well Stacked Pizza | 5) Gas Station | 6)Burger Shot | 7)Sex Shop");
return 1;
}
if(type < 1 || type > 7) return SendClientMessage(playerid, COLOR_GREY, "Businesses are between 1 and 7.");
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(!BizInfo[idx][bType])
{
// Getting Business Setup
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
// Making Business
BizInfo[idx][bType] = type;
BizInfo[idx][bStatus] = 1;
format(BizInfo[idx][bOwner], 32, "The State");
BizInfo[idx][bX] = X;
BizInfo[idx][bY] = Y;
BizInfo[idx][bZ] = Z;
BizInfo[idx][bMoney] = 0;
BizInfo[idx][bProducts] = 0;
BizInfo[idx][bSold] = 0;
BizInfo[idx][bLevel] = 1;
BizInfo[idx][bPrice] = 1337;
if(BizInfo[idx][bType] == 1)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1274, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 2)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1275, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 3)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1242, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 4)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1582, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 5)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1650, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 6)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(19094, 1, X, Y, Z, 0);
}
if(BizInfo[idx][bType] == 7)
{
BizInfo[idx][bPickup] = CreateDynamicPickup(321, 1, X, Y, Z, 0);
}
format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nFor Sale: $%d\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice], idx);
BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z+0.8, 4);
format(string, sizeof(string), "AdmWarn: %s has created business ID %d.", RPN(playerid), idx);
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
idx = MAX_BIZ;
SaveBiz();
}
}
return 1;
}
CMD:deletebiz(playerid, params[])
{
new id, string[128];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COLOR_WHITE, "You must be Admin to use this Command!");
if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deletebiz [bizid]");
if(!BizInfo[id][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
foreach(Player, i)
{
if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == id)
{
PlayerInfo[playerid][pBiz] = 0;
format(string, sizeof(string), " Administrator %s has deleted your business.", RPN(playerid));
SendClientMessage(i, COLOR_WHITE, string);
}
}
if(!strcmp("The State", BizInfo[id][bOwner]))
{
format(string, sizeof(string), "AdmWarn: %s has deleted business ID %d.", RPN(playerid), id);
}
else
{
format(string, sizeof(string), "AdmWarn: %s has deleted %s's business. (ID %d)", RPN(playerid), BizInfo[id][bOwner], id);
}
ABroadCast(COLOR_LIGHTRED, string,4);
Log("logs/business.log", string);
BizInfo[id][bType] = 0;
BizInfo[id][bStatus] = 0;
format(BizInfo[id][bOwner], 32, "");
BizInfo[id][bX] = 0;
BizInfo[id][bY] = 0;
BizInfo[id][bZ] = 0;
BizInfo[id][bMoney] = 0;
BizInfo[id][bProducts] = 0;
DestroyDynamicPickup(BizInfo[id][bPickup]);
DestroyDynamic3DTextLabel(BizInfo[id][bText]);
SaveBiz();
return 1;
}