[Tutorial] How to disable drive-by's in SA-MP 0.3c
#1

[TUT] How To Disable Drive-By's In SA-MP 0.3c
Introduction

It's seems that some people (or game-mode styles) don't really go well with allowing the newly added "any weapon drive-by" system. I have decided to take 5 minutes and show you how to do this in SA-MP 0.3c...

COMPLETELY Disabling Drive-By's

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(playerid, 0);
    return 1;
}
Explanation
We are simply checking to see if a players state has changed to being either the driver, or passenger, of a vehicle. If they are, we will set their "armed (equipped) weapon" to their fist. I don't think that needs to be explained further, does it?
P.S. I am adding more to this later, this is just a start!
Reply
#2

Ehhh, not much of a start. I do realize that I am adding more to this later and this is just a start!
Reply
#3

Quote:
Originally Posted by X35B
View Post
Ehhh, not much of a start. I do realize that I am adding more to this later and this is just a start!
It's actually a simple thing to do, but I haven't seen anyone make a small tutorial on disabling the "any weapon drive-by" system; so I threw this together.
Reply
#4

not a tutorial, but in some threads it exists...
Reply
#5

Quote:
Originally Posted by RealCop228
View Post
[TUT] How To Disable Drive-By's In SA-MP 0.3c
Introduction

It's seems that some people (or game-mode styles) don't really go well with allowing the newly added "any weapon drive-by" system. I have decided to take 5 minutes and show you how to do this in SA-MP 0.3c...

COMPLETELY Disabling Drive-By's

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(playerid, 0);
    return 1;
}
Explanation
We are simply checking to see if a players state has changed to being either the driver, or passenger, of a vehicle. If they are, we will set their "armed (equipped) weapon" to their fist. I don't think that needs to be explained further, does it?
P.S. I am adding more to this later, this is just a start!
just a start? what can you add more to it?
ok, a challenge for you.
Imagine i want just to use uzi, JUST uzi, and not allow them to use other weapons?
how could i?
Reply
#6

Would that really disable? cause it means: if is the player passager or on vehicle, set his weapon for 0. Wouldn't it bug? this is like a weapon ID, but depends vehicle. Would be better use a SetPVar for the player which attacks someone else, or even if attack this person with the weapon ID: 49.

EDIT:

@Mestrekiller: you could add to his condition just these weapons ID's you want to disable also.
Like:

pawn Code:
if(newstate == PLAYER_STATE_DRIVER && GetPlayerArmedWeapon(playerid) == ID) return (...)
Reply
#7

Short but effective! Good work
Reply
#8

Quote:
Originally Posted by [OC]MestreKiller
View Post
just a start? what can you add more to it?
ok, a challenge for you.
Imagine i want just to use uzi, JUST uzi, and not allow them to use other weapons?
how could i?
I can add something later.

Quote:
Originally Posted by blackwave
View Post
Would that really disable? cause it means: if is the player passager or on vehicle, set his weapon for 0. Wouldn't it bug? this is like a weapon ID, but depends vehicle. Would be better use a SetPVar for the player which attacks someone else, or even if attack this person with the weapon ID: 49.
It would disable it because in 0.3c, you can set the players armed weapon while they are in a vehicle. Unless you set it to something else, they can't use any weapons while in a vehicle.
Reply
#9

Untested.

pawn Code:
new weaponExceptions[] =
    {24, 27, 29};
   
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) {
        for(new i = 0; i < sizeof(weaponExceptions); i++) {
            if(GetPlayerWeapon(playerid) == weaponExceptions[i]) SetPlayerArmedWeapon(playerid, 0);
        }
    }
    return 1;
}
Add weapons to the weaponExceptions array, the example blocks drivers/passengers from using deagles, combat shotguns and MP5s, you can change it and add more weapons by adding a number then adding a comma afterwards.
Reply
#10

Quote:
Originally Posted by MestreKiller
View Post
just a start? what can you add more to it?
ok, a challenge for you.
Imagine i want just to use uzi, JUST uzi, and not allow them to use other weapons?
how could i?
Yea!? You can't FOOL a FOOLER! xD

Props to the tut tho
Reply
#11

i thought u ment for the driver not passenger because it would be good for roleplay servers
Reply
#12

Code:
error 021: symbol already defined: "OnPlayerStateChange"
What is wrong and how do i fix it. It is calling the error on the line that has the:
{
Reply
#13

Yea,simple but usefull xD
Your right,everyone is asking how to do this but your the first one who made a tutorial :P
Reply
#14

Quote:
Originally Posted by BittleRyan
View Post
Code:
error 021: symbol already defined: "OnPlayerStateChange"
What is wrong and how do i fix it. It is calling the error on the line that has the:
{
You already have the the callback "OnPlayerStateChange" being used elsewhere, you need to add the code inside of what is on my main post and put it inside your callback.
Reply
#15

Quote:
Originally Posted by ToPhrESH
View Post
Yea!? You can't FOOL a FOOLER! xD

Props to the tut tho
Kinda loled here...
Reply
#16

THAT'S SHIT. I don't know why you prohibit this game feature and it's allowed bugs, that they are external to the game. If you don't like Drive-By THIS IS NOT YOU GAME YOU SHOULD PLAY GAMES LIKE COUNTER STRIKE.
Reply
#17

Quote:
Originally Posted by anonymousx
View Post
THAT'S SHIT. I don't know why you prohibit this game feature and it's allowed bugs, that they are external to the game. If you don't like Drive-By THIS IS NOT YOU GAME YOU SHOULD PLAY GAMES LIKE COUNTER STRIKE.
Actually, some game-modes don't allow drive-by's because their creator(s) find it unfair and unrealistic for RP modes. People enjoy playing SA-MP, nobody is forcing them to play a game-mode where you cannot drive-by. Perhaps you should stop flaming in peoples' threads.
Reply
#18

Quote:
Originally Posted by anonymousx
View Post
THAT'S SHIT. I don't know why you prohibit this game feature and it's allowed bugs, that they are external to the game. If you don't like Drive-By THIS IS NOT YOU GAME YOU SHOULD PLAY GAMES LIKE COUNTER STRIKE.
Ohh cmon,another newbie who believes that his the biggest script!
The biggest Communities like LS-RP doesn't allows DB'es.My opinion is that YOU should find another game to play
P.S:My suggestion: Mario.
Reply
#19

Quote:
Originally Posted by SkizzoTrick
View Post
Ohh cmon,another newbie who believes that his the biggest script!
The biggest Communities like LS-RP doesn't allows DB'es.My opinion is that YOU should find another game to play
P.S:My suggestion: Mario.
lol mario
Reply
#20

Im sorry, but will the Weapons Return if he Changes State Again?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)