02.12.2014, 18:51
Personal Car:
- First of all, we need to make a variable, at the top of script, under includes/defines we add:
- With this variable, we define the personal car for that player.
- Then, we need to create the car, under OnFilterScriptInit() or OnGameModeInit(). Depends if you are using a Filescript [OnFilterScriptInit()] or if you are using a GameMode [OnGameModeInit()]. And then, we create the car:
Vehicle Model - It's the model of vehicle wich you want to create. All vehicle models can be found right here!
X, Y, Z, Angle - Are the positions of that car. Them can be found by going in game and type /Save, then going in My Documents/GTA San Andreas User Files/SAMP/savedpositions.txt
Color1, Color2 - Are the colors of that car. Them can be found, too, right here!
Respawn Time - Time after which the car will be respawned.
- After creating the car, we'll moving under OnPlayerEnterVehicle(playerid, vehicleid), and we add the code:
- First of all, we need to make a variable, at the top of script, under includes/defines we add:
pawn Код:
new Car;
- Then, we need to create the car, under OnFilterScriptInit() or OnGameModeInit(). Depends if you are using a Filescript [OnFilterScriptInit()] or if you are using a GameMode [OnGameModeInit()]. And then, we create the car:
pawn Код:
Car = CreateVehicle(Vehicle Model, Float:X, Float:Y, Float:Z, Float:Angle, Color1, Color2, RespawnTime);
X, Y, Z, Angle - Are the positions of that car. Them can be found by going in game and type /Save, then going in My Documents/GTA San Andreas User Files/SAMP/savedpositions.txt
Color1, Color2 - Are the colors of that car. Them can be found, too, right here!
Respawn Time - Time after which the car will be respawned.
- After creating the car, we'll moving under OnPlayerEnterVehicle(playerid, vehicleid), and we add the code:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid) // public
{ // Open bracket
new name[MAX_PLAYER_NAME]; // Hrre make a variable for player's name!
GetPlayerName(playerid, name, sizeof(name)); // Here we gettin' his and, to know if he is leader of car, else will remove him.
new Car2 = GetPlayerVehicleID(playerid); // Here we define the Car2 variable, and get his car vehicle id;
if(Car2 == Car) // If Car2 variable it's Car creating by us below.
{ // Open bracket!
if(strcmp(name, "NameOfPlayer", true)) // Replace "NameOfPlayer" with the owner of car wich you want to be. And if he is owner.
{ // Open bracket
SendClientMessage(playerid, -1, "Welcome in your vehicle!"); // Send to him message "Welcome in your vehicle!"
} // Close bracket !
else // Else, if he isn't owner of that car!
{ // Open bracket !
SendClientMessage(playerid, -1, "It's not your vehicle!"); // Will send to him message "It's not your vehicle!"
RemovePlayerFromVehicle(playerid); // He will got removed from vehicle !
} // Close bracket
} // Close bracket *2
return 1; // Returns the value.
} // Closing bracket