SA-MP Forums Archive
Timer issue. - 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: Timer issue. (/showthread.php?tid=94448)



Timer issue. - [LSB]Clinz - 29.08.2009

Yeah, so I've been working on using timers and I'll admit, I'm totally useless when it comes to the more advanced timer use. So all I'd like to do is when I use /jail, it'll store their amount of minutes into a variable which can be used to be shown on a command and will decrease every minute. Here's my code;

Код:
if(strcmp(cmd, "/jail", true) == 0)
  {
    if(IsPlayerConnected(playerid))
    {
     tmp = strtok(cmdtext, idx);
     if(!strlen(tmp))
     {
      SendClientMessage(playerid, COLOR_RED, "USAGE: /jail [ID] [Minutes] [Reason]");
      return 1;
     }
     new playa;
     new money;
     playa = strval(tmp);
     tmp = strtok(cmdtext, idx);
 			if(PlayerData[playerid][Admin] < 3) return SendClientMessage(playerid, RED, "SERVER MESSAGE: You are not admin level 3.");
			{
       if(IsPlayerConnected(playa))
       {
         if(playa != INVALID_PLAYER_ID)
         {
      	 new otherplayer = strval(tmp);
new length = strlen(cmdtext);
	while ((idx < length) && (cmdtext[idx] <= ' '))
	{
	idx++;
	}
	new offset = idx;
	new result[64];
	while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
	{
	result[idx - offset] = cmdtext[idx];
	idx++;
	}
	result[idx - offset] = EOS;
   			 GetPlayerName(playa, giveplayer, sizeof(giveplayer));
         GetPlayerName(playerid, sendername, sizeof(sendername));
         if(PlayerData[playerid][onduty] == 0) return SendClientMessage(playerid, RED, "Your not on Administration duty!");
 		 	   if(PlayerData[playerid][Admin] < PlayerData[otherplayer][Admin]) return SendClientMessage(playerid, RED, "You can't use this command on higher level Admins than yourself!");
         format(string, sizeof(string), "*Administrator %s jailed %s for %d minutes – [Reason: %s]", sendername,giveplayer,PlayerData[playa][PrisonTime],result);
         SendClientMessageToAll(COLOR_RED1, string);
         ResetPlayerWeapons(playa);
         PlayerData[playa][Prison] = 1;
         GameTextForPlayer(playa, "~r~Admin Jailed", 3000, 3);
         SetPlayerInterior(playa, 6);
         SetPlayerPos(playa, 264.6288,77.5742,1001.0391);
         format(string, sizeof(string), "You are jailed for %d minutes – Reason: %s", PlayerData[playa][PrisonTime],result);
         SendClientMessage(playa, COLOR_RED1, string);
					PlayerData[playa][PrisonTime] = money*60000;
					SetTimerEx("JailTimerPassing",60000,1,"-",playa);
				}
      }
     }
   }
   return 1;
  }
I apologize for the terrible indentation but I can't help it. Anyhow, I'd appreciate any help here as I don't have a clue what I'm doing here.


Re: Timer issue. - Weirdosport - 29.08.2009

SetTimerEx("JailTimerPassing",60000,1,"-",playa);

Not sure what made you put "-", but if "playa" is the playerid (integer) you need "i".


Re: Timer issue. - [LSB]Clinz - 29.08.2009

Alright thanks, I'll try that. As I said, I didn't really know what that was so I took a guess with that really as I'm useless with timers.


Re: Timer issue. - Backwardsman97 - 29.08.2009

I would very much suggest dcmd and sscanf.


Re: Timer issue. - Erkan - 29.08.2009

Quote:
Originally Posted by Weirdosport
SetTimerEx("JailTimerPassing",60000,1,"-",playa);

Not sure what made you put "-", but if "playa" is the playerid (integer) you need "i".
We tryed this it did not work.


Re: Timer issue. - Erkan - 30.08.2009

Sorry for bumping, but it works now the only problem it, it unjails me automaticly every one minute :S.

Код:
public JailTimerPassing(playerid)
{
	new string[256];
	new playrname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playrname, sizeof(playrname));
	SetPlayerWorldBounds(playerid,20000.0000,-20000.0000,20000.0000,-20000.0000);
	PlayerData[playerid][Prison] = 0;
	PlayerData[playerid][PrisonTime] = 0;
	SetPlayerArmour(playerid, 0);
	SetPlayerInterior(playerid,0);
	format(string, sizeof(string), "%s was unjailed automatically (Times Up).", playrname);
	SendClientMessageToAll(RED, string);
	SetPlayerPos(playerid,1480.9805,-1770.7013,18.7958);
}