Can you guys help me add a timer
#1

Can someone help me add a timer to my rob command? It already has a timer of 10 seconds you have to wait in the checkpoint until the robbery is complete, but it does not display the actual time which is what i need, but have no idea how to do

So the time should display 10, 9, 8 , 7 , etc etc 2, 1, then display


//rob command

Код:
if(strcmp(cmdtext, "/robvictim", true) == 0)
	{
	if(IsSpawned[playerid] == 0) {
	SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
  return 1;
  }
  if(Jailed[playerid] == 1) {
	SendClientMessage(playerid, COLOR_ERROR, "You are in jail. You cannot use this command");
  return 1;
  }
  if(cuffed[playerid] == 1) {
	SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while you are handcuffed");
  return 1;
  }
	if (!IsPlayerInDynamicCP(playerid, gCheckpoint[4])){
  SendClientMessage(playerid,COLOR_ERROR,"You are not in a victim checkpoint");
  return 1;
  }
  if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_ARMY || gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_CASSEC || gTeam[playerid] == TEAM_JAILTK) {
	SendClientMessage(playerid,COLOR_ERROR,"Law Enforcement agents cannot use that command!");
	return 1;
 	}
 	TogglePlayerDynamicCP(playerid, 4, true);
  {
  if(Victimrobbedrecent >= 1) {
  SendClientMessage(playerid,COLOR_ERROR,"Victim has been robbed recently");
	return 1;
 	}
 	new Victimrand = random(100);
 	if(Victimrand >=0 && Victimrand <=10) {
 	SendClientMessage(playerid, 0xA9A9A9AA, "|_Victim Robbery Failed_|");
 	SendClientMessage(playerid,COLOR_ERROR,"Your attempt to rob Victim has failed");
 	return 1;
 	}
  if(Victimrand >=11 && Victimrand <=100)
	{
    new Victimrobbber[30];
    new pcol = GetPlayerColor(playerid);
    GetPlayerName(playerid,Victimrobbber,30);
    new plwl = GetPlayerWantedLevel(playerid);
	  SetPlayerWantedLevel(playerid, plwl +4);
		robbingVictim[playerid] =15;
		SendClientMessage(playerid,0x00C7FFAA,"You are now robbing Victim. The Police have been dispatched and will be on route right now");
		SendClientMessage(playerid,0x00C7FFAA,"Stay in the checkpoint to complete the robbery...");
		plwl = GetPlayerWantedLevel(playerid);
		Victimrobbedrecent = 140;
		SendClientMessage(playerid, 0xA9A9A9AA, "|_Crime Commited_|");
		format(szstring, sizeof(szstring), "(Victim ROBBERY) Wanted Level %d",plwl);
		SendClientMessage(playerid,pcol,szstring);
		commitedcrimerecently[playerid] +=120;
		printf("%s(%d) has started a Victim robbery",Victimrobbber,playerid);
		for(new i=0;i<MAX_PLAYERS;i++)
		{
    if(LawEnforcementRadio[i] == 1) {
    new szstring1[256];
    new szstring2[256];
		format(szstring1, sizeof(szstring1), "DISPATCH: (ROBBERY IN PROGRESS) Suspect: %s(%d)",Victimrobbber,playerid);
		format(szstring2, sizeof(szstring2), "ALL UNITS: Please respond to DS and arrest %s(%d)",Victimrobbber,playerid);
		SendClientMessage(i, COLOR_ROYALBLUE, szstring1);
		SendClientMessage(i, COLOR_ROYALBLUE, szstring2);
	  }
	  }
	  }
	  }
		return 1;
 	}
//rob command countdown

Код:
public Victimcountdown(playerid)
{
  for(new i=0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(robbingVictim[i] >= 2)
      {
				robbingVictim[i] --;
        	format(szstring, sizeof(szstring), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT");
        GameTextForPlayer(i, szstring, 2000,3);
			}
			if(robbingVictim[i] == 1)
      {
        new robbingVictimrand = random(150000);
				robbingVictim[i] =0;
				new Victimrobbber[30];
        new pcol = GetPlayerColor(i);
        GetPlayerName(i,Victimrobbber,30);
        format(szstring, sizeof(szstring), "%s(%d) Has robbed $%d from Victim",Victimrobbber,i,robbingVictimrand);
        SendClientMessageToAll(0x00C7FFAA,szstring);
        format(szstring, sizeof(szstring), "~b~VICTIM~n~~y~ROBBERY COMPLETE~n~~w~$%d",robbingVictimrand);
        GameTextForPlayer(i, szstring, 5000,3);
        GivePlayerMoney(i,robbingVictimrand);
        oscore = GetPlayerScore(playerid);
  			SetPlayerScore(playerid, oscore +1);
        format(szstring, sizeof(szstring), "Victim Robbery Complete. You robbed a total of $%d",robbingVictimrand);
        SendClientMessage(i,pcol,szstring);
        if(robberrank[i] <=39) {
  			SendClientMessage(i,COLOR_WHITE,"Your robbing skill level has been increased. Type /robskill for more info");
  			robberrank[i] +=1;
				}
        printf("%s(%d) has robbed $%d in a Victim Robbery",Victimrobbber,i,robbingVictimrand);
			}

		}
	}
}
//robbing the store timer

Код:
SetTimer("Victimcountdown",1000,1);
Reply
#2

Anyone know?
Reply
#3

What do you mean? display the time on the screen?
Reply
#4

Quote:
Originally Posted by [GM
LeGenDy ]
What do you mean? display the time on the screen?
Yes
Reply
#5

anyone? please help
Reply
#6

just a thought and a rough guide:

Код:
new robtime;

/robvictim
robtime = 10;
SetTimer("countdown", 1000, 10);


forward countdown();
public countdown(){
if(robtime == 0){
SendClientMessage(playerid, COLOR, "Robbery complete");
}
else{
format(string, sizeof(string), "%d", robtime);
SendClientMessage(playerid, COLOR, string);
return robtime--;
}
return 1;
}
fit it in as and where necessary but hopefully that should sent 10 messages
Reply
#7

I don't understand where to fill that in......I'm not that good at scripting yet....Can someone help me? I need help with adding a countdown that is visible. I already have a timer countdown but i need it to be visible
Reply
#8

pawn Код:
format(szstring, sizeof(szstring), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT");
change it to

pawn Код:
format(szstring, sizeof(szstring), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT~n~~b~%i", robbingVictim[i]);
Reply
#9

Quote:
Originally Posted by MadeMan
pawn Код:
format(szstring, sizeof(szstring), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT");
change it to

pawn Код:
format(szstring, sizeof(szstring), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT~n~~b~%i", robbingVictim[i]);
Ok, i replaced it, but nothing happens.......... still same thing no number is displayed. (that is the only thing i added) the other guy that told me to do that stuff, that code is not in my script
Reply
#10

Try this one

pawn Код:
if(robbingVictim[i] >= 2)
            {
                new str[128];
                robbingVictim[i] --;
                format(str, sizeof(str), "~y~ROBBERY IN PROGRESS~n~~r~STAY IN THE CHECKPOINT~n~~b~%i", robbingVictim[i]);
                GameTextForPlayer(i, str, 2000,3);
            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)