04.08.2013, 10:01
(
Last edited by Smokeyy; 06/08/2013 at 08:41 AM.
)
Hi! Today i will show you my way of creating personal cars. You are free to use it as long as you are not gonna remove the credits, please!
1. We will start by enumerating cInfo.
2. Then we will add these code to OnPlayerEnterVehicle. If you do you not have public OnPlayerEnterVehicle in your gamemode, add it like that:
3. Ok there we go with the function that creates the vehicle
4. Creating a vehicle. You just add this code, first inserting the code that you get from /save command in game. Use the /save command only if you are in a vehicle. Add The AddStaticVehicle parameters in CPV(AddStaticVehicleparametersFrom/save, "ownername EX: Smokey");. Example:
NOTE: I've tested this only on godfather gamemode. If you have any questions, feel free to ask.This is the easiest way to add personal cars from your gamemode. I suggest you to add personal cars from the gamemode because personal cars from commands can be buggy. Please notify me if i missed something and i will do an edit to the post. Sorry for my bad English.
Credits:
Smokey - For Coding this personal cars System.
1. We will start by enumerating cInfo.
pawn Code:
enum cInfo
{
cOwner[MAX_PLAYER_NAME],
cOwned
};
new CarInfo[1500][cInfo];
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(CarInfo[vehicleid][cOwned] == 1 && !ispassenger)
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
if(strcmp(sendername,CarInfo[vehicleid][cOwner],true))
if(IsPlayerAdmin(playerid)) // here you can add your own admin system from your gamemode.
{
new string[128];
format(string,sizeof(string),"Personal vehicle of{FFFFFF} %s !", CarInfo[vehicleid][cOwner]);
SendClientMessage(playerid, COLOR_GREY, string);
}
else
{
new string[128];
new Float:cx, Float:cy, Float:cz;
GetPlayerPos(playerid, cx, cy, cz);
SetPlayerPos(playerid, cx, cy, cz);
format(string,sizeof(string),"Personal vehicle of player{FFFFFF} %s !", CarInfo[vehicleid][cOwner]);
SendClientMessage(playerid, COLOR_GREY, string);
RemovePlayerFromVehicle(playerid);
}
}
// return 1; // WARNING: Use this only if you have created the function, if you had this function do you not use that, just add the code up to the function OnPlayerEnterVehicle.
}
pawn Code:
new pv;
forward CPV(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2,owner[MAX_PLAYER_NAME]);
public CPV(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2,owner[MAX_PLAYER_NAME])
{
pv = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2); //
CarInfo[pv][cOwned] = 1;
strmid(CarInfo[pv][cOwner], owner, 0, strlen(owner), 255);
}
pawn Code:
//----------------------------------[PERSONAL CARS [By Smokey]] --------------------------------------
CPV(522,490.8501,-1491.0966,20.0057,168.9865,125,52,"Smokey");
Credits:
Smokey - For Coding this personal cars System.