#1

Hi. i'm creating /weapons command. When round starts 30 sec this command gona work, after 30sec gona dont work
But i've have some problems, the /weapons command is working all time -.-
Can somebody help me?
This is my code:

Код:
new canuseguns;

----------------------------

  if (strcmp("/weapons", cmdtext, true, 10) == 0)
  {
  if ( canuseguns == 1 ) ResetPlayerWeapons(playerid), ShowMenuForPlayer(WEAP1, playerid);
  return 1;
  }

-----------------------


  canuseguns = 1;
	SetTimer("canuseguns = 0;",10000,false);
Reply
#2

For starters 30 seconds is 30000, 1 second = 1000.

What exactly do you want the command to do? Reset their weapons and show a menu?
Reply
#3

Quote:
Originally Posted by V1ceC1ty
For starters 30 seconds is 30000, 1 second = 1000.

What exactly do you want the command to do? Reset their weapons and show a menu?
Yes, i'm making this command, for starting round and when you select guns from menu, you can change it on 30sec
I want that /weapons command show menu, but when 30 sec going out, /weapons command doesn't work.
So i want that /weapons command don't work any more after 30sec
Reply
#4

Can someone help? -_-
Reply
#5

You use timers in wrong way.
https://sampwiki.blast.hk/wiki/SetTimer
Reply
#6

pawn Код:
//tos
new
  gRoundStartTime = 0;

//round starts
gRoundStartTimer = gettime();

//weapon command
if ( ( gettime() - gRoundStartTime ) < 30 )
{
  //give weapon or whatever the command does
}
else
{
  //30 seconds has passed deny them the weapon (message or whatever)
}
No need for a timer as the round start time never changes, only the time they used the command does so we only need to check the period from the start to the current and react accordingly to it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)