[Tutorial] How to create private vehicles
#1

In this tutorial, you're going to learn how to create a private vehicle, for specific teams or administrators, etc. (Just edit and make it fit your needs).

Let's start!

At the top of your script, under the includes, add:
pawn Код:
new car1;
Okay, basically, this will a couple warnings from appearing to you when you finish the script.

Search for:
Код:
OnPlayerStateChange
Under:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
Add:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
   
    if(newstate == PLAYER_STATE_DRIVER && vehicleid == car1 && !IsPlayerAdmin(playerid)) {
                RemovePlayerFromVehicle(playerid); // Ejects the player from the vehicle.
                SendClientMessage(playerid, RED, "You must be a RCON administrator to drive this vehicle."); // Outputs a message to the player.
                return 1;
            }
The 'vehicleid' available at the top of the script is: GetPlayerVehicleID function, some people don't want to make the code longer or looking rubbish, they just do that to make it shorter. Let me explain this to you...

This code:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER && vehicleid == car1 && !IsPlayerAdmin(playerid)) {
Is the same as:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == car1 && !IsPlayerAdmin(playerid)) {
So, basically that's it for this part! We'll now move to OnGameModeInIt (for gamemodes), or OnFilterScriptInIt (for filterscripts).

Under:
pawn Код:
public OnGameModeInit()
{
Add:
pawn Код:
car1 = AddStaticVehicle(MODELID, X, Y, Z, ANGLE,COLOR1,COLOR2);
Model ID: Vehicle ID.
X: Position X.
Y: Position Y.
Z: Position Z.
Angle: The angle of the vehicle.
Color1: The color #1 of the vehicle.
Color2: The color #2 of the vehicle. (Not all vehicles have it, only some, such as: Banshee, Bullet.)

Well, well, well! That is it! Congratulations.

You've made a private vehicle, to add more private vehicles, just add the same thing, but instead of having it named car1, make it car2, and so on, or whatever you feel is good! It won't effect.

Leave your comments below.
Reply
#2

Uhh...

https://sampforum.blast.hk/showthread.php?tid=100016
Reply
#3

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
I've just saw that, and I've been looking at the script and just realized that if you add more than one private vehicle, the script would go crazy.
Reply
#4

This was help so "sorry i beat 'fraid dude" like the hippy of san andreas
Reply
#5

Quote:
Originally Posted by Yuvalino
Посмотреть сообщение
This was help so "sorry i beat 'fraid dude" like the hippy of san andreas
Excuse me?
Reply
#6

Bump - haven't gotten any new replies for like two or three months?
Reply
#7

Dude it's normal that a thread dies out after a few weeks, no need to bump it to get some more posts.
Reply
#8

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Dude it's normal that a thread dies out after a few weeks, no need to bump it to get some more posts.
Whatever, just stay on topic.
Reply
#9

Nice TuT.
Reply
#10

Quote:
Originally Posted by Markx
Посмотреть сообщение
Nice TuT.
Thanks - anyways, this is absolutely un tested. I cannot guarantee if it'll work or not, feel free to post any errors you may notice.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)