name = my-car-custom-name
_z = position-z-here
_x = position-x-here
_y = position-y-here
stock SaveVehicle(vehicleid)
{
new veh = ConvertVID(vehicleid);
new file[64];
format(file,sizeof file,VEHICLE_PATH,veh);
new INI:handler = INI_Open(file);
INI_WriteString(handler,"_owner",PrivateVehicles[veh][_owner]);
INI_WriteInt(handler,"_modelid",PrivateVehicles[veh][_modelid]);
INI_WriteFloat(handler,"_x",PrivateVehicles[veh][_x]);
INI_WriteFloat(handler,"_y",PrivateVehicles[veh][_y]);
INI_WriteFloat(handler,"_z",PrivateVehicles[veh][_z]);
INI_WriteFloat(handler,"_rot",PrivateVehicles[veh][_rot]);
INI_WriteInt(handler,"_c1",PrivateVehicles[veh][_c1]);
INI_WriteInt(handler,"_c2",PrivateVehicles[veh][_c2]);
INI_WriteInt(handler,"_price",PrivateVehicles[veh][_price]);
INI_WriteInt(handler,"_spawned",PrivateVehicles[veh][_spawned]);
INI_WriteInt(handler,"_locked",PrivateVehicles[veh][_locked]);
new Float:health2;
PrivateVehicles[veh][_health] = health2;
INI_WriteFloat(handler,"_health",PrivateVehicles[veh][_health]);
INI_Close(handler);
return 1;
}
stock LoadVehicles()
{
new counter = 0;
for(new i = 0;i<M_VEHICLES;i++)
{
new file[64];format(file,sizeof file,VEHICLE_PATH,i);
if(fexist(file))
{
new INI:handler = INI_Open(file);
INI_ParseFile(file,"LoadVehicle",.bExtra = true, .extra = i);
PrivateVehicles[i][_vehicleid] = AddStaticVehicle(PrivateVehicles[i][_modelid],PrivateVehicles[i][_x],PrivateVehicles[i][_y],PrivateVehicles[i][_z],PrivateVehicles[i][_rot],PrivateVehicles[i][_c1],PrivateVehicles[i][_c2]);
SetVehicleNumberPlate(PrivateVehicles[i][_vehicleid],PrivateVehicles[i][_owner]);
SetVehicleToRespawn(PrivateVehicles[i][_vehicleid]);
SetVehicleHealth(PrivateVehicles[i][_vehicleid],PrivateVehicles[i][_health]);
SetVehicleParamsEx(PrivateVehicles[i][_vehicleid],engine,lights,alarm,PrivateVehicles[i][_locked],bonnet,boot,objective);
INI_Close(handler);
counter++;
}
}
printf("vDealer: %i vehicle(s) loaded.",counter);
}
forward LoadVehicle(i,name[],value[]);
public LoadVehicle(i,name[],value[])
{
if(!strcmp(name,"_owner")){format(PrivateVehicles[i][_owner],MAX_PLAYER_NAME,"%s",value);}
INI_Int("_modelid",PrivateVehicles[i][_modelid]);
INI_Float("_x",PrivateVehicles[i][_x]);
INI_Float("_y",PrivateVehicles[i][_y]);
INI_Float("_z",PrivateVehicles[i][_z]);
INI_Float("_rot",PrivateVehicles[i][_rot]);
INI_Int("_c1",PrivateVehicles[i][_c1]);
INI_Int("_c2",PrivateVehicles[i][_c2]);
INI_Int("_price",PrivateVehicles[i][_price]);
INI_Int("_spawned",PrivateVehicles[i][_spawned]);
INI_Int("_locked",PrivateVehicles[i][_locked]);
INI_Float("_health",PrivateVehicles[i][_health]);
return 1;
}
stock CreateVehicleDealer(dealername[],Float:x,Float:y,Float:z)
{
new id = GenerateID(1);
format(Dealers[id][_dealername],64,"%s",dealername);
Dealers[id][_x] = x;
Dealers[id][_y] = y;
Dealers[id][_z] = z;
Dealers[id][_active] = true;
#if USE_CP == true
Dealers[id][_pickupid] = CreateDynamicCP(x,y,z,CP_SIZE);
#else
Dealers[id][_pickupid] = CreateDynamicPickup(PICKUP_MODEL,23,x,y,z);
#endif
Dealers[id][_3dtextlabel] = CreateDynamic3DTextLabel(dealername,COLOR_YELLOW,x,y,z +1,STREAMER_DISTANCE);
Dealers[id][_mapicon] = CreateDynamicMapIcon(x,y,z,MAP_ICON,0);
return id;
}
Go and learn the basics how to use loops and detect any vehicle position
|
stock GetClosestVehicle(playerid, Float:range)
{
new Float:p_X;
new Float:p_Y;
new Float:p_Z;
new Float:Distance;
new Float:PretendentDistance = range +1;
new Pretendent;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
{
Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
if(Distance <= range && Distance <= PretendentDistance)
{
Pretendent = vehicleid;
PretendentDistance = Distance;
}
}
return Pretendent;
}
new vehicleid;
vehicleid = GetClosestVehicle(playerid, 20);
COMMAND:lock(playerid,params[])
{
new pName[MAX_PLAYER_NAME];GetPlayerName(playerid,pName,sizeof pName);
new vehicleid;
vehicleid = GetClosestVehicle(playerid, 5);
new veh = GetPlayerVehicleID(playerid);
if(IsVehiclePrivate(veh))
{
if(strcmp(pName,PrivateVehicles[ConvertVID(veh)][_owner]))
{
SendClientMessage(playerid,COLOR_WHITE,"Closest vehicle doesn't belong to you!");
return 1;
}
else
{
veh = ConvertVID(veh);
PrivateVehicles[veh][_locked] = 0;
SendClientMessage(playerid,COLOR_RED,"Car Locked!");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,0,bonnet,boot,objective);
}
}
return 1;
}
if(vehicleid != 0) // if any vehicle is in range, returns 0 if theres no vehicle in range
To: BigETI, If the thing you want to say isn't helpful and doesn't make sense, why bother? |
If you think that you don't know anything at scripting and don't want to bother to learn it so go and hire a scripter instead of asking all the time on this forum.
|
Looks like that you don't bother to learn anything since I see hundreds of threads by you with scripting questions.
|
This subforum is meant to ask for help.
That doesn't mean that he doesn't bother to learn anything. How can you be so sure? Your first reply on this topic was completely useless, you can go to all topics where people ask some help in scripting questions, and answer: "Go learn basics.". So you should stop posting replies like that. |