Drive Thru
#1

Hello once again SAMP playing people!!!

I need some help. Well today I made a drive thru dialog and all is actually pretty good, I did it so that if someone buys some item from the menu he gets +50 hp but the problem is, if the players will buy like 5 random things their hp wont stop to grow and it will continue growing, so players might abuse, So im wondering how to make it so that when player got 100 % of his hp, other food that player will buy wont actually give him more hp.

Thank you.

Here is one item from the Dialog, so you will know how it looks now:

Код:
if(listitem == 1)// 'Chicken Burger'
			{
				GetPlayerHealth(playerid, health);
  				SetPlayerHealth(playerid, health +50.0);
                                GivePlayerMoney(playerid, - 10);
                                TogglePlayerControllable(playerid,1);
			}
Reply
#2

pawn Код:
if(listitem == 1)// 'Chicken Burger'
            {
                GetPlayerHealth(playerid, health);
                health = (health+50);
                if(health > 100) SetPlayerHealth(playerid, 100);
                else SetPlayerHealth(playerid, health );//Removed the +50 from this line since the health variable has already gotten 50 added to it, it was then adding a hundred, sorry
                GivePlayerMoney(playerid, - 10);
                TogglePlayerControllable(playerid,1);
            }
this should work, i didnt test it just typed it in the reply box
Reply
#3

Yes, thank you that problem is solved but now there is another problem, every item I buy from the dialog sets your hp to 100 and not to 50 like I need, but atleast now the HP dosent go over 100.
Reply
#4

I edited my post, should work now
Reply
#5

Код:
if(listitem == 1)// 'Chicken Burger'
			{
				GetPlayerHealth(playerid, health);
				health = (health+50);
				if(health > 100) SetPlayerHealth(playerid, +50);
  				else SetPlayerHealth(playerid, health );//Removed the +50 from this line since the health variable has already gotten 50 added to it, it was then adding a hundred, sorry
				GivePlayerMoney(playerid, - 10);
				TogglePlayerControllable(playerid,1);
			}
Reply
#6

Quote:
Originally Posted by geerdinho8
Посмотреть сообщение
Код:
if(listitem == 1)// 'Chicken Burger'
			{
				GetPlayerHealth(playerid, health);
				health = (health+50);
				if(health > 100) SetPlayerHealth(playerid, +50);
  				else SetPlayerHealth(playerid, health );//Removed the +50 from this line since the health variable has already gotten 50 added to it, it was then adding a hundred, sorry
				GivePlayerMoney(playerid, - 10);
				TogglePlayerControllable(playerid,1);
			}
really.. your gonna repost my post and not give me credit?
Reply
#7

This will work correctly. Hopefully.

pawn Код:
if(listitem == 1)// 'Chicken Burger'
            {
                new Float:HP; GetPlayerHealth(playerid, HP);
                if(HP >= 50.0) { SetPlayerHealth(playerid, 100.0); }
                else { SetPlayerHealth(playerid, HP+50.0); }
                GivePlayerMoney(playerid, -10);
                TogglePlayerControllable(playerid, true);
            }
Reply
#8

Quote:
Originally Posted by dowster
Посмотреть сообщение
really.. your gonna repost my post and not give me credit?
credits?

because you added 2 new lines?

And btw, i changed it.
If his health was below 100, it would give him always 100 hp if he bought it.

So:

Player has 1 health.
Player Buys a meal.
Player has 100 health.

My code:

Player has 1 health.
Player Buys a meal.
Player has 51 health.
Reply
#9

Quote:
Originally Posted by geerdinho8
Посмотреть сообщение
credits?

because you added 2 new lines?

And btw, i changed it.
If his health was below 100, it would give him always 100 hp if he bought it.

So:

Player has 1 health.
Player Buys a meal.
Player has 100 health.

My code:

Player has 1 health.
Player Buys a meal.
Player has 51 health.
1. You just happened to type the exact same comment where i typed mine?
2. if they had one health they would actually end up with 101 health due to the extra +50 i had.
3. You clearly copy and pasted straight from what i did, all you changed was you used [code] instead of [pawn]
Reply
#10

Quote:
Originally Posted by dowster
Посмотреть сообщение
1. You just happened to type the exact same comment where i typed mine?
2. if they had one health they would actually end up with 101 health due to the extra +50 i had.
3. You clearly copy and pasted straight from what i did, all you changed was you used [code] instead of [pawn]
Then i guess we were same minded.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)