Sellfish Location issue
#1

pawn Код:
if(strcmp(cmd, "/sellfish", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] != 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a 24-7!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellfish [number]");
                return 1;
            }
            new price;
            new fishid = strvalEx(tmp);
            if(fishid < 1 || fishid > 5) { SendClientMessage(playerid, COLOR_GREY, "   Fish can't be below 1 or above 5!"); return 1; }
            else if(fishid == 1 && Fishes[playerid][pWeight1] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 2 && Fishes[playerid][pWeight2] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 3 && Fishes[playerid][pWeight3] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 4 && Fishes[playerid][pWeight4] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 5 && Fishes[playerid][pWeight5] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            switch (fishid)
            {
                case 1:
                {
                    if(Fishes[playerid][pWeight1] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighting 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid1]);
                    price = price * Fishes[playerid][pWeight1];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish1],Fishes[playerid][pWeight1],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 1);
                }
                case 2:
                {
                    if(Fishes[playerid][pWeight2] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid2]);
                    price = price * Fishes[playerid][pWeight2];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish2],Fishes[playerid][pWeight2],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 2);
                }
                case 3:
                {
                    if(Fishes[playerid][pWeight3] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid3]);
                    price = price * Fishes[playerid][pWeight3];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish3],Fishes[playerid][pWeight3],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 3);
                }
                case 4:
                {
                    if(Fishes[playerid][pWeight4] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid4]);
                    price = price * Fishes[playerid][pWeight4];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish4],Fishes[playerid][pWeight4],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 4);
                }
                case 5:
                {
                    if(Fishes[playerid][pWeight5] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid5]);
                    price = price * Fishes[playerid][pWeight5];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish5],Fishes[playerid][pWeight5],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 5);
                }
            }
            Fishes[playerid][pLastFish] = 0;
            Fishes[playerid][pFishID] = 0;
            return 1;
        }
        return 1;
    }
Pretty much, id like to change it to ONLY make the sellfish work at a coordinate "fishing store" instead of 24/7s.

Can anyone rearrange the code to make it possible?

Make it so that if youre not at the coordinate you cant sell your fish.

The sample coordinates: 2581.3191,53.2449,27.0078 Thanks!
Reply
#2

pawn Код:
if(strcmp(cmd, "/sellfish", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2581.3191, 53.2449, 27.0078))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the fishing store!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellfish [number]");
                return 1;
            }
            new price;
            new fishid = strvalEx(tmp);
            if(fishid < 1 || fishid > 5) { SendClientMessage(playerid, COLOR_GREY, "   Fish can't be below 1 or above 5!"); return 1; }
            else if(fishid == 1 && Fishes[playerid][pWeight1] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 2 && Fishes[playerid][pWeight2] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 3 && Fishes[playerid][pWeight3] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 4 && Fishes[playerid][pWeight4] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 5 && Fishes[playerid][pWeight5] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            switch (fishid)
            {
                case 1:
                {
                    if(Fishes[playerid][pWeight1] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighting 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid1]);
                    price = price * Fishes[playerid][pWeight1];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish1],Fishes[playerid][pWeight1],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 1);
                }
                case 2:
                {
                    if(Fishes[playerid][pWeight2] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid2]);
                    price = price * Fishes[playerid][pWeight2];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish2],Fishes[playerid][pWeight2],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 2);
                }
                case 3:
                {
                    if(Fishes[playerid][pWeight3] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid3]);
                    price = price * Fishes[playerid][pWeight3];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish3],Fishes[playerid][pWeight3],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 3);
                }
                case 4:
                {
                    if(Fishes[playerid][pWeight4] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid4]);
                    price = price * Fishes[playerid][pWeight4];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish4],Fishes[playerid][pWeight4],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 4);
                }
                case 5:
                {
                    if(Fishes[playerid][pWeight5] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid5]);
                    price = price * Fishes[playerid][pWeight5];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish5],Fishes[playerid][pWeight5],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 5);
                }
            }
            Fishes[playerid][pLastFish] = 0;
            Fishes[playerid][pFishID] = 0;
            return 1;
        }
        return 1;
    }
Reply
#3

Just replace this:
pawn Код:
if(BizzInfo[PlayerInfo[playerid][InBusiness]][bType] != 1)
With
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 10.0, 2581.3191,53.2449,27.0078))
It's really not that hard if you think about it logically.

Edit: damn, someone beat me.
Reply
#4

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/sellfish", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2581.3191, 53.2449, 27.0078))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not at the fishing store!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellfish [number]");
                return 1;
            }
            new price;
            new fishid = strvalEx(tmp);
            if(fishid < 1 || fishid > 5) { SendClientMessage(playerid, COLOR_GREY, "   Fish can't be below 1 or above 5!"); return 1; }
            else if(fishid == 1 && Fishes[playerid][pWeight1] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 2 && Fishes[playerid][pWeight2] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 3 && Fishes[playerid][pWeight3] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 4 && Fishes[playerid][pWeight4] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            else if(fishid == 5 && Fishes[playerid][pWeight5] < 1) { SendClientMessage(playerid, COLOR_GREY, "   You don't have a fish in that slot!"); return 1; }
            switch (fishid)
            {
                case 1:
                {
                    if(Fishes[playerid][pWeight1] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighting 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid1]);
                    price = price * Fishes[playerid][pWeight1];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish1],Fishes[playerid][pWeight1],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 1);
                }
                case 2:
                {
                    if(Fishes[playerid][pWeight2] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid2]);
                    price = price * Fishes[playerid][pWeight2];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish2],Fishes[playerid][pWeight2],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 2);
                }
                case 3:
                {
                    if(Fishes[playerid][pWeight3] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid3]);
                    price = price * Fishes[playerid][pWeight3];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish3],Fishes[playerid][pWeight3],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 3);
                }
                case 4:
                {
                    if(Fishes[playerid][pWeight4] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid4]);
                    price = price * Fishes[playerid][pWeight4];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish4],Fishes[playerid][pWeight4],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 4);
                }
                case 5:
                {
                    if(Fishes[playerid][pWeight5] < 20)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "We are only interested in Fish weighing 20 LBS or more.");
                        return 1;
                    }
                    price = FishCost(playerid, Fishes[playerid][pFid5]);
                    price = price * Fishes[playerid][pWeight5];
                    format(string, sizeof(string), "* You have sold your %s that weighs %d, for $%d.", Fishes[playerid][pFish5],Fishes[playerid][pWeight5],price);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price;
                    GivePlayerMoney(playerid, price);
                    ClearFishID(playerid, 5);
                }
            }
            Fishes[playerid][pLastFish] = 0;
            Fishes[playerid][pFishID] = 0;
            return 1;
        }
        return 1;
    }
Boss! Thanks a lot!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)