Detect distance from land?
#1

How to make that the fish weight becomes larger the longer you are out in the ocean?

pawn Код:
if(PRESSED(KEY_AIM))
    {
        if (FishCaught[playerid] == 1)
        {
            if(IsPlayerNearWater(playerid) || IsPlayerInWater(playerid))
            {
                //if(Fishing[playerid] == 1)
                {
                    new Caught;
                    new rand;
                    new luck = Random(1, 100);
                    new fstring[MAX_PLAYER_NAME];
                    new Level = PlayerInfo[playerid][pFishSkill];
                    if(Level >= 0   && Level < 50)  { Caught = random((20 -  7 + 1)) + 7; }
                    else if(Level >= 50  && Level < 100) { Caught = random((50 - 20 + 1)) + 20; }
                    else if(Level >= 100 && Level < 200) { Caught = random((75 - 50 + 1)) + 50; }
                    else if(Level >= 200 && Level < 400) { Caught = random((87 - 60 + 1)) + 60; }
                    else if(Level >= 400 && Level < 500) { Caught = random((105 - 60 + 1)) + 60; }
                    else if(Level >= 500) { Caught = random((120 - 60 + 1)) + 60; }
                    rand = random(FishNamesNumber);
                    if(luck <= 99)
                    {
                        if(Fishes[playerid][pWeight] == 0)
                        {
                            new string[85];
                            HidePlayerFishText(playerid);
                            PlayerInfo[playerid][pFishes] += 1;
                            Fishes[playerid][pFishHold] = 1;
                            PlayerInfo[playerid][pFishSkill] += 1;
                            format(fstring, sizeof(fstring), "%s", FishNames[rand]);
                            strmid(Fishes[playerid][pFish], fstring, 0, strlen(fstring), 255);
                            format(string, sizeof(string), "* %s reels in a %s weighing %d lbs!", RemoveUnderScore(playerid), Fishes[playerid][pFish], Caught);
                            ProxDetector(30.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                            RemovePlayerAttachedObject(playerid,0);
                            KillTimer(fishtimer[playerid]);
                            FishCaught[playerid] = 0;
                            Fishing[playerid] = 0;
                            Fishes[playerid][pWeight] = Caught;
                            Fishes[playerid][pLastFish] = 2;
                            Fishes[playerid][pFishPrice] = rand;
                            Fishes[playerid][pFishID] = rand;
                        }
                        return 1;
                    }
                    if(PlayerInfo[playerid][pFishSkill] == 50)
                    { SendClientMessage(playerid, COLOR_YELLOW, "* Your fishing skill is now level 2."); }
                    else if(PlayerInfo[playerid][pFishSkill] == 100)
                    { SendClientMessage(playerid, COLOR_YELLOW, "* Your fishing skill is now level 3."); }
                    else if(PlayerInfo[playerid][pFishSkill] == 200)
                    { SendClientMessage(playerid, COLOR_YELLOW, "* Your fishing skill is now level 4."); }
                    else if(PlayerInfo[playerid][pFishSkill] == 400)
                    { SendClientMessage(playerid, COLOR_YELLOW, "* Your fishing skill is now level 5."); }
                    else if(PlayerInfo[playerid][pFishSkill] == 700)
                    { SendClientMessage(playerid, COLOR_YELLOW, "* The fish gods are mad at you!. You no longer can catch fish."); }
                }
            }
        }
    }
    return 1;
}
Reply
#2

Anyone?
Reply
#3

You must use zones for that or if player is in range of point
Reply
#4

Quote:
Originally Posted by Rockefeller
Посмотреть сообщение
You must use zones for that or if player is in range of point
Yeah, i have the zones include, how do i make it detect if the player is far away from land?
Reply
#5

Using a base IsPlayerInWater function and a timer, you can detect when they enter the water and get their current position which you can compare and reference to.

These may be of assistance:
https://sampforum.blast.hk/showthread.php?tid=400049
https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint
Reply
#6

Well the map is roughly 6000x6000 units in size, so what you could basically do is see if their X or Y coordinate is greater than 3000 or less than -3000 and calculate a size based off that. I would consider a coordinate of more than 3000 or less than -3000 (excluding height axis) to be 'deep ocean'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)