17.09.2011, 11:37
(
Last edited by FireCat; 11/11/2012 at 05:48 PM.
)
Hello :b
I'm going to show you how to make private vehicles, but a beginners version.
So lets start of with the variables.
So that's going to be my 'name', i'll be the owner of the vehicle.
That's aswell where we are going to store the 'vehicle id'.
So now under OnGameModeInit
So the variable FireCat will store the vehicle id.
CreateVehicle params are:
-model id
-Float: Spawn X
-Float: Spawn Y
-Float: Spawn Z
-Float: Angle
-Color 1
-Color 2
-Respawn delay in seconds
Now lets make only the selected play can drive the vehicle.
So under OnPlayerEnterVehicle add
I hope you liked it.
If I didn't explain well enough, don't complain, just ask for me to explain better.
I'm going to show you how to make private vehicles, but a beginners version.
So lets start of with the variables.
pawn Code:
new FireCat;
That's aswell where we are going to store the 'vehicle id'.
So now under OnGameModeInit
pawn Code:
FireCat = CreateVehicle(411,0,0,0,1,146,146,60);
CreateVehicle params are:
-model id
-Float: Spawn X
-Float: Spawn Y
-Float: Spawn Z
-Float: Angle
-Color 1
-Color 2
-Respawn delay in seconds
Now lets make only the selected play can drive the vehicle.
So under OnPlayerEnterVehicle add
pawn Code:
if(vehicleid == FireCat)//Checking if the vehicleid matches the FireCat one.
{
new pName[MAX_PLAYER_NAME];//Where we will store the players name in a 24 size.
GetPlayerName(playerid,pName,sizeof(pName));//Getting the players name and storing it in pName.
if(strcmp(pName,"NAMEHERE") == 0)//String compare between the users name and the selected name.
{
//If the 2 names are the same...
SendClientMessage(playerid,-1,"Welcome to your car!");
}
else//Else if the 2 names don't match....
{
RemovePlayerFromVehicle(playerid);//Lets remove him from the vehicle
SendClientMessage(playerid,-1,"This car is not yours!");
}
}
If I didn't explain well enough, don't complain, just ask for me to explain better.