/jailtime Problem
#1

Код:
  if(strcmp("/jailtime",cmdtext,true) == 0)
{
format(string,sizeof(string)," %d Minutes",PlayerData[playerid][PrisonTime]);
SetTimerEx("JailTime",PlayerData[playerid][PrisonTime]*60000,0,"i",playerid);
SendClientMessage(playerid,WHITE,string);
return 1;
}
It says only how long, I jailed him 5minutes, I want it should go down like I jailed some one 5 minutes, he checks after 1 minute /jailtime and it should say 4min, any tips how to make it ?
Reply
#2

something like this here: (i think when u use exacly my code it wont work, but i just want to show you )

Код:
if(strcmp("/jail",cmdtext,true) == 0)
{

new tmp[128];
tmp = strtok(cmdtext, idx);

new tmp2[128];
tmp2 = strtok(cmdtext, idx);

//<----Then here the timer......

new JHour, JMin, JSec;

gettime(JHour, JMin, JSec);


SetPlayerPos(strval(tmp), JAIL X, JAIL Y, JAIL Z);
return JHour, JMin, JSec;
}


if(strcmp("/jailtime",cmdtext,true) == 0)
{
new Hour, Min, Sec;
new Rhour, Rmin, Rsec;

gettime(Hour, Min, Sec);
Rhour=JHour-Hour;
Rmin=JMin-Min;
Rsec=JSec-Sec;

new string[128];
format(string,sizeof(string)," %i Hours, %i Minutes and %i Seconds left!",Rhour, Rmin, Rsec);
SendClientMessage(playerid,WHITE,string);
}
.....
I'm not sure if it works, i hope so, but i cannot check, cuz my compiler is broken at the moment XD... it could be that it gives you at Rsec and Rmin a negative value, but i guess you will be able to solve that by urself within using "<" and ">"... I hope my code is not tooooo broken for you to use :S... But i did my best and hope it helped you out a bit.

Best wishes, DeathOnaStick


(by the way, im not even sure if you can use gettime for that, if not, you have to set a timer, which counts every second, which is passed during the server is online, and work on this basic, like i did with gettime.)
Reply
#3

You can give this a try, should work.

Код:
//====

//forward
OneMinTimer();

//GameModeInit
SetTimer("OneMinTimer", 60000, true);

public OneMinTimer()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerData[i][PrisonTime] > 0)
      {
        PlayerData[i][PrisonTime] -= 1;
			}
		}
	}
	return 1;
}


if(strcmp("/jailtime",cmdtext,true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
	  if(PlayerData[playerid][PrisonTime] == 0)
	  {
	    SendClientMessage(playerid, WHITE, "You are not in Jail");
	    return 1;
		}
		format(string,sizeof(string)," %d Minutes",PlayerData[playerid][PrisonTime]);
		SendClientMessage(playerid,WHITE,string);
	}
	return 1;
}
Reply
#4

Quote:
Originally Posted by JR !
You can give this a try, should work.

Код:
//====

//forward
OneMinTimer();

//GameModeInit
SetTimer("OneMinTimer", 60000, true);

public OneMinTimer()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerData[i][PrisonTime] > 0)
      {
        PlayerData[i][PrisonTime] -= 1;
			}
		}
	}
	return 1;
}


if(strcmp("/jailtime",cmdtext,true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
	  if(PlayerData[playerid][PrisonTime] == 0)
	  {
	    SendClientMessage(playerid, WHITE, "You are not in Jail");
	    return 1;
		}
		format(string,sizeof(string)," %d Minutes",PlayerData[playerid][PrisonTime]);
		SendClientMessage(playerid,WHITE,string);
	}
	return 1;
}

Can you not do it like everyone it should go down, if i jail some one 5 minutes after 1 minutes he use /jailtime and it shows 4 mins you script only shows how long I jailed him
Reply
#5

Quote:
Originally Posted by [LSB
Erkan ]
Quote:
Originally Posted by JR !
You can give this a try, should work.

Код:
//====

//forward
OneMinTimer();

//GameModeInit
SetTimer("OneMinTimer", 60000, true);

public OneMinTimer()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(PlayerData[i][PrisonTime] > 0)
      {
        PlayerData[i][PrisonTime] -= 1;
			}
		}
	}
	return 1;
}


if(strcmp("/jailtime",cmdtext,true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
	  if(PlayerData[playerid][PrisonTime] == 0)
	  {
	    SendClientMessage(playerid, WHITE, "You are not in Jail");
	    return 1;
		}
		format(string,sizeof(string)," %d Minutes",PlayerData[playerid][PrisonTime]);
		SendClientMessage(playerid,WHITE,string);
	}
	return 1;
}

Can you not do it like everyone it should go down, if i jail some one 5 minutes after 1 minutes he use /jailtime and it shows 4 mins you script only shows how long I jailed him
Any Ideas ?
Reply
#6

Basically what I gave you is a timer, that takes of a minute every 60 seconds.. and when the player does /jailtime it will show how long they have left in Jail... no matter how long into the jail time they check.

How do you want it?
Reply
#7

That with minute does not even work, can you try to make with seconds ?
Reply
#8

bump
Reply
#9

bump any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)