Szép estét.
Elkészítettem egy jármû mentés / betöltéses szkriptet.
Amit ment a jármûvön: - Színek
- Festõmunka
- Rendszám
- Pozíció ahol elmentetted
- Komponensek (pl. kerék, szélterelõ stb..)
Ha le spawnolsz akkor automatikusan betölti a jármûvedet ott ahol elmentetted.
Parancsok: - /createvehicle -
FONTOS!!! Ha azt akarod, hogy a színek, festõmunka, rendszám is mentõdjön ezzel a paranccsal kell létrehoznod jármûvet! - /savevehicle - Ha kocsiban ülsz eltudod menteni azt
- /loadvehicle - Jármû betöltése ott ahol vagy (automatikusan belerak a jármûbe)
#include a_samp
#include zcmd
#include sscanf2
#include dini
#define File(%1) format(vehfile, sizeof(vehfile), \"VehSystem/%s.ini\", GetName(%1))
enum vehicle {
Color1,
Color2,
Paintjob,
NumberPlate[9]
}
new VEHICLE[MAX_VEHICLES][vehicle],
vehfile[128];
public OnPlayerSpawn(playerid) {
File(playerid);
if(dini_Exists(vehfile)) {
new Float: Pos[4], vehid, color1, color2, paintjob, numplate[9], tunes[128];
vehid = dini_Int(vehfile, \"Model\");
color1 = dini_Int(vehfile, \"Color1\");
color2 = dini_Int(vehfile, \"Color2\");
paintjob = dini_Int(vehfile, \"Paintjob\");
Pos[0] = dini_Float(vehfile, \"VehX\");
Pos[1] = dini_Float(vehfile, \"VehY\");
Pos[2] = dini_Float(vehfile, \"VehZ\");
Pos[3] = dini_Float(vehfile, \"VehA\");
format(numplate, sizeof(numplate), \"%s\", dini_Get(vehfile, \"Numberplate\"));
new vehicleid = CreateVehicle(vehid, Pos[0], Pos[1], Pos[2], Pos[3], color1, color2, -1);
SetPVarInt(playerid, \"MyVehicle\", vehicleid);
SetVehicleNumberPlate(vehicleid, numplate);
SetVehicleVirtualWorld(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerInterior(playerid));
for(new i; i < 14; i++) {
format(tunes, 32, \"Tune%i\", i);
AddVehicleComponent(vehicleid, dini_Int(vehfile, tunes));
}
ChangeVehiclePaintjob(vehicleid, paintjob);
}
return 1;
}
CMD:createvehicle(playerid, params[]) {
new model, color1, color2, paintjob, numplate[9], mycar, Float: Pos[4];
if(sscanf(params, \"iiiis[9]\", model, color1, color2, paintjob, numplate)) return SendClientMessage(playerid, -1, \"Használat: /createvehicle [Model ID] [szín 1] [szín 2] [Festõmunka] [Rendszám]\");
if(strlen(numplate) > return SendClientMessage(playerid, 0xFF4646AA, \"-- A rendszám maximum 8 karakterbõl állhat!\");
if(color1 > 255) return SendClientMessage(playerid, 0xFF4646AA, \"-- A szín1 maximum 255-ig terjedhet!\");
if(color2 > 255) return SendClientMessage(playerid, 0xFF4646AA, \"-- A szín2 maximum 255-ig terjedhet!\");
if(paintjob > 6) return SendClientMessage(playerid, 0xFF4646AA, \"-- A festõmunka maximum 5-ig terjedhet!\");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
if(GetPVarInt(playerid, \"MyVehicle\") != INVALID_VEHICLE_ID) {
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == GetPVarInt(playerid, \"MyVehicle\")) RemovePlayerFromVehicle(playerid);
DestroyVehicle(GetPVarInt(playerid, \"MyVehicle\"));
}
SetPVarInt(playerid, \"MyVehicle\", CreateVehicle(model, Pos[0] + 2.5, Pos[1], Pos[2] + 2.5, Pos[3], color1, color2, -1));
SetVehicleNumberPlate(GetPVarInt(playerid, \"MyVehicle\"), numplate);
ChangeVehiclePaintjob(GetPVarInt(playerid, \"MyVehicle\"), paintjob);
PutPlayerInVehicle(playerid, GetPVarInt(playerid, \"MyVehicle\"), 0);
SetVehicleVirtualWorld(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerInterior(playerid));
mycar = GetPlayerVehicleID(playerid);
VEHICLE[mycar][Color1] = color1;
VEHICLE[mycar][Color2] = color2;
VEHICLE[mycar][Paintjob] = paintjob;
VEHICLE[mycar][NumberPlate] = numplate;
return 1;
}
CMD:savevehicle(playerid, params[]) {
new vehicleid = GetPlayerVehicleID(playerid), tunes[128], Float: Pos[4];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
File(playerid);
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF4646AA, \"-- Nem ülsz jármûben!\");
if(!dini_Exists(vehfile)) {
dini_Create(vehfile);
dini_IntSet(vehfile, \"Model\", GetVehicleModel(vehicleid));
dini_IntSet(vehfile, \"Color1\", VEHICLE[vehicleid][Color1]);
dini_IntSet(vehfile, \"Color2\", VEHICLE[vehicleid][Color2]);
dini_IntSet(vehfile, \"Paintjob\", VEHICLE[vehicleid][Paintjob]);
dini_Set(vehfile, \"NumberPlate\", VEHICLE[vehicleid][NumberPlate]);
dini_FloatSet(vehfile, \"VehX\", Pos[0]);
dini_FloatSet(vehfile, \"VehY\", Pos[1]);
dini_FloatSet(vehfile, \"VehZ\", Pos[2]);
dini_FloatSet(vehfile, \"VehA\", Pos[3]);
for(new i; i < 14; i++) {
format(tunes, 32, \"Tune%i\", i);
dini_IntSet(vehfile, tunes, GetVehicleComponentInSlot(vehicleid, i));
}
} else {
dini_IntSet(vehfile, \"Model\", GetVehicleModel(vehicleid));
dini_IntSet(vehfile, \"Color1\", VEHICLE[vehicleid][Color1]);
dini_IntSet(vehfile, \"Color2\", VEHICLE[vehicleid][Color2]);
dini_IntSet(vehfile, \"Paintjob\", VEHICLE[vehicleid][Paintjob]);
dini_Set(vehfile, \"NumberPlate\", VEHICLE[vehicleid][NumberPlate]);
dini_FloatSet(vehfile, \"VehX\", Pos[0]);
dini_FloatSet(vehfile, \"VehY\", Pos[1]);
dini_FloatSet(vehfile, \"VehZ\", Pos[2]);
dini_FloatSet(vehfile, \"VehA\", Pos[3]);
for(new i; i < 14; i++) {
format(tunes, 32, \"Tune%i\", i);
dini_IntSet(vehfile, tunes, GetVehicleComponentInSlot(vehicleid, i));
}
}
SendClientMessage(playerid, 0xFFFF99AA, \"* Jármûved sikeresen elmentve!\");
return 1;
}
CMD:loadvehicle(playerid, params[]) {
File(playerid);
if(!dini_Exists(vehfile)) return SendClientMessage(playerid, 0xFF4646AA, \"-- Neked nincs mentett jármûved!\");
new Float: Pos[4], vehid, color1, color2, paintjob, numplate[9], tunes[128];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
vehid = dini_Int(vehfile, \"Model\");
color1 = dini_Int(vehfile, \"Color1\");
color2 = dini_Int(vehfile, \"Color2\");
paintjob = dini_Int(vehfile, \"Paintjob\");
format(numplate, sizeof(numplate), \"%s\", dini_Get(vehfile, \"Numberplate\"));
if(GetPVarInt(playerid, \"MyVehicle\") != INVALID_VEHICLE_ID) {
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == GetPVarInt(playerid, \"MyVehicle\")) RemovePlayerFromVehicle(playerid);
DestroyVehicle(GetPVarInt(playerid, \"MyVehicle\"));
}
new vehicleid = CreateVehicle(vehid, Pos[0], Pos[1], Pos[2], Pos[3], color1, color2, -1);
SetPVarInt(playerid, \"MyVehicle\", vehicleid);
SetVehicleNumberPlate(vehicleid, numplate);
PutPlayerInVehicle(playerid, GetPVarInt(playerid, \"MyVehicle\"), 0);
SetVehicleVirtualWorld(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(GetPVarInt(playerid, \"MyVehicle\"), GetPlayerInterior(playerid));
for(new i; i < 14; i++) {
format(tunes, 32, \"Tune%i\", i);
AddVehicleComponent(vehicleid, dini_Int(vehfile, tunes));
}
ChangeVehiclePaintjob(vehicleid, paintjob);
SendClientMessage(playerid, 0xFFFF99AA, \"* Mentett jármûved sikeresen betöltve!\");
return 1;
}
stock GetName(playerid) {
new name[24+1];
GetPlayerName(playerid, name, sizeof(name));
return name;
}