SA-MP Forums Archive
[HELP]How to reset variable - 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: [HELP]How to reset variable (/showthread.php?tid=566270)



[HELP]How to reset variable - TiXz0r - 04.03.2015

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


Re: [HELP]How to reset variable - Misiur - 04.03.2015

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

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



Re: [HELP]How to reset variable - TiXz0r - 04.03.2015

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;
	}



Re: [HELP]How to reset variable - Lunoxx - 04.03.2015

Here?
SetPlayerHealth(playerid, +7);

If so,
Quote:

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




Re: [HELP]How to reset variable - Misiur - 04.03.2015

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