SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/03/2015, 07:08 PM   #1
TiXz0r
Big Clucker
 
Join Date: Nov 2013
Posts: 178
Reputation: 4
Default [HELP]How to reset variable

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
TiXz0r is offline   Reply With Quote
Old 04/03/2015, 07:09 PM   #2
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: [HELP]How to reset variable

pawn Code:
//1.
new value = 105;
if (value > 100) value = 100;

//2.
new value = 108;
value = clamp(value, 0, 100);
Misiur is offline   Reply With Quote
Old 04/03/2015, 07:53 PM   #3
TiXz0r
Big Clucker
 
Join Date: Nov 2013
Posts: 178
Reputation: 4
Default Re: [HELP]How to reset variable

Quote:
Originally Posted by Misiur View Post
pawn Code:
//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:

Code:
	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;
	}
TiXz0r is offline   Reply With Quote
Old 04/03/2015, 08:40 PM   #4
Lunoxx
Big Clucker
 
Join Date: Feb 2015
Posts: 54
Reputation: 0
Default Re: [HELP]How to reset variable

Here?
SetPlayerHealth(playerid, +7);

If so,
Quote:
new Float:Health;
GetPlayerHealth(playerid, Health);
if(Health < 94)
{
SetPlayerHealth(playerid, +7);
}
Lunoxx is offline   Reply With Quote
Old 04/03/2015, 09:11 PM   #5
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: [HELP]How to reset variable

pawn Code:
PlayerInfo[playerid][pSnaga] = clamp(PlayerInfo[playerid][pSnaga] + 7, 0, 100)
SetPlayerHealth(playerid, PlayerInfo[playerid][pSnaga]);
Misiur is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Global variable/direct reference works, local variable doesn't - format (y_va) Misiur Scripting Help 11 25/02/2014 11:43 AM
Variable reset Muhamed.pwn Scripting Help 0 19/06/2013 07:38 AM
Dynamic Variable Naming / Variable Variables / Indirect Variable Access Redgie Scripting Help 3 04/06/2012 07:32 PM
variable reset? +rep! PawnoQ Scripting Help 19 03/03/2012 05:06 PM
Variable reset baske007 Help Archive 4 24/07/2010 12:18 PM


All times are GMT. The time now is 02:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.