Dialog selection nothing happens
#1

I made a dialog for hospital but nothing happens when I choose one of the selections. Thats the part of my dialog;


Код:
if(dialogid == DIALOG_HOSPITAL)
{
	    if(response)
	    {
	        if(listitem == 0)
	        {
	        
        		if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        	{
	            	SetPlayerHealth(playerid,99);
	            	GivePlayerMoney(playerid, -10000);
	            	SendClientMessage(playerid, -1, "Your health increased.");
			}
        		if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) < 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        	{
			SendClientMessage(playerid, -1, "Not enough money.");
			}
        		if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] > 0)
	        	{
         		SetPlayerHealth(playerid, 99);
			SendClientMessage(playerid, -1, "Your expenses was covered by health insurance.");
			}
     			if(GetPlayerHealth(playerid) > 99 && GetPlayerMoney(playerid) >= 10000)
	        	{
			SendClientMessage(playerid, -1, "You don't need this.");
			 }

	        }
	    }


    return 1;
}
Reply
#2

Try
pawn Код:
switch(listitem)
{
case 0:
{

}
case 1:
{

}
case 2:
{

}
//... and so on
}
Reply
#3

Still nothing happens and it says "number of arguments does not match definition"

Код:
   	if(dialogid == DIALOG_HOSPITAL)
	{
		if(response)
		{
			switch(listitem)
			{

				case 1:
				{

        			    if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        		    {
	            		          SetPlayerHealth(playerid, 99);
	            		          GivePlayerMoney(playerid, -10000);
	            		          SendClientMessage(playerid, -1, "Your health increased.");
				     }
        			     if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) < 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        		     {
					   SendClientMessage(playerid, -1, "Not enough money.");//Tell them.
				      }
        			      if(GetPlayerHealth(playerid) < 100 && GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] > 0)
	        		       {
         				    SetPlayerHealth(playerid, 99);
					    SendClientMessage(playerid, -1, "Your expenses was covered by health insurance.");
			    	        }
     				        if(GetPlayerHealth(playerid) > 99 && GetPlayerMoney(playerid) >= 10000)
	        		        {
					    SendClientMessage(playerid, -1, "You dont need this.");
			    	         }
				         }

				case 2:
				{
 					if(GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        		        {
	        	    	            GivePlayerMoney(playerid, -250);
	        	    	            PlayerInfo[playerid][pCondom] += 1;
	        	    	            SendClientMessage(playerid, -1, "Bought a condom.");
					 }
				 }
				case 4:
				{
 					if(GetPlayerMoney(playerid) >= 10000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        		        {
	        	    	              GivePlayerMoney(playerid, -10000);
	        	    	              PlayerInfo[playerid][pCondom] += 5;
	        	    	              SendClientMessage(playerid, -1, "Bought 5 condoms.");
					}
				}
				case 5:
				{
 					if(GetPlayerMoney(playerid) >= 5000 && PlayerInfo[playerid][pHealthInsurance] < 0)
	        		       {
	        	    	            GivePlayerMoney(playerid, -5000);
	        	    	            PlayerInfo[playerid][pCondom] += 1;
	        	    	            SendClientMessage(playerid, -1, "Bought viagra.");	        	    return 1;
					}
				}
			}
		}
 	return 1;
	}
Reply
#4

GetPlayerHealth shouldn't be used that way. Correct way:
PHP код:
new FloatHealth;
GetPlayerHealth(playeridHealth);
if(
Health 100...) 
Reply
#5

Quote:
Originally Posted by ranme15
Посмотреть сообщение
GetPlayerHealth shouldn't be used that way. Correct way:
PHP код:
new FloatHealth;
GetPlayerHealth(playeridHealth);
if(
Health 100...) 
I tried it. Result is the same. The problem is not only increasing health but also buying items. for example
Код:
PlayerInfo[playerid][pCondom] += 1;
doesnt work
Reply
#6

pawn Код:
if(dialogid == DIALOG_HOSPITAL)
    {
        if(response)
        {
            if(listitem == 0)
            {
                new Float:hp;
                GetPlayerHealth(playerid, hp);
                if(hp >= 99) return SendClientMessage(playerid, -1, "You don't need this.");
                if(PlayerInfo[playerid][pHealthInsurance])
                {
                    SetPlayerHealth(playerid, 99);
                    SendClientMessage(playerid, -1, "Your expenses were covered by health insurance.");
                }
                else
                {
                    if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, -1, "Not enough money.");
                    SetPlayerHealth(playerid, 99);
                    GivePlayerMoney(playerid, -10000);
                    SendClientMessage(playerid, -1, "Your health increased.");
                }
            }
        }
        return 1;
    }
There is nothing wrong with this code. If you are experiencing other issues, it is because you are not using the variables correctly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)