/robbank
#1

Hey guys. So i was wondering how can i make if player leaves area for robbank robbering will be interrupted
Reply
#2

if you are using checkpoints
OnPlayerLeaveCheckpoint or OnPlayerLeaveDynamicCP(if you use streamer)
alternatively you can use a timer to check player position, and if the player leaves the robbery area, make the robbery fail?
Reply
#3

Well instead of doing that i came up with this idea. I locked bank so noone can go in or out except police.
Reply
#4

You can use a timer which is verifying if that player is in a range of a point.

Then, you are using the rob variable.

For example:
Код HTML:
new RobCheck[MAX_PLAYERS];
use
Код HTML:
RobCheck[playerid] = SetTimerEx("RobCheck[playerid]", 3000, 1, "d", playerid);
to start the timer.
Код HTML:
forward RobCheck(forward);
public RobCheck(playerid)
{
  if(PlayerVariable[playerid][pRob] == 1)
  {
     if(IsPlayerInRangeOfPoint(playerid, 30.0, x,y,z))
	{
               SendClientMessage(playerid, COLOR_WHITE,"Rob Accepted.");
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, " You are far away from the rob point. Rob Failed.");
            PlayerVariable[playerid][pRob] = 0;
            KillTimer(RobCheck[playerid]);
        }
  }
  return 1;
}
Don't forget to use
Код HTML:
 KillTimer(RobCheck[playerid]);
after rob.
Reply
#5

Any of the above examples are good, but also consider using IsPlayerInCheckpoint
Reply
#6

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
You can use a timer which is verifying if that player is in a range of a point.

Then, you are using the rob variable.

For example:
Код HTML:
new RobCheck[MAX_PLAYERS];
use
Код HTML:
RobCheck[playerid] = SetTimerEx("RobCheck[playerid]", 3000, 1, "d", playerid);
to start the timer.
Код HTML:
forward RobCheck(forward);
public RobCheck(playerid)
{
  if(PlayerVariable[playerid][pRob] == 1)
  {
     if(IsPlayerInRangeOfPoint(playerid, 30.0, x,y,z))
	{
               SendClientMessage(playerid, COLOR_WHITE,"Rob Accepted.");
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, " You are far away from the rob point. Rob Failed.");
            PlayerVariable[playerid][pRob] = 0;
            KillTimer(RobCheck[playerid]);
        }
  }
  return 1;
}
Don't forget to use
Код HTML:
 KillTimer(RobCheck[playerid]);
after rob.
This is a good way but as you need to know if the player is still in the bank

Код HTML:
forward RobCheck(forward);
public RobCheck(playerid)
{
  if(PlayerVariable[playerid][pRob] == 1)
  {
     if(!IsPlayerInRangeOfPoint(playerid, r, x,y,z))
	{
            SendClientMessage(playerid, COLOR_RED, "You exited the bank! Rob failed!");
            PlayerVariable[playerid][pRob] = 0;
            KillTimer(RobCheck[playerid]);
        }
  }
  return 1;
}
Remember to send the Range based on the bank size.
Reply
#7

I used that example because maybe he wants to put a random value which increase in each second


Something like:

Код HTML:
new RobAmount[MAX_PLAYERS];

forward RobCheck(forward);
public RobCheck(playerid)
{
  if(PlayerVariable[playerid][pRob] == 1)
  {
     if(IsPlayerInRangeOfPoint(playerid, 30.0, x,y,z))
	{
               new amount = 1000+random(5000);
               RobAmount[playerid] += amount;

        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, " You are far away from the rob point. Rob Failed.");
            PlayerVariable[playerid][pRob] = 0;
            KillTimer(RobCheck[playerid]);
        }
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)