30.06.2015, 15:51
I could be blind as a bat, but in your example i dont even see a pVBiz?
Nevertheless, try the below, i added a bunch of linebreaks to improve readability, and added comments to describe my changes to your code, feel free to re-structure again on your end.
Edit: "currInteriour" should actually be "currInterior", sorry, not a native english speaker
Nevertheless, try the below, i added a bunch of linebreaks to improve readability, and added comments to describe my changes to your code, feel free to re-structure again on your end.
Код:
CMD:bizupgrade(playerid, params[]) { new string[128], idx = PlayerInfo[playerid][pBiz], idx2 = PlayerInfo[playerid][pVBiz], // added a pointer too the pVBiz currInteriour = GetPlayerVirtualWorld(playerid)-100; // added a variable that should hold the current interior id (or whatever that GetPlayerVirtualWorld returns) if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!PlayerInfo[playerid][pBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business."); // changed, now it will check against both interiours // As an added bonus, we can now just use "currInteriour" in the remainder of this function, if that does not match idx or idx2 then it wont get past the below line anyway. if((currInteriour != idx) && (currInteriour != idx2)) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business."); if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizupgrade [confirm]"); // changed, now it will check currInteriour instead of idx if(BizInfo[currInteriour][bLevel] >= 5) return SendClientMessage(playerid, COLOR_GREY, "Your business already has the maximum level possible."); if(!strcmp(params, "confirm", true)) { // in the four if statements below, idx was replaced with currInteriour if(strval(RPBL(playerid)) == 1 && RPBS(playerid) >= 100) {BizInfo[currInteriour][bLevel]++; SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have upgraded your business to level 2.");} else if(strval(RPBL(playerid)) == 2 && RPBS(playerid) >= 300) {BizInfo[currInteriour][bLevel]++; SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have upgraded your business to level 3.");} else if(strval(RPBL(playerid)) == 3 && RPBS(playerid) >= 700) {BizInfo[currInteriour][bLevel]++; SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have upgraded your business to level 4.");} else if(strval(RPBL(playerid)) == 4 && RPBS(playerid) >= 1200) {BizInfo[currInteriour][bLevel]++; SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have upgraded your business to level 5.");} else { if(strval(RPBL(playerid)) == 1) format(string, sizeof(string), "Your business needs to sell %d more products to level up.", 100 -RPBS(playerid)); else if(strval(RPBL(playerid)) == 2) format(string, sizeof(string), "Your business needs to sell %d more products to level up.", 300 -RPBS(playerid)); else if(strval(RPBL(playerid)) == 3) format(string, sizeof(string), "Your business needs to sell %d more products to level up.", 700 -RPBS(playerid)); else if(strval(RPBL(playerid)) == 4) format(string, sizeof(string), "Your business needs to sell %d more products to level up.", 1200 -RPBS(playerid)); SendClientMessage(playerid, COLOR_GREY, string); } } return 1; }