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(playerid, params[])
{
if(isplayerinsideofbusiness)) // change this to whateve int you want
{
SendClientMessage(playerid, -1, "Robbery started");
SetTimerEx("robingbiz", 1000, 0, "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(playerid, checkpoint cords, 2.0);
}
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. |
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); }
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); } |