#1

I made a robebry system wich is working just that I wanna make it so if the player exits the checkpoint it cancels the timer

pawn Код:
public CountDown(playerid)
{
  new string[128];
  format(string, sizeof(string), " Stay in the marker for %d seconds to complete the robbery", countn);
  GameTextForPlayer(playerid,string,10000,4);
  countn--;
  if(countn <= -1)
  {
    KillTimer(counttimer);
    SetPlayerScore(playerid,GetPlayerScore(playerid) + 2);
    SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) + 4);
    new Float:money;
    switch(money)
    {
      case 0:
      {
          if(IsPlayerInRangeOfPoint(playerid,3.0,377.0883,-115.8647,1001.4922))
          {
           GivePlayerMoney(playerid,1752);
           GameTextForPlayer(playerid,"You robbed 1752$ from Well Stacked Pizza shop",3000,4);
           new string1[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string1,sizeof(string1),"%s has robbed 1752$ from Well Stacked Pizza shop",pName);
           SendClientMessageToAll(COLOR_GREY,string1);
          }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,-2235.9595,128.4391,1035.4141))
         {
            GivePlayerMoney(playerid,753);
            GameTextForPlayer(playerid,"You robbed 753$ from RC electronics shop",3000,4);
            new string2[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string2,sizeof(string2),"%s has robbed 753$ from RC electronics shop",pName);
            SendClientMessageToAll(COLOR_GREY,string2);
          }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,379.6420,-8.8524,1001.8516))
         {
            GivePlayerMoney(playerid,1325);
            GameTextForPlayer(playerid,"You robbed 1325$ from Cluckin' Bell shop",3000,4);
            new string3[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string3,sizeof(string3),"%s has robbed 1325$ from Cluckin' Bell shop",pName);
            SendClientMessageToAll(COLOR_GREY,string3);
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,378.3380,-65.0391,1001.5078))
         {
            GivePlayerMoney(playerid,853);
            GameTextForPlayer(playerid,"You robbed 853$ from BurgerShot shop",3000,4);
            new string4[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string4,sizeof(string4),"%s has robbed 853$ from BurgerShot shop",pName);
            SendClientMessageToAll(COLOR_GREY,string4);
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,161.4013,-79.2683,1001.8047))
         {
           GivePlayerMoney(playerid,2200);
           GameTextForPlayer(playerid,"You robbed 2200$ from ZIP shop",3000,4);
           new string5[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string5,sizeof(string5),"%s has robbed 2200$ from ZIP shop",pName);
           SendClientMessageToAll(COLOR_GREY,string5);
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,-202.0584,-5.0931,1002.2734))
         {
            GivePlayerMoney(playerid,1368);
            GameTextForPlayer(playerid,"You robbed 1368$ from Hemlock Tatoo shop",3000,4);
            new string6[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string6,sizeof(string6),"%s has robbed 1368$ from Hemlock Tatoo shop",pName);
            SendClientMessageToAll(COLOR_GREY,string6);
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,418.5518,-75.7314,1001.8047))
         {
           GivePlayerMoney(playerid,354);
           GameTextForPlayer(playerid,"You robbed 354$ from Barber's shop",3000,4);
           new string7[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string7,sizeof(string7),"%s has robbed 354$ from Barber's shop",pName);
           SendClientMessageToAll(COLOR_GREY,string7);
         }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,502.6806,-11.5208,1000.6797))
        {
           GivePlayerMoney(playerid,1520);
           GameTextForPlayer(playerid,"You robbed 1520$ from Gayadaa Disco club",3000,4);
           new string8[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string8,sizeof(string8),"%s has robbed 1520$ from Gayadaa Disco club",pName);
           SendClientMessageToAll(COLOR_GREY,string8);
        }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,204.0275,-40.4131,1001.8047))
        {
           GivePlayerMoney(playerid,736);
           GameTextForPlayer(playerid,"You robbed 736$ from SubUrban shop",3000,4);
           new string9[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string9,sizeof(string9),"%s has robbed 736$ from SubUrban shop",pName);
           SendClientMessageToAll(COLOR_GREY,string9);
        }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,508.1718,-84.3275,998.9609))
        {
           GivePlayerMoney(playerid,963);
           GameTextForPlayer(playerid,"You robbed 963$ from SubUrban shop",3000,4);
           new string10[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string10,sizeof(string10),"%s has robbed 963$ from Mystic bar",pName);
           SendClientMessageToAll(COLOR_GREY,string10);
        }
      }
    }
  }
  return 1;
}

