Value raises every second?
#1

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?

Reply
#2

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++;
}
Reply
#3

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();
Reply
#4

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.
Reply
#5

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
Reply
#6

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....)
Reply
#7

Код:
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.
Reply
#8

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.....
Reply
#9

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...
Reply
#10

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


Forum Jump:


Users browsing this thread: 4 Guest(s)