Bank Anti-Kill System With Door & Pickups

Started by !, Feb 09, 2017, 10:29 AM

Previous topic - Next topic

!

Older(Simple Bank Anti-Kill System)
[spoiler]Could also be done with class.
function onScriptLoad()
{
Bank <- array( GetMaxPlayers(), true );
}
   
function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
{
local BankPoly = InPoly( player.Pos.x, player.Pos.y, -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( !BankPoly && Bank[player.ID] == true )
{
player.CanAttack = true;
Bank[player.ID] = false;
Announce("Weapons Enabled", player);
}
if ( BankPoly && Bank[player.ID] == false && player.Pos.z < 50 )
{
Bank[player.ID] = true;
player.CanAttack = false;
player.Pos = Vector( -901.3, -341.11, 13.3802 );//Remove this line if you don't like.
Announce("Weapons Disabled", player);
}
}
;D[/spoiler]
 
Updated

Bank Door

Copy all the files from zip file to store.
Bnak Door Stuff For Store

Add this onScriptLoad Function
function onScriptLoad()
{
Bank <- array( GetMaxPlayers(), true );

NewTimer( "AntiBankKilling", 2000, 0 );

BankDoorOut1 <- CreateObject(6000, 0, Vector(-897.365, -342.66, 13.6187),255);
BankDoorOut1.RotateToEuler(Vector(3.13319, 0, -0),0);
BankDoorOut2 <- CreateObject(6001, 0, Vector(-897.355, -339.4, 13.6187),255);
BankDoorOut2.RotateToEuler(Vector(3.13318, -3.79681e-010, -6.16084e-010),0);

BankDoorIn1 <- CreateObject(6000, 0, Vector(-897.365, -342.66, 13.6187),255);
BankDoorIn1.RotateToEuler(Vector(0, 0, -0),0);
BankDoorIn2 <- CreateObject(6001, 0, Vector(-897.355, -339.4, 13.6187),255);
BankDoorIn2.RotateToEuler(Vector(0, -3.79681e-010, -6.16084e-010),0);

BankDoorIn <- CreatePickup( 382, 1, 1, Vector( -899.141, -341.11, 13.3802 ), 255, false );
BankDoorOut <- CreatePickup( 382, 1, 1, Vector( -895.855, -341.11, 13.3846 ), 255, false );
}
   
Add this onPickupPickedUp Function.
function onPickupPickedUp( player, pickup )
{
if ( pickup.ID == 1 )//Use id according to your script
{
Bank[player.ID] = false;
player.CanAttack = true;
player.Pos = Vector( -893.855, -341.11, 13.5005 );
Announce("Weapons Enabled", player);
}

else if ( pickup.ID == 2 )//Use id according to your script
{
Bank[player.ID] = true;
player.CanAttack = false;
player.Pos = Vector( -901.3, -341.11, 13.3802 );
Announce("Weapons Disabled", player);
}
}

Add this AntiBankKilling Function, At the end of script.
function AntiBankKilling()
{
for (local i=0; i<GetMaxPlayers(); i++)
{
local plr=FindPlayer(i);
if ( plr && plr.IsSpawned )
{
local BankPoly = InPoly( plr.Pos.x, plr.Pos.y, -898.2357,-326.6091,-898.2196,-355.5072,-936.2309,-355.5205,-939.2854,-352.5587,-952.3001,-342.9138,-957.1079,-341.7898,-966.5380,-337.4671,-966.5401,-328.1766 );
if ( !BankPoly && Bank[plr.ID] == true )
{
plr.CanAttack = true;
Bank[plr.ID] = false;
Announce("Weapons Enabled", plr);
}
if ( BankPoly && Bank[plr.ID] == false && plr.Pos.z < 50 )
{
Bank[plr.ID] = true;
plr.CanAttack = false;
plr.Pos = Vector( -901.3, -341.11, 13.3802 );
Announce("Weapons Disabled", plr);
}
}
}
}

Discord: zeus#5155

KAKAN

why not run a timer instead? onPlayerMove with InPoly doesn't fit.
Just add some print statements to that event and see the spam, now, imagine 10 players running all around, what will happen then.
oh no

!

Quote from: KAKAN on Feb 09, 2017, 10:43 AMwhy not run a timer instead? onPlayerMove with InPoly doesn't fit.
Just add some print statements to that event and see the spam, now, imagine 10 players running all around, what will happen then.
IDK you are better in scripting than me but i think its not going to spam check these two lines
Quote from: zeus on Feb 09, 2017, 10:29 AMfunction onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
{
........
if ( !BankPoly && Bank[player.ID] == true )
............
if ( BankPoly && Bank[player.ID] == false && player.Pos.z < 50 )
.......

Discord: zeus#5155

KAKAN

#3
I told you, the thing that's making it inefficient is InPoly.
Think of it like this, even when you move a little, that event is called, now, inPoly pokes the client to get your X, Y, after that, it compares your location according to the input given, which takes a bit of computing power.
Now, think, you're running, lets say the event is called 10times/sec, which is still OK.
Now think, 10-20 players are running at the same time, that means the event is being called 10*20 = 200times/sec. That's just too much.
My suggestion, use a 1s or 500ms timer( lets assume you used 500ms timer ). It runs 2 times/sec.
Even with 100 players, it runs just 2 times/sec. While, with onPlayerMove, its more like: 10*100 = 1000times/sec!
That was just to explain you, the real situation might get worse. Do a calculation and see it yourself.

Or even better, just kill the killer who killed the player in the bank :D
oh no

vito

player can kill player being outside bank from door, so no point to care about inpoly/lags, just make a door...

!

#5
Quote from: KAKAN on Feb 09, 2017, 11:08 AMit runs just 2 times/sec.
1 time per 2 seconds.

Quote from: vito on Feb 09, 2017, 11:20 AMplayer can kill player being outside bank from door, so no point to care about inpoly/lags, just make a door...
Updated first post.

Discord: zeus#5155

KAKAN

Why do you even need AntiBankKilling?
There's a pickup outside of it, when we enter using it, we get our weapons blocked. When we exit it, we get to shoot back. I don't understand it, seriously.
oh no

!

Quote from: KAKAN on Feb 09, 2017, 06:16 PMWhy do you even need AntiBankKilling?
There's a pickup outside of it, when we enter using it, we get our weapons blocked. When we exit it, we get to shoot back. I don't understand it, seriously.
Mainly for hackers.
wall hack and another benefit is
No need to disable cmds like goto etc when in bank if someone wants too not me

Discord: zeus#5155

!

There is also another way go down means under map and then goto bank now land heli on bank vault roof and jump.
Congrats  you're in xd enjoy =D

Discord: zeus#5155

KAKAN

Quote from: zeus on Feb 09, 2017, 06:39 PMNo need to disable cmds like goto etc when in bank if someone wants too not me
After teleportation, check the location using inPoly, that'd be more efficient( I guess so ). Or, pause the timer when no one is in the server.

Quote from: zeus on Feb 09, 2017, 06:43 PMThere is also another way go down means under map and then goto bank now land heli on bank vault roof and jump.
Congrats  you're in xd enjoy =D
Sorry, my fault
oh no

!

#10
No khana not bank roof actually there is a building near malibu club through which player are able to go down the map with the help of heli.
So instead of fixing these shits simply add antibank function.
Now its on other if they want to kill the killer if killed player bank status was true so doing all these stuff simply
Make the bank status of player true if he/she has not used the pickup for enterence.

Discord: zeus#5155