[HELP]How to reset variable
#1

Hello.


How to make this:

I have happy system. I want make, when have 98% and when get sometnih what give him 10%, set him 100% not 108%.

Thanks
Reply
#2

pawn Код:
//1.
new value = 105;
if (value > 100) value = 100;

//2.
new value = 108;
value = clamp(value, 0, 100);
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
//1.
new value = 105;
if (value > 100) value = 100;

//2.
new value = 108;
value = clamp(value, 0, 100);
thanks for answer.

how to use it on:

Код:
	if(dialogid == DIALOG_FOODKIOSK)
	{
    if(response)
    {
	if(listitem == 0)
	{
    if(GetPlayerCash(playerid) < 30) return SCM(playerid, COLOR_GREEN, "[PRODAVAC]: "COL_WHITE"Nemate dovoljno novaca. Hotdog kosta 3$.");
    if(PlayerInfo[playerid][pSnaga] == 100) return SCM(playerid, COLOR_GREEN, "[ZIVOT]: "COL_WHITE"Ne mozete vise jesti.");

    SendClientMessage(playerid, COLOR_GREEN, "[PRODAVAC]: "COL_WHITE"Kupili ste hotdog. Dobar tek.");
    GivePlayerCash(playerid, -3);
    PlayerInfo[playerid][pSnaga] += 7;
    SetPlayerHealth(playerid, +7);
	}
	
	//
    }
    return 1;
	}
Reply
#4

Here?
SetPlayerHealth(playerid, +7);

If so,
Quote:

new Float:Health;
GetPlayerHealth(playerid, Health);
if(Health < 94)
{
SetPlayerHealth(playerid, +7);
}

Reply
#5

pawn Код:
PlayerInfo[playerid][pSnaga] = clamp(PlayerInfo[playerid][pSnaga] + 7, 0, 100)
SetPlayerHealth(playerid, PlayerInfo[playerid][pSnaga]);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)