COMMAND:rob(playerid,params[])
{
   if(gTeam[playerid] == TEAM_ROBBERS)
   {
      if(IsPlayerInRangeOfPoint(playerid,3.0,377.0883,-115.8647,1001.4922) || IsPlayerInRangeOfPoint(playerid,3.0,-2235.9595,128.4391,1035.4141) ||
      IsPlayerInRangeOfPoint(playerid,3.0,379.6420,-8.8524,1001.8516) || IsPlayerInRangeOfPoint(playerid,3.0,378.3380,-65.0391,1001.5078) ||
      IsPlayerInRangeOfPoint(playerid,3.0,161.4013,-79.2683,1001.8047) || IsPlayerInRangeOfPoint(playerid,3.0,-202.0584,-5.0931,1002.2734) ||
      IsPlayerInRangeOfPoint(playerid,3.0,418.5518,-75.7314,1001.8047) || IsPlayerInRangeOfPoint(playerid,3.0,502.6806,-11.5208,1000.6797) ||
      IsPlayerInRangeOfPoint(playerid,3.0,204.0275,-40.4131,1001.8047))
      {
         countn = 15;
         counttimer = SetTimer("CountDown",1000,true);
      }
      if(GetPlayerInterior(playerid) == 0) return SendClientMessage(playerid,COLOR_FORESTGREEN,"This command can be used only on a shop");
   }
   if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_MEDICS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for robbers");
  return true;
}
Reply
#2

nobody yet?
Reply
#3

Really easy.

Create a variable on the top of your script

