SA-MP Forums Archive
Robbing system checkpoints - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Robbing system checkpoints (/showthread.php?tid=645751)



Robbing system checkpoints - Deroxi - 03.12.2017

Ive seen tutorials on this forums on how to make a robbering system. They work fine but either the timers are not correct or every checkpoint has to be defined. My question is: Is there an easier/simple way to create 3 checkpoints per store (Enter, Exit, Robbing place).

I dont need the exact code, just rough ideas will do.

Thanks in advance,
__Deroxi


Re: Robbing system checkpoints - AlexMSK - 03.12.2017

yep, using onplayerentercheckpoint and switching cases
ex
PHP код:
new playercheckpoint[MAX_PLAYERS];
enum
{
checkpoint_none,
checkpoint_robbery
};
public 
OnPlayerEnterCheckpoint(playerid)
{
switch(
playercheckpoint)
{
    case 
checkpoint_robbery:
{
   
// your code here
    
playercheckpoint checkpoint_none;
    
DisablePlayerCheckpoint(playerid);
}
}
}
cmd:robstore(playeridparams[])
{
  if(
isplayerinsideofbusiness)) // change this to whateve int you want
  
{
      
SendClientMessage(playerid, -1"Robbery started");
      
SetTimerEx("robingbiz"10000"ii"playerid);
   }
   return 
