Bracket of SendClientMessage
#1

Hi all...
I'm getting tired from that brackets...
I have some problems with bracket on my cmd /buy, i tried a lot of tries but nothing works.
so what i want is: when player is at 24/7 market and he type /buy vest it will SCM to him "You are not at the Goverment Ammunation"
when player is on ammunation and type /buy speedomter it will SCM "You are not at 24/7"

Here some SS to show you the problem: (Its not the full code but with strcmp function is all same so i just gave an exmaple)

24/7 market sends unnecessary SCM:



ammunation doesn't respond -_-




and there is the command:

Код:
CMD:buy(playerid, params[])
{
	new idx = GetPlayerVirtualWorld(playerid)-100, string[128], price, bizlevel;
	if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 && BizInfo[idx][bType] != 7 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");
	
	if(sscanf(params, "s[32]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [item]");
	if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_GREY, "This business is currently out of products.");
	
	if(BizInfo[idx][bLevel] < bizlevel) return SendClientMessage(playerid, COLOR_GREY, "This business doesn't have this product yet.");
	
	if(BizInfo[idx][bType] == 1)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the 24/7 Market!");
	{
	if(!strcmp(params, "speedometer", true))
	{
		if(GetPlayerMoney(playerid) >= price)
		{
			GivePlayerCash(playerid, -5000);
			PlayerInfo[playerid][pSpeedo] = 1;
			PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
			SendClientMessage(playerid, COLOR_GRAD4, "Speedometer purchased.");
			SendClientMessage(playerid, COLOR_WHITE, "HINT: Type /speedo to use.");
			BizInfo[idx][bProducts] --;
			BizInfo[idx][bSold] ++;
			if(PlayerInfo[playerid][pDonateRank] >= 2)
			{
   				GivePlayerCash(playerid, -(80*price)/100);
   				BizInfo[idx][bMoney] += price;
				format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
		        SendClientMessageEx(playerid, COLOR_YELLOW, string);
	      	}
			else
			{
			    BizInfo[idx][bMoney] += price;
				GivePlayerCash(playerid, -price);
				}
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
			}
		}
		
	else if(BizInfo[idx][bType] == 3)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the Goverment Ammunation!");
	{		
	if(!strcmp(params, "vest", true))
	{
		if(GetPlayerMoney(playerid) >= price)
		{
			format(string, sizeof(string), "* %s has bought a vest for $%d.", GetPlayerNameEx(playerid), price);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetPlayerArmour(playerid, 100.00);
			BizInfo[idx][bProducts] --;
			BizInfo[idx][bSold] ++;
			if(PlayerInfo[playerid][pDonateRank] >= 2)
			{
				GivePlayerCash(playerid, -(80*price)/100);
				BizInfo[idx][bMoney] += price;
				format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
				SendClientMessageEx(playerid, COLOR_YELLOW, string);
			}
			else
			{
				BizInfo[idx][bMoney] += price;
				GivePlayerCash(playerid, -price);
				}
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not at the Goverment Ammunation!");
		}
	}
	return 1;
}
I'm getting tired from that brackets... can someone give me a full tutorial of how using brackets in all conditions?
+REP
Reply
#2

Just add return 1 att every end of script to stop it from keep reading the rest of the script
Reply
#3

Quote:
Originally Posted by Xsyiaris
Посмотреть сообщение
Just add return 1 att every end of script to stop it from keep reading the rest of the script
Can you please add it on the cmd to Avoid mistakes?
Reply
#4

pawn Код:
CMD:buy(playerid, params[])
{
    new idx = GetPlayerVirtualWorld(playerid)-100, string[128], price, bizlevel;
    if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 && BizInfo[idx][bType] != 7 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");

    if(sscanf(params, "s[32]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [item]");
    if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_GREY, "This business is currently out of products.");

    if(BizInfo[idx][bLevel] < bizlevel) return SendClientMessage(playerid, COLOR_GREY, "This business doesn't have this product yet.");

    if(BizInfo[idx][bType] == 1)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the 24/7 Market!");
    {
        if(!strcmp(params, "speedometer", true))
        {
            if(GetPlayerMoney(playerid) >= price)
            {
                GivePlayerCash(playerid, -5000);
                PlayerInfo[playerid][pSpeedo] = 1;
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                SendClientMessage(playerid, COLOR_GRAD4, "Speedometer purchased.");
                SendClientMessage(playerid, COLOR_WHITE, "HINT: Type /speedo to use.");
                BizInfo[idx][bProducts] --;
                BizInfo[idx][bSold] ++;
                if(PlayerInfo[playerid][pDonateRank] >= 2)
                {
                    GivePlayerCash(playerid, -(80*price)/100);
                    BizInfo[idx][bMoney] += price;
                    format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
                    SendClientMessageEx(playerid, COLOR_YELLOW, string);
                }
                else
                {
                    BizInfo[idx][bMoney] += price;
                    GivePlayerCash(playerid, -price);
                }
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
            }
        }
        else if(BizInfo[idx][bType] == 3)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the Goverment Ammunation!");
        {
            if(!strcmp(params, "vest", true))
            {
                if(GetPlayerMoney(playerid) >= price)
                {
                    format(string, sizeof(string), "* %s has bought a vest for $%d.", GetPlayerNameEx(playerid), price);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SetPlayerArmour(playerid, 100.00);
                    BizInfo[idx][bProducts] --;
                    BizInfo[idx][bSold] ++;
                    if(PlayerInfo[playerid][pDonateRank] >= 2)
                    {
                        GivePlayerCash(playerid, -(80*price)/100);
                        BizInfo[idx][bMoney] += price;
                        format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
                        SendClientMessageEx(playerid, COLOR_YELLOW, string);
                    }
                    else
                    {
                        BizInfo[idx][bMoney] += price;
                        GivePlayerCash(playerid, -price);
                    }
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
                }
            }
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "  You are not at the Goverment Ammunation!");
        }
    }
    return 1;
}
Here's the code, anything missed or any mistake inside it?
Reply
#5

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
pawn Код:
CMD:buy(playerid, params[])
{
    new idx = GetPlayerVirtualWorld(playerid)-100, string[128], price, bizlevel;
    if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 && BizInfo[idx][bType] != 7 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");

    if(sscanf(params, "s[32]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [item]");
    if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_GREY, "This business is currently out of products.");

    if(BizInfo[idx][bLevel] < bizlevel) return SendClientMessage(playerid, COLOR_GREY, "This business doesn't have this product yet.");

    if(BizInfo[idx][bType] == 1)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the 24/7 Market!");
    {
        if(!strcmp(params, "speedometer", true))
        {
            if(GetPlayerMoney(playerid) >= price)
            {
                GivePlayerCash(playerid, -5000);
                PlayerInfo[playerid][pSpeedo] = 1;
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                SendClientMessage(playerid, COLOR_GRAD4, "Speedometer purchased.");
                SendClientMessage(playerid, COLOR_WHITE, "HINT: Type /speedo to use.");
                BizInfo[idx][bProducts] --;
                BizInfo[idx][bSold] ++;
                if(PlayerInfo[playerid][pDonateRank] >= 2)
                {
                    GivePlayerCash(playerid, -(80*price)/100);
                    BizInfo[idx][bMoney] += price;
                    format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
                    SendClientMessageEx(playerid, COLOR_YELLOW, string);
                }
                else
                {
                    BizInfo[idx][bMoney] += price;
                    GivePlayerCash(playerid, -price);
                }
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
            }
        }
        else if(BizInfo[idx][bType] == 3)// return SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the Goverment Ammunation!");
        {
            if(!strcmp(params, "vest", true))
            {
                if(GetPlayerMoney(playerid) >= price)
                {
                    format(string, sizeof(string), "* %s has bought a vest for $%d.", GetPlayerNameEx(playerid), price);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SetPlayerArmour(playerid, 100.00);
                    BizInfo[idx][bProducts] --;
                    BizInfo[idx][bSold] ++;
                    if(PlayerInfo[playerid][pDonateRank] >= 2)
                    {
                        GivePlayerCash(playerid, -(80*price)/100);
                        BizInfo[idx][bMoney] += price;
                        format(string, sizeof(string), "VIP: You have received 20 percent off this product. Instead of paying $%d, you paid $%d.", price, (80*price)/100);
                        SendClientMessageEx(playerid, COLOR_YELLOW, string);
                    }
                    else
                    {
                        BizInfo[idx][bMoney] += price;
                        GivePlayerCash(playerid, -price);
                    }
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_GRAD4, "You don't have the cash for this item!");
                }
            }
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "  You are not at the Goverment Ammunation!");
        }
    }
    return 1;
}
Here's the code, anything missed or any mistake inside it?
No, but as i told in my first post.
BTW what did you change on your post?
Reply
#6

it's alright, i just fixed brackets places, it wasn't in it correct place
Reply
#7

Where did you change? because as i see the code you fixed i did exactly like yours but its still same problems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)