Increasing the Jail time per wanted level
#1

Ive managed to code a arrest command and had it working when it was just set to one specific time, which is to low for a 6 star wanted level.

Quote:

if(strcmp(cmd, "/arrest", true)==0) {

if (gTeam[playerid] == TEAM_COP) {
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arrest [ID]");
return 1;
}
new pid = strval(tmp);

if (IsPlayerConnected(pid))
{

new String [256];
new pName[MAX_PLAYER_NAME];
new copname[MAX_PLAYER_NAME];
GetPlayerName(pid, pName, sizeof(pName));
GetPlayerName(playerid, copname, sizeof(copname));
format(String, sizeof(String), "[ATTENTION OFFICERS] %s has been arrested by Officer %s!", pName,copname);
SendClientMessageToAll(COLOR_YELLOW, String);
SetPlayerInterior(pid, 3);
ResetPlayerWeapons(pid);
SetPlayerPos(pid, 197.6661, 173.8179, 1003.0234);
IsJailed[pid] = 1;

if(GetPlayerWantedLevel(pid) == 1)
SetTimer("JailRelease", 60000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 1 Minute");

if(GetPlayerWantedLevel(pid) == 2)
SetTimer("JailRelease", 120000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 2 Minutes");

if(GetPlayerWantedLevel(pid) == 3)
SetTimer("JailRelease", 180000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 3 Minutes");

if(GetPlayerWantedLevel(pid) == 4)
SetTimer("JailRelease", 240000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 4 Minutes");

if(GetPlayerWantedLevel(pid) == 5)
SetTimer("JailRelease", 300000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 5 Minutes");

if(GetPlayerWantedLevel(pid) == 6)
SetTimer("JailRelease", 360000, 0);
SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 6 Minutes");
}

}
return 1;
}

I seperated each "wanted level" so its easy to see, Now what happened when i arrested myself to test it is that even with a 1 star wanted level, I would get all the sendclientmessages from 1 star to 6 stars, Can anyone tell me what am i missing to get this to work properly?
Reply
#2

you forgot the {} in your if-blocks...


Код:
   if(GetPlayerWantedLevel(pid) == 1)
   SetTimer("JailRelease", 60000, 0);
   SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 1 Minute");
Код:
   if(GetPlayerWantedLevel(pid) == 1)
   {
      SetTimer("JailRelease", 60000, 0);
      SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 1 Minute");
   }
you might wanne learn to use switch:

pawn Код:
switch(GetPlayerWantedLevel(pid))
{
   case 1:
   {
      SetTimer("JailRelease", 60000, 0);
      SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 1 Minute");
   }
   case 2:
   {
      SetTimer("JailRelease", 120000, 0);
      SendClientMessage(pid, COLOR_YELLOW, "You have been sent to jail for your criminal acts for 2 Minutes");
   }
   case 3: ... and so on
}

does need the {} 2 ...
Reply
#3

ahh of course,.. thanks heaps
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)