[Tutorial] How to create organization vehicles.
#1

Hello fellow friends, this tutorial will teach you how to create organization vehicles.
NOTE: This tutorial is linked to my other tutorial about how to create organizations. However, you can manipulate it to created restricted vehicles on your server.

Lets get started.

Go to the top of your script, below the "#defines" and add:
pawn Код:
new SAPD1,SAPD2
First, get the coordination for the vehicles ready. Now the new variables that we made, will hold the vehicles.
Now go to OnGameModeInt(); and add:

pawn Код:
SAPD1 = AddStaticVehicle(598,2256.2041,2476.9424,10.5694,356.1667,0,1); // policecar1
SAPD2 = AddStaticVehicle(598,2256.2522,2442.7004,10.5722,358.7384,0,1); // policecar2
Now this is the part that we will remove the player from the vehicle if they are not in that org.

Go to OnPlayerStateChane and add:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == SAPD1 && Member[playerid] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, red, "This is an Organization vehicle!");
        }
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == SAPD2 && Member[playerid] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, red, "This is an Organization vehicle!");
        }
    }
    return 1;
}
What the code above is really saying is that. When the player changes state (When they are seated in the SAPD car) it will check if they are in SAPD, and if they are not, it will remove them from the car.

I hope this helped. NB i am not good at tutorials

Note: This is outdated since I made a dynamic MySQL version.
Reply
#2

This was realy help me!Thank you!
Reply
#3

resuming:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == SAPD1||SAPD2 && Member[playerid] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, red, "This is an Organization vehicle!");
        }
    }
    return 1;
}
Reply
#4

I never tryed that way. It could work.
Reply
#5

Nice and simple, but I recommend you to do it dynamic. I mean:

new SAPD[2];

SAPD[0] = AddStaticVehicle(blabla);
SAPD[1] = AddStaticVehicle(blabla);

etc.
Reply
#6

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Nice and simple, but I recommend you to do it dynamic. I mean:

new SAPD[2];

SAPD[0] = AddStaticVehicle(blabla);
SAPD[1] = AddStaticVehicle(blabla);

etc.
yeh its more effecient
Reply
#7

Quote:
Originally Posted by [OC]MestreKiller
Посмотреть сообщение
resuming:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == SAPD1||SAPD2 && Member[playerid] != 1)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, red, "This is an Organization vehicle!");
        }
    }
    return 1;
}
Sorry that will not work.
Reply
#8

Indeed it wouldn't.
Reply
#9

some one help me with this the raf org vehs are bugged. the vehs are at area 51 and they dont act like org vehs. check my script (attached).
Reply
#10

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Nice and simple, but I recommend you to do it dynamic. I mean:

new SAPD[2];

SAPD[0] = AddStaticVehicle(blabla);
SAPD[1] = AddStaticVehicle(blabla);

etc.
you were faster than me xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)