SA-MP Forums Archive
Logic Error ? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Logic Error ? (/showthread.php?tid=194918)



Logic Error ? - marinov - 30.11.2010

pawn Код:
if(strcmp(cmd, "/feed", true) == 0)
    {
        if(team[playerid] != 6 && team[playerid] != 7) return SendClientMessage(playerid, YELLOW, "You are not STARS / UC!");
        target = GetClosestPlayer(playerid);
        if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "Nobody is near you!");
        if(GetDistanceBetweenPlayers(playerid,target) <= 3)
        {
            IsHungry[playerid] = 0;
            SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
            GameTextForPlayer(target,"~g~FED",5000,1);
            SendClientMessage(playerid,GREEN,"Player was feed!");
        }
        else SendClientMessage(playerid, YELLOW, "Nobody is near you!");
        return 1;
    }
when I use it in game it says "Player was feed!" but even when no one is close to me. Is a logic error in there ?


Re: Logic Error ? - marinov - 30.11.2010

bump this s*%t


Re: Logic Error ? - The_Moddler - 30.11.2010

pawn Код:
if(strcmp(cmd, "/feed", true) == 0)
{
    if(team[playerid] != 6 && team[playerid] != 7) return SendClientMessage(playerid, YELLOW, "You are not STARS / UC!");
    {
        target = GetClosestPlayer(playerid);
        if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "Nobody is near you!");
        {
            if(GetDistanceBetweenPlayers(playerid, target) < 3) return SendClientMessage(playerid, YELLOW, "Nobody is near you!");
            {
                IsHungry[playerid] = 0;
                SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
                GameTextForPlayer(target,"~g~FED",5000,1);
                SendClientMessage(playerid,GREEN,"Player was feed!");
            }
        }
    }
    return 1;
}
Try that.


Re: Logic Error ? - marinov - 30.11.2010

nope, all it says is "Nobody is near you!", even when someone is right next to me


Re: Logic Error ? - marinov - 01.12.2010

pawn Код:
if(strcmp(cmd, "/feed", true) == 0)
    {
        if(team[playerid] != 6 && team[playerid] != 7) return SendClientMessage(playerid, YELLOW, "You are not STARS / UC!");
        target = GetClosestPlayer(playerid);
        if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "Nobody is near you!");
        if(GetDistanceBetweenPlayers(playerid,target) <= 3)
        {
            IsHungry[playerid] = 0;
            SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
            GameTextForPlayer(target,"~g~FED",5000,1);
            SendClientMessage(playerid,GREEN,"Player was feed!");
      }
        else SendClientMessage(playerid, YELLOW, "Nobody is near you!");
        return 1;
    }
I did like this, it is working now, thx