10.02.2010, 19:59
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
//rob command countdown
//robbing the store timer
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;
}
Код:
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);
}
}
}
}
Код:
SetTimer("Victimcountdown",1000,1);