1;
}
forward robingbiz(playerid);
public 
robingbiz(playerid)
{
    
// your code here
    
SendClientMessage(playerid, -1"Biz robbed go to checkpoint");
    
playercheckpoint checkpoint_robbery;
    
setplayercheckpoint(playeridcheckpoint cords2.0);

PS there are a lot other ways to do it more easy, but i like this one


Re: Robbing system checkpoints - Deroxi - 03.12.2017

But wouldnt this require me to define every single checkpoint?

P.S. Im using Streamer by Incognito


Re: Robbing system checkpoints - FuNkYTheGreat - 03.12.2017

The upper code isn't very good it's just like useless..

Try doing this:
- Create per shop var like " bshot[3] "
- Then create them on game mode init.
- Now in Onplayerenterdynamiccheckpoint, Check that if the checkpoint id is equal to the ID of the enter checkpoint which he enter, Now set his enter pos, do the same for exit one.
- Now for robbing check if checkpointid = rob cp one , then use your code of robbing,
- and no need of multiple timers, create a var like " shop[MAX_SHOPS] " , define max shops and then
- When someone robs it do it like " shop[enteredshop] = 60 " and create only a timer,
- In that timer loop through all shops and minus it like shop[varloop] --; so that it'll keep minusing a second in it.
- And now when player starts robbing check that if the shop he entered variablw of it aka shop is 0 then he can start robbing
- also don't forgot to do a check that loop id shop var isn't 0 already..




Re: Robbing system checkpoints - Deroxi - 03.12.2017

It might be just me, but I dont get what you are trying to explain.


Re: Robbing system checkpoints - NaS - 04.12.2017

Create an Array (with an enumerator) which holds each Shop's Enter/Exit/Robbery Checkpoint Coordinates and the Interior ID (best would be also adding an angle to the enter/exit coords for the teleport).
Mabye also a Name for the shop, a Value and Coordinates for the Actor (if you want to add that).

You should also create an Array for each Player that saves the last time a player was teleported into/out of a Robbery Store (to prevent an endless loop of teleporting).

Also add a variable to the enumerator which holds the timestamp of the last robbery (use gettime(), not GetTickCount() because you don't need milliseconds, and GetTickCount() is not safe for longer durations).
I'd not do it like FuNkY said, it's totally unneccessary to use a timer here. Also this method is accurate (timers are not, by default).

In GameModeInit you then just have to create all the Checkpoints and fill the timestamp with the current time - 60 (assuming 60 seconds is the minimum time between 2 robberies).

Then in OnPlayerEnterDynamicCP you check if the entered checkpoint is one of the Shop CPs and which one.

If it's the Enter CP, check the time of the player's last teleport to prevent an endless loop of teleports. If the last teleport is longer than (eg) 5 seconds ago, teleport the player to the Exit CP (inside the Shop) and set the variable mentioned above to the current time (gettime()). If you wouldn't do that, the player would get teleported back/forth endlessly, cause he enters the Exit CP after the teleport.

(Same for the Exit CP, just the other way around).

Then handle the Robbery CP accordingly, not sure how exactly you want to do that. Using gettime() and a simple timer you can repeatedly check if the player is still aiming the Actor and for how long. If you just want to make a /rob command or something, do that instead.

To add Stores you can now just /save 3 coordinates and paste them into your mode.

Later you can also make them save to a file and load, or whatever you prefer to save data, so you could create them ingame without having to GMX/copy around coords at all.

It would also be a good idea to set the Player's Virtual World to a unique number for each Shop (eg. 2000 + Shop ID). That way you can re-use interiors for different Shops.


Re: Robbing system checkpoints - Deroxi - 04.12.2017

Quote:
Originally Posted by NaS
Посмотреть сообщение
Create an Array (with an enumerator) which holds each Shop's Enter/Exit/Robbery Checkpoint Coordinates and the Interior ID (best would be also adding an angle to the enter/exit coords for the teleport).
Mabye also a Name for the shop, a Value and Coordinates for the Actor (if you want to add that).

You should also create an Array for each Player that saves the last time a player was teleported into/out of a Robbery Store (to prevent an endless loop of teleporting).

Also add a variable to the enumerator which holds the timestamp of the last robbery (use gettime(), not GetTickCount() because you don't need milliseconds, and GetTickCount() is not safe for longer durations).
I'd not do it like FuNkY said, it's totally unneccessary to use a timer here. Also this method is accurate (timers are not, by default).

In GameModeInit you then just have to create all the Checkpoints and fill the timestamp with the current time - 60 (assuming 60 seconds is the minimum time between 2 robberies).

Then in OnPlayerEnterDynamicCP you check if the entered checkpoint is one of the Shop CPs and which one.

If it's the Enter CP, check the time of the player's last teleport to prevent an endless loop of teleports. If the last teleport is longer than (eg) 5 seconds ago, teleport the player to the Exit CP (inside the Shop) and set the variable mentioned above to the current time (gettime()). If you wouldn't do that, the player would get teleported back/forth endlessly, cause he enters the Exit CP after the teleport.

(Same for the Exit CP, just the other way around).

Then handle the Robbery CP accordingly, not sure how exactly you want to do that. Using gettime() and a simple timer you can repeatedly check if the player is still aiming the Actor and for how long. If you just want to make a /rob command or something, do that instead.

To add Stores you can now just /save 3 coordinates and paste them into your mode.

Later you can also make them save to a file and load, or whatever you prefer to save data, so you could create them ingame without having to GMX/copy around coords at all.

It would also be a good idea to set the Player's Virtual World to a unique number for each Shop (eg. 2000 + Shop ID). That way you can re-use interiors for different Shops.
I got a feeling that this should be the way to go, but I don't really understand you. Would you mind giving me a small piece of code for an example?


Re: Robbing system checkpoints - jasperschellekens - 04.12.2017

I use something like that for entering/exiting the bank on my server.
Might be useful to you.

Код:
new Bank1;
new Bank2;
new Bank3;
new Bank4;
new Bank5;
new Bank6;
new Bank7;
new Bank8;
new BankExit;

Bank1=CreateDynamicPickup(1274,1,1461.8743,-1011.6029,26.8438,-1);
Bank2=CreateDynamicPickup(1274,1,2474.4038,1023.0991,10.8203,-1);
Bank3=CreateDynamicPickup(1274,1,-2764.9155,375.3531,6.3429,-1);
Bank4=CreateDynamicPickup(1274,1,-178.1093,1109.9939,19.7422);
Bank5=CreateDynamicPickup(1274,1,2862.0969,-1405.7080,11.7344);
Bank6=CreateDynamicPickup(1274,1,-1704.3229,785.7140,25.4682);
Bank7=CreateDynamicPickup(1274,1,274.1207,-1614.0920,33.2041);
Bank8=CreateDynamicPickup(1274,1,2462.8232,2244.1150,10.8203);
BankExit=CreateDynamicPickup(1274,1,1563.2772,-2251.8469,266.2109,-1);

//OnPlayerPickUpDynamicPickup
if(pickupid==Bank1)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=1;
	}
	if(pickupid==Bank2)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=2;
	}
	if(pickupid==Bank3)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=3;
	}
	if(pickupid==Bank4)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=4;
	}
	if(pickupid==Bank5)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=5;
	}
	if(pickupid==Bank6)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=6;
	}
	if(pickupid==Bank7)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=7;
	}
	if(pickupid==Bank8)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=8;
	}

