SA-MP Forums Archive
Value raises every second? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Value raises every second? (/showthread.php?tid=79283)



Value raises every second? - SiJ - 27.05.2009

Hey,
If I have line like this:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
This line is only for example
How can I do so i value would raise by 1 every one second?




Re: Value raises every second? - member - 27.05.2009

I didn't use the line you gave but something simple like this?
pawn Код:
#define MAX_NUMBER 200 //change to the max number so number starts recounting from 0
new Number = 0;

SetTimer("IncreaseNumber",1000, true);

public IncreaseNumber()
{
    if(Number >= MAX_NUMBER)Number = 0;
    else Number++;
}



Re: Value raises every second? - SiJ - 27.05.2009

Quote:
Originally Posted by [B2K
Hustler ]
I didn't use the line you gave but something simple like this?
pawn Код:
#define MAX_NUMBER 200 //change to the max number so number starts recounting from 0
new Number = 0;

SetTimer("IncreaseNumber",1000, true);

public IncreaseNumber()
{
    if(Number >= MAX_NUMBER)Number = 0;
    else Number++;
}
Thanks for help..
BTW you missed one line: forward IncreaseNumber();


Re: Value raises every second? - lol2112 - 27.05.2009

Quote:

BTW you missed one line: forward IncreaseNumber();

lol cheeky. I think he was just showing you how to do it, not writing the whole thing for you.


Re: Value raises every second? - SiJ - 27.05.2009

Quote:
Originally Posted by lol2112
Quote:

BTW you missed one line: forward IncreaseNumber();

lol cheeky. I think he was just showing you how to do it, not writing the whole thing for you.
If I would be worse scripter, I would ask him for more help because Timer won't work without that line


Re: Value raises every second? - SiJ - 27.05.2009

Quote:
Originally Posted by [B2K
Hustler ]
I didn't use the line you gave but something simple like this?
pawn Код:
#define MAX_NUMBER 200 //change to the max number so number starts recounting from 0
new Number = 0;

SetTimer("IncreaseNumber",1000, true);

public IncreaseNumber()
{
    if(Number >= MAX_NUMBER)Number = 0;
    else Number++;
}
It doesn't work :\

I use it like this:
pawn Код:
#define MAX_TIMER 200

new TutTime = 0;
new TimerOfTut; //For killing timer when tutorial is ended

public TutTimer()
{
    if(TutTime >= MAX_TIMER)TutTime = 0;
    else TutTime++;
}

TimeOfTut = SetTimer("TutTimer",1000,true); // I tried without TimeOfTut - still doesn't work

if (TutTime == 0)
                {
                    SystemMsg(playerid,"Welcome to San Fierro!");
                                       
                }
                if (TutTime == 7)
                {
                    SystemMsg(playerid," ");
                    SystemMsg(playerid," ");
                }
                if (TutTime == 10)
                {
                    SystemMsg(playerid,"This is a RolePlay server which means you have to act like in real life.");
                    KillTimer(TimerOfTut);
                }
What's wrong with this.....
(It compiles without errors....)


Re: Value raises every second? - lol2112 - 27.05.2009

Код:
new count;

for(new i = 0; i < MAX_PLAYERS && tickcount() - count == 1000; i++)
{
     Do whatever
     count = tickcount();
}
I really don't know if this will work or if it's even the best way to do it. Worth a shot.


Re: Value raises every second? - SiJ - 27.05.2009

Quote:
Originally Posted by lol2112
Код:
new count;

for(new i = 0; i < MAX_PLAYERS && tickcount() - count == 1000; i++)
{
     Do whatever
     count = tickcount();
}
I really don't know if this will work or if it's even the best way to do it. Worth a shot.
I'll try it tomorow. People, if somone knows more ways to do it, post...
Thanks, and see you all tomorow.....


Re: Value raises every second? - SiJ - 27.05.2009

Quote:
Originally Posted by lol2112
Код:
new count;

for(new i = 0; i < MAX_PLAYERS && tickcount() - count == 1000; i++)
{
     Do whatever
     count = tickcount();
}
I really don't know if this will work or if it's even the best way to do it. Worth a shot.
It doesn't work..
I'll try to do something with the first code given by Hustler...


Re: Value raises every second? - SiJ - 28.05.2009

anybody? ...........
I would be really thankful to you for this...