SA-MP Forums Archive
/buy Command help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /buy Command help (/showthread.php?tid=387523)



/buy Command help - [TC]XxJuggaloxX - 25.10.2012

Well, I made a /buy command to make it for different stores. I made it so that if you were at IsAt247(playerid) || IsAtElecShop(playerid) || IsAtHardShop(playerid)
However, Whenever I go to the location of any of those, It says You are not in a Store! I don't know why, Any thoughts?

pawn Code:
CMD:buy(playerid, params[])
{
    if(!IsAt247(playerid) || !IsAtElecShop(playerid) || !IsAtHardShop(playerid))
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
        return 1;
    }
    if(IsAt247(playerid))
    {
        /*if(Showing[playerid] == 1)
        {
            Showing[playerid] = 0;
            for(new i = 0; i < 39; i++)
            {
                TextDrawHideForPlayer(playerid, Textdraw[i]);
                TogglePlayerControllable(playerid,1);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREEN, "The /buy menu may have some bugs. If you find any report them at www.ug-gaming.tk/forums");
            Showing[playerid] = 1;
            SelectTextDraw(playerid, 0xFF4040AA);
            for(new i = 0; i < 39; i++)
            {
                TextDrawShowForPlayer(playerid, Textdraw[i]);
                TogglePlayerControllable(playerid,0);
            }
        }*/

        if(PlayerInfo[playerid][pDonateRank] >= 1)
        {
            ShowPlayerDialog(playerid, STOREMENU, DIALOG_STYLE_LIST, "24/7", "Phone Book        $4000\nDice         $400\nCondom        $40\nSpraycan       $160\nRope          $800\nCigar         $40\nSprunk         $8\nCheckbook       $400\nBag           $5000\nPapers           $400", "Buy", "Cancel");
        }
        else
        {
            ShowPlayerDialog(playerid, STOREMENU, DIALOG_STYLE_LIST, "24/7", "Cell Phone        $500\nDice          $500\nCondom        $50\nSpraycan       $200\nRope          $1000\nCigar            $50\nSprunk         $10\nCheckbook      $500\nBag           $6000\nPapers           $500", "Buy", "Cancel");
        }
    }
    if(IsAtElecShop(playerid))
    {
        if(PlayerInfo[playerid][pDonateRank] >= 1)
        {
            ShowPlayerDialog(playerid, STOREMENU2, DIALOG_STYLE_LIST, "Electronic's Shop", "Cell Phone      $400\nCD Player     $40\nVehicle Lock       $4000\nPortable Radio       $40000\nCamera          $160", "Buy", "Cancel");
        }
        else
        {
            ShowPlayerDialog(playerid, STOREMENU2, DIALOG_STYLE_LIST, "Electronic's Shop", "Cell Phone      $500\nCD Player     $50\nVehicle Lock       $5000\nPortable Radio       $50000\nCamera          $200", "Buy", "Cancel");
        }
    }
    return 1;
}



Re: /buy Command help - park4bmx - 25.10.2012

then your IsAt247 is wrong
show the stock


Re: /buy Command help - [TC]XxJuggaloxX - 25.10.2012

Here is both of them

pawn Code:
stock IsAt247(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 100.0, -30.875, -88.9609, 1004.53))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 10.0, -2654.2300,1526.3693,907.1797))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, 890.66, 1429.08, -82.34))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -29.2035, -185.1285, 1003.5469))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, 2.0450,-29.0116,1003.5494))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -28.1463,-89.9533,1003.5469))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -22.0699,-138.6297,1003.5469))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -22.0699,-138.6297,1003.5469))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -30.9772,-29.0228,1003.5573))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -23.4488,-55.6319,1003.5469))
        {
            return 1;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 500, -1044.0193,1342.7756,1306.9235)) // VIP Lounge
        {
            return 1;
        }
    }
    return 0;
}

stock IsAtElecShop(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 100.0, 1007.2590,52.3136,55.3221))
        {
            return 1;
        }
    }
    return 0;
}



Re: /buy Command help - Emmet_ - 25.10.2012

pawn Code:
if(!IsAt247(playerid) && !IsAtElecShop(playerid) && !IsAtHardShop(playerid))
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
        return 1;
    }



Re: /buy Command help - park4bmx - 25.10.2012

Do this
pawn Code:
stock IsAt247(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 100.0, -30.875, -88.9609, 1004.53))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 10.0, -2654.2300,1526.3693,907.1797))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, 890.66, 1429.08, -82.34))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -29.2035, -185.1285, 1003.5469))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, 2.0450,-29.0116,1003.5494))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -28.1463,-89.9533,1003.5469))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -22.0699,-138.6297,1003.5469))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -22.0699,-138.6297,1003.5469))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -30.9772,-29.0228,1003.5573))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 50.0, -23.4488,-55.6319,1003.5469))
        {
            return true;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 500, -1044.0193,1342.7756,1306.9235)) // VIP Lounge
        {
            return true;
        }
    }
    return 0;
}

stock IsAtElecShop(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 100.0, 1007.2590,52.3136,55.3221))
        {
            return true;
        }
    }
    return 0;
}
Then do this

pawn Code:
pawn Code:
if(IsAt247(playerid)==1 || IsAtElecShop(playerid)==1 || IsAtHardShop(playerid)==1)
    {
       
        return 1;
    }else return SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");



Re: /buy Command help - CentyPoo - 25.10.2012

pawn Code:
if(!IsAt247(playerid) && !IsAtElecShop(playerid) && !IsAtHardShop(playerid)) //Use && instead of ||
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
        return 1;
    }
If you're using || for this code, it will check to see if you're not in one of everyone of them , meaning if you're in one but not the other, it will return true.


Re: /buy Command help - park4bmx - 25.10.2012

Quote:
Originally Posted by CentyPoo
View Post
pawn Code:
if(!IsAt247(playerid) && !IsAtElecShop(playerid) && !IsAtHardShop(playerid)) //Use && instead of ||
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
        return 1;
    }
If you're using || for this code, it will check to see if you're not in one of everyone of them , meaning if you're in one but not the other, it will return true.
This is wrong !
what your simply saying is that the player has to be at ALL these 3 places at the same time, how will that happen ?

Because the script will check if the player is close to all these 3 location at the same time, but that cant happen because the player cant be at these 3 positions at the same time !


Re: /buy Command help - [TC]XxJuggaloxX - 25.10.2012

Quote:
Originally Posted by Emmet_
View Post
pawn Code:
if(!IsAt247(playerid) && !IsAtElecShop(playerid) && !IsAtHardShop(playerid))
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
        return 1;
    }
This fixed it, Thanks!


Re: /buy Command help - Finn - 25.10.2012

Why do you first check if the player is not at any of those locations, then if the player is at some of them, you check it again just to confirm this fact? I find it pretty stupid.

What you should do instead:
pawn Code:
if(IsAt247(playerid))
{
    // 247 code
}
else if(IsAtElecShop(playerid))
{
    // ElecShop code
}
else if(IsAtHardShop(playerid))
{
    // HardShop code
}
else
{
    SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a Store!");
    return 1;
}