/eat help
#1

Hello, I am trying to make a /eat command, but it wont let me choose the second choice[berry]. Cant figure out whats wrong.

Код:
CMD:eat(playerid,params[])
	{
		new option[128], string[128], sendername[MAX_PLAYER_NAME];
		if(sscanf(params, "s", option))
		{
  			SendClientMessage(playerid, RED, "[Survival:RP] /eat option");
     		SendClientMessage(playerid, COLOR_WHITE, "[Survival:RP] Options: fish,berry");
  			return 1;
		}
		if (strcmp(option, "fish", true) == 0)
		{
  			if(PlayerInfo[playerid][pFishDone] > 0)
			{
	 			if(Hungry[playerid] > 4)
 				{
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					GameTextForPlayer(playerid, "~g~You ate your fish",3500,5);
					PlayerInfo[playerid][pSlotsFree] -= 1;
					format(string, sizeof(string), "%s takes his/her cooked fish and eats it", sendername);
					ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
					PlayerInfo[playerid][pFishDone] -= 1;
					SetPlayerHealth(playerid, 100);
					Hungry[playerid] = 0;
					SetProgressBarValue(Hunger[playerid], 0.0);
					UpdateProgressBar(Hunger[playerid], playerid);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
				}
			}
			else
			{
   				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any fish cooked");
			}
			if(strcmp(option, "berry", true) == 0)
			{
				if(Hungry[playerid] > 4)
				{
    				if(PlayerInfo[playerid][pBerry] > 0)
    				{
			  			ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
						ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
						GameTextForPlayer(playerid, "~g~You ate a berry",3500,5);
						PlayerInfo[playerid][pSlotsFree] -= 1;
						format(string, sizeof(string), "%s takes his/her berry and eats it", sendername);
						ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
						PlayerInfo[playerid][pBerry] -= 1;
						SetPlayerHealth(playerid, 100);
						Hungry[playerid] = 0;
						SetProgressBarValue(Hunger[playerid], 0.0);
						UpdateProgressBar(Hunger[playerid], playerid);
     				}
					else
					{
   						SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
					}
				}
				else
				{
    				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any berries");
				}
			}
		}
		return 1;
	}
Would be grateful if anyone knew whats wrong
Reply
#2

Код:
CMD:eat(playerid,params[])
	{
		new option[128], string[128], sendername[MAX_PLAYER_NAME];
		if(sscanf(params, "s", option))
		{
  			SendClientMessage(playerid, RED, "[Survival:RP] /eat option");
     		SendClientMessage(playerid, COLOR_WHITE, "[Survival:RP] Options: fish,berry");
  			return 1;
		}
		if (strcmp(option, "fish", true) == 0)
		{
  			if(PlayerInfo[playerid][pFishDone] > 0)
			{
	 			if(Hungry[playerid] > 4)
 				{
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					GameTextForPlayer(playerid, "~g~You ate your fish",3500,5);
					PlayerInfo[playerid][pSlotsFree] -= 1;
					format(string, sizeof(string), "%s takes his/her cooked fish and eats it", sendername);
					ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
					PlayerInfo[playerid][pFishDone] -= 1;
					SetPlayerHealth(playerid, 100);
					Hungry[playerid] = 0;
					SetProgressBarValue(Hunger[playerid], 0.0);
					UpdateProgressBar(Hunger[playerid], playerid);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
				}
			}
			else
			{
   				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any fish cooked");
			}
			if(strcmp(option, "berry", true) == 0)
			{
    				if(PlayerInfo[playerid][pBerry] > 0)	
				{
    				if(Hungry[playerid] > 4)
    				{
			  			ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
						ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
						GameTextForPlayer(playerid, "~g~You ate a berry",3500,5);
						PlayerInfo[playerid][pSlotsFree] -= 1;
						format(string, sizeof(string), "%s takes his/her berry and eats it", sendername);
						ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
						PlayerInfo[playerid][pBerry] -= 1;
						SetPlayerHealth(playerid, 100);
						Hungry[playerid] = 0;
						SetProgressBarValue(Hunger[playerid], 0.0);
						UpdateProgressBar(Hunger[playerid], playerid);
     				}
					else
					{
   						SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
					}
				}
				else
				{
    				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any berries");
				}
			}
		}
		return 1;
	}
Try this one
Reply
#3

No, still dont work. I can do /eat fish, and it shows the error that I dont have any fish. But when I do /eat berry, nothing is happening at all
Reply
#4

