SA-MP Forums Archive
[Tutorial] How to create private vehicles - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create private vehicles (/showthread.php?tid=185612)



How to create private vehicles - ••• ĤБĶБM ••• - 25.10.2010

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.


Re: How to create private vehicles - Hiddos - 25.10.2010

Uhh...

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


Re: How to create private vehicles - ••• ĤБĶБM ••• - 25.10.2010

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.


Re: How to create private vehicles - Yuvalino - 27.10.2010

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


Re: How to create private vehicles - ••• ĤБĶБM ••• - 28.10.2010

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


Re: How to create private vehicles - ••• ĤБĶБM ••• - 21.04.2011

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


Re: How to create private vehicles - alpha500delta - 21.04.2011

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


Re: How to create private vehicles - ••• ĤБĶБM ••• - 25.04.2011

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.


Re: How to create private vehicles - Markx - 25.04.2011

Nice TuT.


Re: How to create private vehicles - ••• ĤБĶБM ••• - 14.05.2011

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.