#include <a_samp>#include <sscanf2>#include <streamer>#include <YSI\\y_ini>#include <iZCMD>#define JARMUVEK_HELYE \"FCRP/Jarmuvek/%d.ini\"enum ENUM_JARMU_INFO{bool:JarmuVan,jID,jModelID,jTipus,Float: jPosX,Float: jPosY,Float: jPosZ,Float: jPosA,jColor1,jColor2,jTulajdonos[MAX_PLAYER_NAME],jAr,Float:jElet,jPanelok,jAjtok,jLampak,jKerekek}new JarmuInfo[MAX_VEHICLES][ENUM_JARMU_INFO];main(){print(\"\\n----------------------------------\");print(\" Blank Gamemode by your name here\");print(\"----------------------------------\\n\");}public OnGameModeInit(){// Don\'t use these lines if it\'s a filterscriptSetGameModeText(\"Blank Script\");AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);JarmuvekBetoltese();return 1;}public OnGameModeExit(){JarmuvekMentese();return 1;}stock JarmuvekMentese(){for(new ji=1;ji < MAX_VEHICLES;ji++){ JarmuMentes(ji); DestroyVehicle(JarmuInfo[ji][jID]);}}stock JarmuMentes(jarmuid){new jFajl[35], modelid, Float:pos[4]; if(JarmuInfo[jarmuid][JarmuVan] == false) return 0;modelid = GetVehicleModel(jarmuid);GetVehiclePos(jarmuid, pos[0], pos[1], pos[2]);GetVehicleZAngle(jarmuid, pos[3]);new panels, doors, lights, tires, Float:vElet;GetVehicleDamageStatus(jarmuid, panels, doors, lights, tires);GetVehicleHealth(jarmuid, vElet);format(jFajl, sizeof(jFajl), JARMUVEK_HELYE, jarmuid); new INI:File = INI_Open(jFajl); INI_WriteInt(File, \"ModelID\", modelid); INI_WriteFloat(File, \"PosX\", pos[0]); INI_WriteFloat(File, \"PosY\", pos[1]); INI_WriteFloat(File, \"PosZ\", pos[2]); INI_WriteFloat(File, \"PosA\", pos[3]); INI_WriteInt(File, \"Color1\", JarmuInfo[jarmuid][jColor1]); INI_WriteInt(File, \"Color2\", JarmuInfo[jarmuid][jColor2]); INI_WriteString(File, \"Tulajdonos\", JarmuInfo[jarmuid][jTulajdonos]); INI_WriteInt(File, \"Ar\", JarmuInfo[jarmuid][jAr]); INI_WriteFloat(File, \"Elet\", vElet); INI_WriteInt(File, \"Panelok\", panels); INI_WriteInt(File, \"Ajtok\", doors); INI_WriteInt(File, \"Lampak\", lights); INI_WriteInt(File, \"Kerekek\", tires); INI_Close(File); return 1;}stock JarmuvekBetoltese(){new jarmucount;for(new ji = 1; ji < MAX_VEHICLES; ji++) { new jFajl[35]; format(jFajl, 35, JARMUVEK_HELYE ,ji); if(fexist(jFajl)) { INI_ParseFile(jFajl, \"JarmuBetolt\", .bExtra = true, .extra = ji); JarmuBetoltes(ji); jarmucount++; printf(\"%d jármű betöltve\", jarmucount); }}}forward JarmuBetolt(id, name[], value[]);public JarmuBetolt(id, name[], value[]){JarmuInfo[id][JarmuVan] = true; INI_Int(\"ModelID\", JarmuInfo[id][jModelID]); INI_Float(\"PosX\", JarmuInfo[id][jPosX]); INI_Float(\"PosY\", JarmuInfo[id][jPosY]); INI_Float(\"PosZ\", JarmuInfo[id][jPosZ]); INI_Float(\"PosA\", JarmuInfo[id][jPosA]); INI_Int(\"Color1\", JarmuInfo[id][jColor1]); INI_Int(\"Color2\", JarmuInfo[id][jColor2]); INI_String(\"Tulajdonos\", JarmuInfo[id][jTulajdonos]); INI_Int(\"Ar\", JarmuInfo[id][jAr]); INI_Float(\"Elet\", JarmuInfo[id][jElet]); INI_Int(\"Panelok\", JarmuInfo[id][jPanelok]); INI_Int(\"Ajtok\", JarmuInfo[id][jAjtok]); INI_Int(\"Lampak\", JarmuInfo[id][jLampak]); INI_Int(\"Kerekek\", JarmuInfo[id][jKerekek]); return 1;}stock JarmuBetoltes(jarmuid){ JarmuInfo[jarmuid][jID] = AddStaticVehicleEx (JarmuInfo[jarmuid][jModelID], JarmuInfo[jarmuid][jPosX], JarmuInfo[jarmuid][jPosY], JarmuInfo[jarmuid][jPosZ], JarmuInfo[jarmuid][jPosA], JarmuInfo[jarmuid][jColor1], JarmuInfo[jarmuid][jColor2], -1, 0);SetVehicleParamsEx(jarmuid, 0, 0, 0, 0, 0, 0, 0);UpdateVehicleDamageStatus(jarmuid, JarmuInfo[jarmuid][jPanelok], JarmuInfo[jarmuid][jAjtok], JarmuInfo[jarmuid][jLampak], JarmuInfo[jarmuid][jKerekek]);SetVehicleHealth(jarmuid, JarmuInfo[jarmuid][jElet]);return 1;} stock ElerhetoJarmuID(){for(new ji = 1; ji<MAX_VEHICLES; ji++){ if(JarmuInfo[ji][JarmuVan] == false) return ji;}return -1;}stock GetName(playerid){new name[MAX_PLAYER_NAME];GetPlayerName(playerid,name,sizeof(name));return name;}
stock JarmuBetoltes(jarmuid){ JarmuInfo[jarmuid][jID] = AddStaticVehicleEx (JarmuInfo[jarmuid][jModelID], JarmuInfo[jarmuid][jPosX], JarmuInfo[jarmuid][jPosY], JarmuInfo[jarmuid][jPosZ], JarmuInfo[jarmuid][jPosA], JarmuInfo[jarmuid][jColor1], JarmuInfo[jarmuid][jColor2], -1, 0);SetVehicleParamsEx(jarmuid, 0, 0, 0, 0, 0, 0, 0);UpdateVehicleDamageStatus(jarmuid, JarmuInfo[jarmuid][jPanelok], JarmuInfo[jarmuid][jAjtok], JarmuInfo[jarmuid][jLampak], JarmuInfo[jarmuid][jKerekek]);SetVehicleHealth(jarmuid, JarmuInfo[jarmuid][jElet]);return 1;}
-
Itt ne a jarmuid-ra hivatkozz, hanem a JarmuInfo[jarmuid][jID]-ra Továbbá ha a létrehozott járművet a saját ID-ján akarod tartani, akkor hozz létre egy tömböt amiben a SA-MP-os járművekhez eltárolod a Jármű rendszeredhez tartozó ID-kat és akkor arra hivatkozol amikor adatot akarsz lekérdezni, így független lesz attól, hogy ID-n jön létre a SA-MP-os jármű.
// Felülrenew MyVehicleIDs[MAX_VEHICLES];//Jármű betöltés alá:MyVehicleIDs[JarmuInfo[jarmuid][jID]] = jarmuid;// Mentésnél meg marad ez hivatkozásként SA-MP-re járműre:JarmuInfo[jarmuid][jID] // SA-MP-s jármű események alatt pl így hivatkozhatsz:public OnVehicleMod(playerid,vehicleid,componentid){ SetVehicleHealth(vehicleid, JarmuInfo[MyVehicleIDs[vehicleid]][jElet]); // jarmuid = MyVehicleIDs[vehicleid] return 1;}
stock JarmuBetoltes(jarmuid){MyVehicleIDs[JarmuInfo[jarmuid][jID]] = jarmuid; JarmuInfo[jarmuid][jID] = AddStaticVehicleEx (JarmuInfo[jarmuid][jModelID], JarmuInfo[jarmuid][jPosX], JarmuInfo[jarmuid][jPosY], JarmuInfo[jarmuid][jPosZ], JarmuInfo[jarmuid][jPosA], JarmuInfo[jarmuid][jColor1], JarmuInfo[jarmuid][jColor2], -1, 0);SetVehicleParamsEx(jarmuid, 0, 0, 0, 0, 0, 0, 0);UpdateVehicleDamageStatus(jarmuid, JarmuInfo[jarmuid][jPanelok], JarmuInfo[jarmuid][jAjtok], JarmuInfo[jarmuid][jLampak], JarmuInfo[jarmuid][jKerekek]);SetVehicleHealth(jarmuid, JarmuInfo[jarmuid][jElet]);return 1;}
stock JarmuMentes(jarmuid){new jFajl[35], modelid, Float:pos[4]; if(JarmuInfo[jarmuid][JarmuVan] == false) return 0;modelid = GetVehicleModel(jarmuid);GetVehiclePos(jarmuid, pos[0], pos[1], pos[2]);GetVehicleZAngle(jarmuid, pos[3]);new panels, doors, lights, tires, Float:vElet;GetVehicleDamageStatus(jarmuid, panels, doors, lights, tires);GetVehicleHealth(jarmuid, vElet);format(jFajl, sizeof(jFajl), JARMUVEK_HELYE, jarmuid); new INI:File = INI_Open(jFajl); INI_WriteInt(File, \"ModelID\", modelid); INI_WriteFloat(File, \"PosX\", pos[0]); INI_WriteFloat(File, \"PosY\", pos[1]); INI_WriteFloat(File, \"PosZ\", pos[2]); INI_WriteFloat(File, \"PosA\", pos[3]); INI_WriteInt(File, \"Color1\", JarmuInfo[jarmuid][jColor1]); INI_WriteInt(File, \"Color2\", JarmuInfo[jarmuid][jColor2]); INI_WriteString(File, \"Tulajdonos\", JarmuInfo[jarmuid][jTulajdonos]); INI_WriteInt(File, \"Ar\", JarmuInfo[jarmuid][jAr]); INI_WriteFloat(File, \"Elet\", vElet); INI_WriteInt(File, \"Panelok\", panels); INI_WriteInt(File, \"Ajtok\", doors); INI_WriteInt(File, \"Lampak\", lights); INI_WriteInt(File, \"Kerekek\", tires); INI_Close(File); return 1;}
SetVehicleParamsEx(jarmuid, 0, 0, 0, 0, 0, 0, 0);
SetVehicleParamsEx(JarmuInfo[jarmuid][jID], 0, 0, 0, 0, 0, 0, 0);
stock JarmuMentes(jarmuid){new jFajl[35], modelid, Float:pos[4]; if(JarmuInfo[jarmuid][JarmuVan] == false) return 0;modelid = JarmuInfo[jarmuid][jModelID];GetVehiclePos(JarmuInfo[jarmuid][jID], pos[0], pos[1], pos[2]);GetVehicleZAngle(JarmuInfo[jarmuid][jID], pos[3]);new panels, doors, lights, tires, Float:vElet;GetVehicleDamageStatus(JarmuInfo[jarmuid][jID], panels, doors, lights, tires);GetVehicleHealth(JarmuInfo[jarmuid][jID], vElet);format(jFajl, sizeof(jFajl), JARMUVEK_HELYE, jarmuid); new INI:File = INI_Open(jFajl); INI_WriteInt(File, \"ModelID\", modelid); INI_WriteFloat(File, \"PosX\", pos[0]); INI_WriteFloat(File, \"PosY\", pos[1]); INI_WriteFloat(File, \"PosZ\", pos[2]); INI_WriteFloat(File, \"PosA\", pos[3]); INI_WriteInt(File, \"Color1\", JarmuInfo[jarmuid][jColor1]); INI_WriteInt(File, \"Color2\", JarmuInfo[jarmuid][jColor2]); INI_WriteString(File, \"Tulajdonos\", JarmuInfo[jarmuid][jTulajdonos]); INI_WriteInt(File, \"Ar\", JarmuInfo[jarmuid][jAr]); INI_WriteFloat(File, \"Elet\", vElet); INI_WriteInt(File, \"Panelok\", panels); INI_WriteInt(File, \"Ajtok\", doors); INI_WriteInt(File, \"Lampak\", lights); INI_WriteInt(File, \"Kerekek\", tires); INI_Close(File); return 1;}