SA-MP Forums Archive
Eat Command not working properly - 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: Eat Command not working properly (/showthread.php?tid=591879)



Eat Command not working properly - Crystallize - 17.10.2015

Fixed.


Re: Eat Command not working properly - Abagail - 17.10.2015

Why do you have IsPlayerInRangeOfPoint but not check the result? Secondly, it will always display you are no longer hungry because it's not told to do so otherwise(assuming you have the knife).

Also, knifes are weaponID 4 not 8.


Re: Eat Command not working properly - Crystallize - 17.10.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Why do you have IsPlayerInRangeOfPoint but not check the result? Secondly, it will always display you are no longer hungry because it's not told to do so otherwise(assuming you have the knife).

Also, knifes are weaponID 4 not 8.
Thanks for poiting out the ID of the knife and other issues.What do you mean with "not check the results"? like what any example? Thanks!


Re: Eat Command not working properly - TwinkiDaBoss - 17.10.2015

Check if the player is in range of the point.
pawn Код:
CMD:eat(playerid) {
    if(GetPlayerWeapon(playerid) != 4) return SendClientMessage(playerid, -1, "You must be holding a knife to eat the human meat!");
    if(!IsPlayerInRangeOfPoint (playerid, 8.0, 2695.6880, -1704.6300, 11.8438)) return SendClientMessage(playerid,COLOR_RED,"You are not near eating place!");
    ApplyAnimation(playerid, "PED", "BOM_Plant ", 4.1, 0, 1, 1, 0, 1, 1);
    SetPlayerHealth(playerid, 100);
    SetTimerEx("needFood",needFoodTimer,1,"i",playerid);
    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are no longer hungry");
    return 1;
}

Using IF you are checking if they are near the point. Having IsPlayerInRangeOfPoint wouldnt make any sort of sense to the script.


Re: Eat Command not working properly - Crystallize - 17.10.2015

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Check if the player is in range of the point.
pawn Код:
CMD:eat(playerid) {
    if(GetPlayerWeapon(playerid) != 4) return SendClientMessage(playerid, -1, "You must be holding a knife to eat the human meat!");
    if(!IsPlayerInRangeOfPoint (playerid, 8.0, 2695.6880, -1704.6300, 11.8438)) return SendClientMessage(playerid,COLOR_RED,"You are not near eating place!");
    ApplyAnimation(playerid, "PED", "BOM_Plant ", 4.1, 0, 1, 1, 0, 1, 1);
    SetPlayerHealth(playerid, 100);
    SetTimerEx("needFood",needFoodTimer,1,"i",playerid);
    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are no longer hungry");
    return 1;
}

Using IF you are checking if they are near the point. Having IsPlayerInRangeOfPoint wouldnt make any sort of sense to the script.
Thanks!
That's what I was missing ;/