How to change the value of a Global Variable from an if statement -
Matteos - 26.01.2016
How could I change the value of 'variable hossz' by an if statement? I tried hossz += 1; but that's not working.
Please help me, it would be so important, these are the last steps of a bigger work of mine.
Thank you!
---------------------------------------------------------------
new gombErtekeToString[18];
new hossz = 0;
if(clickedid == szam0)
{
if (hossz >= 1) {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
strcat(gombErtekeToString, "0");
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
} else {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
hossz += 1;
}
}
-----------------------------------------------------------------------------------------------------------
Re: Change the value of a Global Variable from an if statement -
Untonyst - 26.01.2016
How did you check the value of a variable?
Re: Change the value of a Global Variable from an if statement -
Matteos - 26.01.2016
Why should I check it? I just try to change the value of it. Value of hossz is 0 and I'd like to change it to 1 by the 'else' part. Actually I tried everything what i could imagine. I hope someone could tell me the solution of this.
Re: Change the value of a Global Variable from an if statement - TheLegend1 - 26.01.2016
Код HTML:
new gombErtekeToString[18];
new hossz = 0;
if(clickedid == szam0)
{
if (hossz >= 1) {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
strcat(gombErtekeToString, "0");
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
} else {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
hossz += 1;
}
}
PHP код:
new gombErtekeToString[18];
new hossz = 0;
if(clickedid == szam0)
{
if (hossz >= 0) {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
strcat(gombErtekeToString, "0");
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
} else {
format(gombErtekeToString, sizeof(gombErtekeToString), "0" );
TextDrawSetString(szampanel, gombErtekeToString);
TextDrawShowForPlayer(playerid, szampanel);
hossz += 1;
}
}
i didnt really get what you wrote btw hope this works
Re: Change the value of a Global Variable from an if statement -
Matteos - 26.01.2016
I have a TextDraw, like a cellphone with numbered buttons 0-9 and stuffs like that. And I created a TextDraw which should show the value of the pressed button. This part is the button 0. Now if i press 0, it appears on the "screen" but if I press another button for example 2, it change the number to 2. But it should show 02 and so on like how I press the buttons.
The 'if' part make a 0 after a pressed button. The else part should be for if yet theres no value on the screen, then show 0 and does nothing after it. But I have to change the value of the hossz variable to 1 for shows a 2nd 0 and not replace it to one 0 again.