command(createbusiness, playerid, params[])
{
new Usage[128], string[128];
if(sscanf(params, "z", Usage))
{
if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 6)
{
SendClientMessage(playerid, WHITE, "SYNTAX: /createbusiness [usage]");
SendClientMessage(playerid, GREY, "Usage: Interior, Exterior, Shop or Complete.");
}else ErrorPTD(playerid,1,"You cannot use this command!");
}
else
{
if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 6)
{
if(strcmp(Usage, "exterior", true) == 0)
{
Player[playerid][BizExterior]++;
Player[playerid][bExtID] = GetPlayerInterior(playerid);
GetPlayerFacingAngle(playerid, Player[playerid][bExtA]);
GetPlayerPos(playerid, Player[playerid][bExtX], Player[playerid][bExtY], Player[playerid][bExtZ]);
format(string, sizeof(string), "Exterior set! (X: %f, Y: %f, Z: %f).", Player[playerid][bExtX], Player[playerid][bExtY], Player[playerid][bExtZ]);
SendClientMessage(playerid, WHITE, string);
}
if(strcmp(Usage, "interior", true) == 0)
{
Player[playerid][BizInterior]++;
Player[playerid][bIntID] = GetPlayerInterior(playerid);
GetPlayerFacingAngle(playerid, Player[playerid][bIntA]);
GetPlayerPos(playerid, Player[playerid][bIntX], Player[playerid][bIntY], Player[playerid][bIntZ]);
format(string, sizeof(string), "Interior set! (X: %f, Y: %f, Z: %f).", Player[playerid][bIntX], Player[playerid][bIntY], Player[playerid][bIntZ]);
SendClientMessage(playerid, WHITE, string);
}
if(strcmp(Usage, "shop", true) == 0)
{
Player[playerid][BizShop]++;
Player[playerid][bShoID] = GetPlayerInterior(playerid);
GetPlayerPos(playerid, Player[playerid][bShoX], Player[playerid][bShoY], Player[playerid][bShoZ]);
format(string, sizeof(string), "Spawn possition set! (X: %f, Y: %f, Z: %f).", Player[playerid][bShoX], Player[playerid][bShoY], Player[playerid][bShoZ]);
SendClientMessage(playerid, WHITE, string);
}
if(strcmp(Usage, "complete", true) == 0)
{
if(Player[playerid][BizInterior] > 0 || Player[playerid][BizExterior] > 0)
{
new NewHouseID = SpawnedBusinesses+1;
if(NewHouseID >= MAX_BUSINESSES)
{
SendClientMessage(playerid, RED, "> Too many businesses are currently spawned!");
}
else
{
format(Businesses[NewHouseID][bName], 255, "None");
format(Businesses[NewHouseID][bOwner], 255, "Nobody");
format(Businesses[NewHouseID][bAddress], 255, "None");
Businesses[NewHouseID][bInteriorID] = Player[playerid][bIntID];
Businesses[NewHouseID][bExteriorID] = Player[playerid][bExtID];
Businesses[NewHouseID][bShopID] = Player[playerid][bShoID];
Businesses[NewHouseID][bInteriorX] = Player[playerid][bIntX];
Businesses[NewHouseID][bInteriorY] = Player[playerid][bIntY];
Businesses[NewHouseID][bInteriorZ] = Player[playerid][bIntZ];
Businesses[NewHouseID][bInteriorA] = Player[playerid][bIntA];
Businesses[NewHouseID][bExteriorX] = Player[playerid][bExtX];
Businesses[NewHouseID][bExteriorY] = Player[playerid][bExtY];
Businesses[NewHouseID][bExteriorZ] = Player[playerid][bExtZ];
Businesses[NewHouseID][bExteriorA] = Player[playerid][bExtA];
Businesses[NewHouseID][bShopX] = Player[playerid][bShoX];
Businesses[NewHouseID][bShopY] = Player[playerid][bShoY];
Businesses[NewHouseID][bShopZ] = Player[playerid][bShoZ];
Businesses[NewHouseID][bSupplies] = 1000;
Player[playerid][BizExterior]--;
Player[playerid][BizInterior]--;
Player[playerid][BizShop]--;
SendClientMessage(playerid, GREEN, "> Successfully created business, don't forget to /setbusiness!");
SetPlayerInterior(playerid, Businesses[NewHouseID][bExteriorID]);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, Businesses[NewHouseID][bExteriorX], Businesses[NewHouseID][bExteriorY], Businesses[NewHouseID][bExteriorZ]);
Businesses[NewHouseID][bLockStatus] = 1;
Businesses[NewHouseID][bPickupID] = CreateDynamicPickup(1272, 23, Businesses[NewHouseID][bExteriorX], Businesses[NewHouseID][bExteriorY], Businesses[NewHouseID][bExteriorZ], 0);
new query[2000];
format(query, sizeof(query), "INSERT INTO `businesses` (`bInteriorID`, `bInteriorX`, `bInteriorY`, `bInteriorZ`, `bInteriorA`, `bExteriorID`, `bExteriorX`, `bExteriorY`, `bExteriorZ`, `bExteriorA`,");
format(query, sizeof(query), "%s `bShopID`, `bShopX`, `bShopY`, `bShopZ`, `bSupplies`) VALUES ", query);
format(query, sizeof(query), "%s(%d, '%f', '%f', '%f', '%f', %d, '%f', '%f', '%f', '%f', %d, '%f', '%f', '%f', %d)",
query,
Player[playerid][bIntID],
Player[playerid][bIntX],
Player[playerid][bIntY],
Player[playerid][bIntZ],
Player[playerid][bIntA],
Player[playerid][bExtID],
Player[playerid][bExtX],
Player[playerid][bExtY],
Player[playerid][bExtZ],
Player[playerid][bExtA],
Player[playerid][bShoID],
Player[playerid][bShoX],
Player[playerid][bShoY],
Player[playerid][bShoZ],
Businesses[NewHouseID][bSupplies]);
SpawnedBusinesses++;
mysql_query(query);
}
}
else
{
SendClientMessage(playerid, WHITE, "> You must select an exterior and an interior first!");
}
}
}else ErrorPTD(playerid,1,"You cannot use this command!");
}
return 1;
}
else if(!strcmp(string, "Business")){
if(strcmp(Businesses[Player[playerid][LastBiz]][bOwner], "Nobody", true) == 0)
{
if(Businesses[Player[playerid][LastBiz]][bPrice] == -1)
{
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyBusinessText[playerid]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],"Unavailable");
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
PTD[playerid][tProperty] = 2;
}
else
{
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyBusinessText[playerid]);
format(string1, sizeof(string1), "%s", Businesses[Player[playerid][LastBiz]][bName]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
format(string1, sizeof(string1), "~y~Address~n~~w~%s", Businesses[Player[playerid][LastBiz]][bAddress]);
PlayerTextDrawSetString(playerid,PropertyFirstLineText[playerid],string1);
format(string1, sizeof(string1), "~y~Price~n~~w~$%d", Businesses[Player[playerid][LastBiz]][bPrice]);
PlayerTextDrawSetString(playerid,PropertySecondLineText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyFirstLineText[playerid]);
PlayerTextDrawShow(playerid,PropertySecondLineText[playerid]);
PlayerTextDrawSetString(playerid,PropertyDoorText[playerid],"~w~CMD: ~r~/buybiz");
PlayerTextDrawShow(playerid,PropertyDoorText[playerid]);
PTD[playerid][tProperty] = 2;
}
}
else
{
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyInfoText[playerid]);
format(string1, sizeof(string1), "%s", Businesses[Player[playerid][LastBiz]][bName]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
format(string1, sizeof(string1), "~y~Address~n~~w~%s", Businesses[Player[playerid][LastBiz]][bAddress]);
PlayerTextDrawSetString(playerid,PropertyFirstLineText[playerid],string1);
format(string1, sizeof(string1), "~y~Owner~n~~w~%s", Businesses[Player[playerid][LastBiz]][bOwner]);
PlayerTextDrawSetString(playerid,PropertySecondLineText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyFirstLineText[playerid]);
PlayerTextDrawShow(playerid,PropertySecondLineText[playerid]);
PlayerTextDrawShow(playerid,PropertyDoorText[playerid]);
PTD[playerid][tProperty] = 2;
}
}
}
}
else if(!strcmp(string, "Business")){
if(strcmp(Businesses[Player[playerid][LastBiz]][bOwner], "Nobody", true) == 0)
{
print("Works 1");
if(Businesses[Player[playerid][LastBiz]][bPrice] == -1)
{
print("Works 2");
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyBusinessText[playerid]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],"Unavailable");
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
PTD[playerid][tProperty] = 2;
}
else
{
print("Works 3");
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyBusinessText[playerid]);
format(string1, sizeof(string1), "%s", Businesses[Player[playerid][LastBiz]][bName]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
format(string1, sizeof(string1), "~y~Address~n~~w~%s", Businesses[Player[playerid][LastBiz]][bAddress]);
PlayerTextDrawSetString(playerid,PropertyFirstLineText[playerid],string1);
format(string1, sizeof(string1), "~y~Price~n~~w~$%d", Businesses[Player[playerid][LastBiz]][bPrice]);
PlayerTextDrawSetString(playerid,PropertySecondLineText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyFirstLineText[playerid]);
PlayerTextDrawShow(playerid,PropertySecondLineText[playerid]);
PlayerTextDrawSetString(playerid,PropertyDoorText[playerid],"~w~CMD: ~r~/buybiz");
PlayerTextDrawShow(playerid,PropertyDoorText[playerid]);
PTD[playerid][tProperty] = 2;
}
}
else
{
print("Works 4");
PlayerTextDrawShow(playerid,PropertyBGText[playerid]);
PlayerTextDrawShow(playerid,PropertyInfoText[playerid]);
format(string1, sizeof(string1), "%s", Businesses[Player[playerid][LastBiz]][bName]);
PlayerTextDrawSetString(playerid,PropertyTypeText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyTypeText[playerid]);
format(string1, sizeof(string1), "~y~Address~n~~w~%s", Businesses[Player[playerid][LastBiz]][bAddress]);
PlayerTextDrawSetString(playerid,PropertyFirstLineText[playerid],string1);
format(string1, sizeof(string1), "~y~Owner~n~~w~%s", Businesses[Player[playerid][LastBiz]][bOwner]);
PlayerTextDrawSetString(playerid,PropertySecondLineText[playerid],string1);
PlayerTextDrawShow(playerid,PropertyFirstLineText[playerid]);
PlayerTextDrawShow(playerid,PropertySecondLineText[playerid]);
PlayerTextDrawShow(playerid,PropertyDoorText[playerid]);
PTD[playerid][tProperty] = 2;
}
}
}
}
pawn Код:
|