Timer! HELP!
#1

At top of script:
Код:
forward time();
then
Код:
if (!strcmp("/testtimer", cmdtext, true))
	{
	SetTimer("time",10000,0);
	return 1;
	}
and then
Код:
public time()
{
SendClientMessageToAll(COLOR_GREEN,"IT'S WORKING!!!");
}
It works, 10 seconds pass and text "IT'S WORKING!!!" appears. But how to do that every second will show at chat window ? 1...2...3....4....5.....6....7.....8....9....10. IT'S WORKING!!!
I read posts in forum, information in sa-mp wiki but dont found anything what will help me
Please, help!
Reply
#2

if you mean you want it to repeat every 10 seconds then add a 1 to the end
Код:
if (!strcmp("/testtimer", cmdtext, true))
	{
	SetTimer("time",10000,1);
	return 1;
	}
now every 10 seconds it will call the time function
Reply
#3

pawn Код:
new timepassed = -1;
new timeTimer;

forward time();

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp(cmdtext, "/testtimer", true) == 0)
  {
    timepassed = -1;
    time();
    timeTimer = SetTimer("time", 1000, 1);
    return 1;
  }
  return 0;
}

public time()
{
  if (timepassed == 0)
  {
    SendClientMessageToAll(COLOR_GREEN, "IT'S WORKING!!!");
    timepassed = -1;
    KillTimer(timeTimer);
  }
  else
  {
    new str[128];
    format(str, sizeof(str), "%d...", timepassed);
    SendClientMessageToAll(COLOR_GREEN, str);
    timepassed--;
  }
}
Untested
Reply
#4

Quote:
Originally Posted by !MaVe
pawn Код:
new timepassed = -1;
new timeTimer;

forward time();

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp(cmdtext, "/testtimer", true) == 0)
  {
    timepassed = -1;
    timeTimer();
    timeTimer = SetTimer("time", 1000, 1);
    return 1;
  }
  return 0;
}

public time()
{
  if (timepassed == 0)
  {
    SendClientMessageToAll(COLOR_GREEN, "IT'S WORKING!!!");
    timepassed = -1;
    KillTimer(timeTimer);
  }
  else
  {
    new str[128];
    format(str, sizeof(str), "%d...", time);
    SendClientMessageToAll(COLOR_GREEN, str);
    timepassed--;
  }
}
Untested
Код:
C:\Documents and Settings\Andrius\Desktop\Best Driver\gamemodes\turnyrasV1.pwn(175) : error 012: invalid function call, not a valid address
C:\Documents and Settings\Andrius\Desktop\Best Driver\gamemodes\turnyrasV1.pwn(175) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Andrius\Desktop\Best Driver\gamemodes\turnyrasV1.pwn(175) : warning 215: expression has no effect
C:\Documents and Settings\Andrius\Desktop\Best Driver\gamemodes\turnyrasV1.pwn(193) : error 076: syntax error in the expression, or invalid function call
175 line:
Код:
    timeTimer();
and
193 line;
Код:
    format(str, sizeof(str), "%d...", time);
:/
Reply
#5

Код:
#include <a_samp>
new abc = 0;
new lol;

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/testtimer", cmdtext, true))
	{
		lol = SetTimer("time",1000,1);
		return 1;
	}
	return 0;
}

forward time();
public time(){
  abc++;
	if(abc == 11){
	SendClientMessageToAll(0x33AA33AA,"IT'S WORKING!!!");
	KillTimer(lol);
	abc = 0;
	}else{
 	new str[128];
 	format(str, sizeof(str), "%d...", abc);
 	SendClientMessageToAll(0x33AA33AA, str);
 	}
}
Reply
#6

pawn Код:
new timepassed = -1;
new timeTimer;

forward time();

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp(cmdtext, "/testtimer", true) == 0)
  {
    timepassed = -1;
    time();
    timeTimer = SetTimer("time", 1000, 1);
    return 1;
  }
  return 0;
}

public time()
{
  if (timepassed == 0)
  {
    SendClientMessageToAll(COLOR_GREEN, "IT'S WORKING!!!");
    timepassed = -1;
    KillTimer(timeTimer);
  }
  else
  {
    new str[128];
    format(str, sizeof(str), "%d...", timepassed);
    SendClientMessageToAll(COLOR_GREEN, str);
    timepassed--;
  }
}
Try this
Reply
#7

Quote:
Originally Posted by Jefff
Код:
#include <a_samp>
new abc = 0;
new lol;

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/testtimer", cmdtext, true))
	{
		lol = SetTimer("time",1000,1);
		return 1;
	}
	return 0;
}

forward time();
public time(){
  abc++;
	if(abc == 11){
	SendClientMessageToAll(0x33AA33AA,"IT'S WORKING!!!");
	KillTimer(lol);
	abc = 0;
	}else{
 	new str[128];
 	format(str, sizeof(str), "%d...", abc);
 	SendClientMessageToAll(0x33AA33AA, str);
 	}
}
This works, thats what i need =]

And now other thing :}
For example script is counting and on 5.. i write /stoptimer text apeears in chat window "Timer sopped at 5 seconds", how to make that?
Reply
#8

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/testtimer", cmdtext, true))
	{
		lol = SetTimer("time",1000,1);
		return 1;
	}
	if (!strcmp("/stopcd", cmdtext, true))
	{
	KillTimer(lol);
	new string[128];
	format(string,sizeof(string),"SERVER: Timer stopped at %d seconds", abc);
	SendClientMessageToAll(0x33AA33AA,string);
	abc=0;
	return 1;
	}
	return 0;
}
:P
Reply
#9

Quote:
Originally Posted by Dreftas
And now other thing :}
For example script is counting and on 5.. i write /stoptimer text apeears in chat window "Timer sopped at 5 seconds", how to make that?
pawn Код:
if (strcmp(cmdtext, "/stoptimer", true) == 0)
{
  KillTimer(lol);
  new str[128];
  format(str, sizeof(str), "Timer stopped at %d seconds.", abc);
  abc = 0;
  SendClientMessageToAll(COLOR_GREEN, str);
  return 1;
}
Reply
#10

Thx a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)