[FilterScript] Simple anti drive by for SA-MP 0.3b
#1

Hello. This is anti drive by (it's working correctly with SA-MP 0.3b).

pawn Код:
new PlayerWeapon[MAX_PLAYERS][13];
new PlayerAmmo[MAX_PLAYERS][13];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
        for (new i = 0; i<13; i++)
        {
                GetPlayerWeaponData(playerid, i, PlayerWeapon[playerid][i], PlayerAmmo[playerid][i]);
        }
        ResetPlayerWeapons(playerid);
}
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
        for(new i=0;i<13;i++)
        {
                GivePlayerWeapon(playerid,PlayerWeapon[playerid][i],PlayerAmmo[playerid][i]);
        }
}
return 1;
}
Do not forget to reset PlayerWeapon and PlayerAmmo variables on OnPlayerDisconnect or OnPlayerConnect.
Reply
#2

I have a better idea.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
 if( (newkeys & KEY_FIRE && newkeys & KEY_LOOK_LEFT ) || (newkeys & KEY_FIRE && newkeys & KEY_LOOK_RIGHT )
                              Kick(playerid);
return 1;
}
P.S.Matau esi lietuvis
Reply
#3

God... Have some utility For RP Servers.
Reply
#4

Quote:
Originally Posted by wups
Посмотреть сообщение
I have a better idea.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
 if( (newkeys & KEY_FIRE && newkeys & KEY_LOOK_LEFT ) || (newkeys & KEY_FIRE && newkeys & KEY_LOOK_RIGHT )
                              Kick(playerid);
return 1;
}
P.S.Matau esi lietuvis
I don't think this is better. First you have to check if is player driver. And if it is detected, you have to do something with this player. Kick - i don't think players would like it.. You can set RemovePlayerFromVehicle, it's better.
Reply
#5

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
 if( (newkeys & KEY_FIRE && newkeys & KEY_LOOK_LEFT ) || (newkeys & KEY_FIRE && newkeys & KEY_LOOK_RIGHT )
                              Stop(playerid);
}
return 1;
}
Alright?
Reply
#6

BanEx(playerid,"Noob Dber");
Reply
#7

GivePlayerGun? O.o
Reply
#8

Optimized version ( Better )
pawn Code:
new
    PlayerWeapon[ MAX_PLAYERS ][ 13 ], // Variable  [ 1 ]
    PlayerAmmo  [ MAX_PLAYERS ][ 13 ]; // Variable  [ 2 ]

public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        for( new i = false; i<13; i++ )
        {
            GetPlayerWeaponData( playerid, i, PlayerWeapon[ playerid ][ i ], PlayerAmmo[ playerid ][ i ] );
        }
        ResetPlayerWeapons     ( playerid );
       
    }
    if( oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT )
    {
        for( new i = false; i<13; i++ )
        {
            GivePlayerWeapon( playerid, PlayerWeapon[ playerid ][ i ],PlayerAmmo[ playerid ][ i] );
        }
    }
    return true;
}
Reply
#9

How it's better? It's the same..
Reply
#10

used a little less cpu
Reply
#11

You just changed new to one and 1 to true, 0 - false. And how it will use less cpu? 0.0000001 % less of CPU?
Reply
#12

I think the idea of removing the players weapons when they enter a vehicle and giving them back when they exit is a FANTASTIC idea compared to other ones I've seen, What if I wan't to be in First Person and look to my side or I do it by accident its going to kick me? Seems like a waste.
Reply
#13

Don't work , when i exit the car , i lost all weapon ...
Reply
#14

Setting the player's weapon to fists is more sufficient, no idea why SetPlayerArmedWeapon doesn't work in vehicles though.
Reply
#15

Can i ask what exactly is wrong with drive bying? i never saw it as a bad thing lol
Reply
#16

the problem is because when you shoot from the car with a submachine gun on a pedestrian, you shoot a lot faster then when you are on foot
so thats why dbing is baned on roleplay servers

this code should work:
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerState(killerid) == 2)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(killerid, COLOR_YELLOW, "That was a drive-by kill. Don't do that again!");
            Kick(killerid);
            return 1;
        }
    }
    return 1;
}
Reply
#17

Quote:
Originally Posted by wups
Посмотреть сообщение
I have a better idea.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
 if( (newkeys & KEY_FIRE && newkeys & KEY_LOOK_LEFT ) || (newkeys & KEY_FIRE && newkeys & KEY_LOOK_RIGHT )
                              Kick(playerid);
return 1;
}
P.S.Matau esi lietuvis
Bad idea, in my own server, I don't allow DDB, but I constantly look left and right to check my surroundings.
Lots of people besides be do this.
Reply
#18

2nd Optimized version :

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(IsPlayerInAnyVehicle(killerid)) Kick(killerid);
   	return 1;
}
Reply
#19

nice one mate
Reply
#20

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
 if( (newkeys & KEY_FIRE && newkeys & KEY_LOOK_LEFT ) || (newkeys & KEY_FIRE && newkeys & KEY_LOOK_RIGHT )
                              Stop(playerid);
}
return 1;
}
Alright?
What about on bikes?
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)