Код:
CMD:eat(playerid,params[])
	{
		new option[128], string[128], sendername[MAX_PLAYER_NAME];
		if(sscanf(params, "s", option))
		{
  			SendClientMessage(playerid, RED, "[Survival:RP] /eat option");
     		SendClientMessage(playerid, COLOR_WHITE, "[Survival:RP] Options: fish,berry");
  			return 1;
		}
		if (strcmp(option, "fish", true) == 0)
		{
  			if(PlayerInfo[playerid][pFishDone] > 0)
			{
	 			if(Hungry[playerid] > 4)
 				{
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					GameTextForPlayer(playerid, "~g~You ate your fish",3500,5);
					PlayerInfo[playerid][pSlotsFree] -= 1;
					format(string, sizeof(string), "%s takes his/her cooked fish and eats it", sendername);
					ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
					PlayerInfo[playerid][pFishDone] -= 1;
					SetPlayerHealth(playerid, 100);
					Hungry[playerid] = 0;
					SetProgressBarValue(Hunger[playerid], 0.0);
					UpdateProgressBar(Hunger[playerid], playerid);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
				}
			}
			else
			{
   				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any fish cooked");
			}
		if (strcmp(option, "berry", true) == 0)
		{
  			if(PlayerInfo[playerid][pBerry] > 0)
			{
	 			if(Hungry[playerid] > 4)
 				{
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					GameTextForPlayer(playerid, "~g~You ate a barry",3500,5);
					PlayerInfo[playerid][pSlotsFree] -= 1;
					format(string, sizeof(string), "%s takes his/her berry and eats it", sendername);
					ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
					PlayerInfo[playerid][pBerry] -= 1;
					SetPlayerHealth(playerid, 100);
					Hungry[playerid] = 0;
					SetProgressBarValue(Hunger[playerid], 0.0);
					UpdateProgressBar(Hunger[playerid], playerid);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
				}
			}
			else
			{
   				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any berries");
			}
			}
		}
		return 1;
	}
Try this, and if it doesnt work check if [pBerry] stat is added corectly.
Reply
#5

When I did /eat berry, it said I wasnt hungry. But when I got hungry, it didnt react again.

New code:

Код:
CMD:eat(playerid,params[])
	{
		new option[128], string[128], sendername[MAX_PLAYER_NAME];
		if(sscanf(params, "s", option))
		{
  			SendClientMessage(playerid, RED, "[Survival:RP] /eat option");
     		SendClientMessage(playerid, COLOR_WHITE, "[Survival:RP] Options: fish,berry");
  			return 1;
		}
		if(Hungry[playerid] < 5) return SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
		if (strcmp(option, "fish", true) == 0)
		{
  			if(PlayerInfo[playerid][pFishDone] > 0)
			{
				ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
				ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
				GameTextForPlayer(playerid, "~g~You ate your fish",3500,5);
				PlayerInfo[playerid][pSlotsFree] -= 1;
				format(string, sizeof(string), "%s takes his/her cooked fish and eats it", sendername);
				ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
				PlayerInfo[playerid][pFishDone] -= 1;
				SetPlayerHealth(playerid, 100);
				Hungry[playerid] = 0;
				SetProgressBarValue(Hunger[playerid], 0.0);
				UpdateProgressBar(Hunger[playerid], playerid);
			}
			else
			{
   				SendClientMessage(playerid, RED, "[Survival:RP] You dont have any fish cooked");
			}
			if (strcmp(option, "berry", true) == 0)
			{
  				if(PlayerInfo[playerid][pBerry] > 0)
				{
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					ApplyAnimation(playerid, "FOOD","EAT_Burger",4.0,0, 1, 1, 1, 1);
					GameTextForPlayer(playerid, "~g~You ate a barry",3500,5);
					PlayerInfo[playerid][pSlotsFree] -= 1;
					format(string, sizeof(string), "%s takes his/her berry and eats it", sendername);
					ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
					PlayerInfo[playerid][pBerry] -= 1;
					SetPlayerHealth(playerid, 100);
					Hungry[playerid] = 0;
					SetProgressBarValue(Hunger[playerid], 0.0);
					UpdateProgressBar(Hunger[playerid], playerid);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You are not hungry");
				}
			}
		}
		return 1;
	}
Reply
#6

Mhmm. Just make 2 Cmds. /eatfish and /eatberry. problem solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)