if(pickupid==BankExit)
	{
		SetPlayerInterior(playerid,0);
		SendClientMessage(playerid,-1,"Have a nice day");
		if(bp[playerid]==0)return SetPlayerPos(playerid,1465.7212,-1012.1486,26.8);
		if(bp[playerid]==1)return SetPlayerPos(playerid,1465.7212,-1012.1486,26.8);
		if(bp[playerid]==2)return SetPlayerPos(playerid,2474.3806,1020.6902,10.820);
		if(bp[playerid]==3)return SetPlayerPos(playerid,-2761.7832,375.2657,5.3636);
		if(bp[playerid]==4)return SetPlayerPos(playerid,-178.1093+2,1109.9939,19.7);
		if(bp[playerid]==5)return SetPlayerPos(playerid,2865.6575,-1405.8911,10.97);
		if(bp[playerid]==6)return SetPlayerPos(playerid,-1706.5990,785.5201,24.890);
		if(bp[playerid]==7)return SetPlayerPos(playerid,272.2456,-1615.6379,33.253);
		if(bp[playerid]==8)return SetPlayerPos(playerid,2463.0823,2242.0701,10.820);
	}



Re: Robbing system checkpoints - Deroxi - 05.12.2017

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
I use something like that for entering/exiting the bank on my server.
Might be useful to you.

Код:
new Bank1;
new Bank2;
new Bank3;
new Bank4;
new Bank5;
new Bank6;
new Bank7;
new Bank8;
new BankExit;

Bank1=CreateDynamicPickup(1274,1,1461.8743,-1011.6029,26.8438,-1);
Bank2=CreateDynamicPickup(1274,1,2474.4038,1023.0991,10.8203,-1);
Bank3=CreateDynamicPickup(1274,1,-2764.9155,375.3531,6.3429,-1);
Bank4=CreateDynamicPickup(1274,1,-178.1093,1109.9939,19.7422);
Bank5=CreateDynamicPickup(1274,1,2862.0969,-1405.7080,11.7344);
Bank6=CreateDynamicPickup(1274,1,-1704.3229,785.7140,25.4682);
Bank7=CreateDynamicPickup(1274,1,274.1207,-1614.0920,33.2041);
Bank8=CreateDynamicPickup(1274,1,2462.8232,2244.1150,10.8203);
BankExit=CreateDynamicPickup(1274,1,1563.2772,-2251.8469,266.2109,-1);

//OnPlayerPickUpDynamicPickup
if(pickupid==Bank1)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=1;
	}
	if(pickupid==Bank2)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=2;
	}
	if(pickupid==Bank3)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=3;
	}
	if(pickupid==Bank4)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=4;
	}
	if(pickupid==Bank5)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=5;
	}
	if(pickupid==Bank6)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=6;
	}
	if(pickupid==Bank7)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=7;
	}
	if(pickupid==Bank8)
	{
		SetPlayerPos(playerid,1563.3580,-2254.1040,266.2183);
		FreezeThenAutoUnfreeze(playerid, 3000);
        GameTextForPlayer(playerid,"~y~b~w~ank",800,1);
		SetPlayerInterior(playerid,5);
		bp[playerid]=8;
	}

if(pickupid==BankExit)
	{
		SetPlayerInterior(playerid,0);
		SendClientMessage(playerid,-1,"Have a nice day");
		if(bp[playerid]==0)return SetPlayerPos(playerid,1465.7212,-1012.1486,26.8);
		if(bp[playerid]==1)return SetPlayerPos(playerid,1465.7212,-1012.1486,26.8);
		if(bp[playerid]==2)return SetPlayerPos(playerid,2474.3806,1020.6902,10.820);
		if(bp[playerid]==3)return SetPlayerPos(playerid,-2761.7832,375.2657,5.3636);
		if(bp[playerid]==4)return SetPlayerPos(playerid,-178.1093+2,1109.9939,19.7);
		if(bp[playerid]==5)return SetPlayerPos(playerid,2865.6575,-1405.8911,10.97);
		if(bp[playerid]==6)return SetPlayerPos(playerid,-1706.5990,785.5201,24.890);
		if(bp[playerid]==7)return SetPlayerPos(playerid,272.2456,-1615.6379,33.253);
		if(bp[playerid]==8)return SetPlayerPos(playerid,2463.0823,2242.0701,10.820);
	}
The problem with this is that I'd still have to define every checkpoint in the map.


Re: Robbing system checkpoints - Sjn - 05.12.2017

You need to understand how arrays work. If you have no proper knowledge then it's obvious it will be hard for you even if people around here show you the examples. I would suggest you to learn em first.