pawn Код:
new Robbing[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{

     Robbing[playerid] = 0;//0 Means the player isnt robbing in our case .
     return 1;
}
Add
pawn Код:
Robbing[playerid] = 1;//1 Means the player IS robbing .
at the rob cmd
pawn Код:
COMMAND:rob(playerid,params[])
{
   if(gTeam[playerid] == TEAM_ROBBERS)
   {
      if(IsPlayerInRangeOfPoint(playerid,3.0,377.0883,-115.8647,1001.4922) || IsPlayerInRangeOfPoint(playerid,3.0,-2235.9595,128.4391,1035.4141) ||
      IsPlayerInRangeOfPoint(playerid,3.0,379.6420,-8.8524,1001.8516) || IsPlayerInRangeOfPoint(playerid,3.0,378.3380,-65.0391,1001.5078) ||
      IsPlayerInRangeOfPoint(playerid,3.0,161.4013,-79.2683,1001.8047) || IsPlayerInRangeOfPoint(playerid,3.0,-202.0584,-5.0931,1002.2734) ||
      IsPlayerInRangeOfPoint(playerid,3.0,418.5518,-75.7314,1001.8047) || IsPlayerInRangeOfPoint(playerid,3.0,502.6806,-11.5208,1000.6797) ||
      IsPlayerInRangeOfPoint(playerid,3.0,204.0275,-40.4131,1001.8047))
      {
         countn = 15;
         counttimer = SetTimer("CountDown",1000,true);
         Robbing[playerid] = 1;//So now the player is robbing.
      }
      if(GetPlayerInterior(playerid) == 0) return SendClientMessage(playerid,COLOR_FORESTGREEN,"This command can be used only on a shop");
   }
   if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_MEDICS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for robbers");
  return true;
}
On the public "CountDown"
You gonna put in every case Robbing[playerid] = 0; Cuz the player is finished the robbery already.
pawn Код:
public CountDown(playerid)
{
  new string[128];
  format(string, sizeof(string), " Stay in the marker for %d seconds to complete the robbery", countn);
  GameTextForPlayer(playerid,string,10000,4);
  countn--;
  if(countn <= -1)
  {
    KillTimer(counttimer);
    SetPlayerScore(playerid,GetPlayerScore(playerid) + 2);
    SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) + 4);
    new Float:money;
    switch(money)
    {
      case 0:
      {
          if(IsPlayerInRangeOfPoint(playerid,3.0,377.0883,-115.8647,1001.4922))
          {
           GivePlayerMoney(playerid,1752);
           GameTextForPlayer(playerid,"You robbed 1752$ from Well Stacked Pizza shop",3000,4);
           new string1[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string1,sizeof(string1),"%s has robbed 1752$ from Well Stacked Pizza shop",pName);
           SendClientMessageToAll(COLOR_GREY,string1);
           Robbing[playerid] = 0;//Robbery is finished for that player
          }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,-2235.9595,128.4391,1035.4141))
         {
            GivePlayerMoney(playerid,753);
            GameTextForPlayer(playerid,"You robbed 753$ from RC electronics shop",3000,4);
            new string2[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string2,sizeof(string2),"%s has robbed 753$ from RC electronics shop",pName);
            SendClientMessageToAll(COLOR_GREY,string2);
            Robbing[playerid] = 0;//Robbery is finished for that player
          }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,379.6420,-8.8524,1001.8516))
         {
            GivePlayerMoney(playerid,1325);
            GameTextForPlayer(playerid,"You robbed 1325$ from Cluckin' Bell shop",3000,4);
            new string3[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string3,sizeof(string3),"%s has robbed 1325$ from Cluckin' Bell shop",pName);
            SendClientMessageToAll(COLOR_GREY,string3);
            Robbing[playerid] = 0;//Robbery is finished for that player
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,378.3380,-65.0391,1001.5078))
         {
            GivePlayerMoney(playerid,853);
            GameTextForPlayer(playerid,"You robbed 853$ from BurgerShot shop",3000,4);
            new string4[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string4,sizeof(string4),"%s has robbed 853$ from BurgerShot shop",pName);
            SendClientMessageToAll(COLOR_GREY,string4);
            Robbing[playerid] = 0;//Robbery is finished for that player
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,161.4013,-79.2683,1001.8047))
         {
           GivePlayerMoney(playerid,2200);
           GameTextForPlayer(playerid,"You robbed 2200$ from ZIP shop",3000,4);
           new string5[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string5,sizeof(string5),"%s has robbed 2200$ from ZIP shop",pName);
           SendClientMessageToAll(COLOR_GREY,string5);
           Robbing[playerid] = 0;//Robbery is finished for that player
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,-202.0584,-5.0931,1002.2734))
         {
            GivePlayerMoney(playerid,1368);
            GameTextForPlayer(playerid,"You robbed 1368$ from Hemlock Tatoo shop",3000,4);
            new string6[128];
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(string6,sizeof(string6),"%s has robbed 1368$ from Hemlock Tatoo shop",pName);
            SendClientMessageToAll(COLOR_GREY,string6);
            Robbing[playerid] = 0;//Robbery is finished for that player
         }
         else if(IsPlayerInRangeOfPoint(playerid,3.0,418.5518,-75.7314,1001.8047))
         {
           GivePlayerMoney(playerid,354);
           GameTextForPlayer(playerid,"You robbed 354$ from Barber's shop",3000,4);
           new string7[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string7,sizeof(string7),"%s has robbed 354$ from Barber's shop",pName);
           SendClientMessageToAll(COLOR_GREY,string7);
           Robbing[playerid] = 0;//Robbery is finished for that player
         }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,502.6806,-11.5208,1000.6797))
        {
           GivePlayerMoney(playerid,1520);
           GameTextForPlayer(playerid,"You robbed 1520$ from Gayadaa Disco club",3000,4);
           new string8[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string8,sizeof(string8),"%s has robbed 1520$ from Gayadaa Disco club",pName);
           SendClientMessageToAll(COLOR_GREY,string8);
           Robbing[playerid] = 0;//Robbery is finished for that player
        }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,204.0275,-40.4131,1001.8047))
        {
           GivePlayerMoney(playerid,736);
           GameTextForPlayer(playerid,"You robbed 736$ from SubUrban shop",3000,4);
           new string9[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string9,sizeof(string9),"%s has robbed 736$ from SubUrban shop",pName);
           SendClientMessageToAll(COLOR_GREY,string9);
           Robbing[playerid] = 0;//Robbery is finished for that player
        }
        else if(IsPlayerInRangeOfPoint(playerid,3.0,508.1718,-84.3275,998.9609))
        {
           GivePlayerMoney(playerid,963);
           GameTextForPlayer(playerid,"You robbed 963$ from SubUrban shop",3000,4);
           new string10[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           format(string10,sizeof(string10),"%s has robbed 963$ from Mystic bar",pName);
           SendClientMessageToAll(COLOR_GREY,string10);
           Robbing[playerid] = 0;//Robbery is finished for that player
        }
      }
    }
  }
  return 1;
}
Now , we gonna have to check every _ if the player is robbing . If yes , we gonna continue checking if he is in range of point we want him to be . if no , We gonna Reset His 'Robbing' (0) and SendClientMessage To him.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(Robbing[playerid] == 1)//In case he is robbing
    {
        //Continue checking .... if the player is in the robbery point
        if(!IsPlayerInRangeOfPoint(playerid,3.0,X,Y,Z))//Replace the X Y Z with your position
        {
            Robbing[playerid] == 0;//The player isnt robbing anymore
            SendClientMessage(playerid,color,"You left the robbery !");//Replace 'color' with your color
        }
    }
    return 1;
}
Reply
#4

I didn't udnerstand exaclty the thing with OnPlayerUpdate u said replace the coords but with what?
Reply
#5

You said you want to check if the player is in some checkpoint ... if not , hes robbery will stop .
So replace the X Y Z (OnPlayerUpdate) with the point that if the the player doesnt in it , the robbery will stop.
Reply
#6

Oh, jeez. Just use OnPlayerLeave(Dynamic)Checkpoint for that ...
Reply
#7

I dont know what he means.
an acttual checkpoint or just a position
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)