Problem at the gamemode !
#1

Hello,

I've been working for this thing about 2 months and i didn't manage it. Listen/Read carefully below.

Код:
stock SetupVehiclesFile()
{
    new File: file;
    file = fopen(V_FILE_SAVE, io_write);
    new SplitDiv[99][MAX_VEHICLES];
	new filestring[256];
	file = fopen(V_FILE_LOAD, io_read);
	new carcost[MAX_VEHICLES];
	for(new vehicleid=1;vehicleid<=vehcount;vehicleid++)
	{
		if (file)
		{
			fread(file, filestring);
		 	split(filestring, SplitDiv, ',');
			VehicleInfo[vehicleid][model] = strval(SplitDiv[0]);
			VehicleInfo[vehicleid][x_spawn] = floatstr(SplitDiv[1]);
			VehicleInfo[vehicleid][y_spawn] = floatstr(SplitDiv[2]);
			VehicleInfo[vehicleid][z_spawn] = floatstr(SplitDiv[3]);
			VehicleInfo[vehicleid][za_spawn] = floatstr(SplitDiv[4]);
			VehicleInfo[vehicleid][ox_spawn] = floatstr(SplitDiv[1]);
			VehicleInfo[vehicleid][oy_spawn] = floatstr(SplitDiv[2]);
			VehicleInfo[vehicleid][oz_spawn] = floatstr(SplitDiv[3]);
			VehicleInfo[vehicleid][oza_spawn] = floatstr(SplitDiv[4]);
			VehicleInfo[vehicleid][color_1] = strval(SplitDiv[5]);
			VehicleInfo[vehicleid][color_2] = strval(SplitDiv[6]);
			CreateVehicle(VehicleInfo[vehicleid][model], VehicleInfo[vehicleid][x_spawn], VehicleInfo[vehicleid][y_spawn], VehicleInfo[vehicleid][z_spawn], VehicleInfo[vehicleid][za_spawn], VehicleInfo[vehicleid][color_1], VehicleInfo[vehicleid][color_2],20000);
			onsys[vehicleid] = 1;
			carcost[vehicleid] = 50000;
    		for(new s=0; s<24; s++) {
     			if(VehicleInfo[vehicleid][model] == heavycar[s][0]) {
       				carcost[vehicleid] = 100000;
   	        	}
			}
			for(new a=0; a<11; a++) {
     			if(VehicleInfo[vehicleid][model] == boat[a][0]) {
       				carcost[vehicleid] = 50000;
   	   		     }
			}
			for(new mb=0; mb<11; mb++) {
	     		if(VehicleInfo[vehicleid][model] == mbike[mb][0]) {
   	    			carcost[vehicleid] = 40000;
	   	        }
			}
			for(new d=0; d<3; d++) {
   		  		if(VehicleInfo[vehicleid][model] == pbike[d][0]) {
       				carcost[vehicleid] = 3000;
   	   		     }
			}
			for(new e=0; e<6; e++) {
    	 		if(VehicleInfo[vehicleid][model] == splane[e][0]) {
       				carcost[vehicleid] = 500000;
   	        	}
			}
			for(new f=0; f<2; f++) {
     			if(VehicleInfo[vehicleid][model] == mplane[f][0]) {
       					carcost[vehicleid] = 1500000;
   	    	    }
			}
			for(new v=0; v<2; v++) {
     			if(VehicleInfo[vehicleid][model] == lplane[v][0]) {
       				carcost[vehicleid] = 2000000;
   	    	    }
			}
			for(new n=0; n<4; n++) {
     			if(VehicleInfo[vehicleid][model] == milair[n][0]) {
       				carcost[vehicleid] = 4000000;
   	        	}
			}
			for(new j=0; j<4; j++) {
     			if(VehicleInfo[vehicleid][model] == sheli[j][0]) {
       				carcost[vehicleid] = 750000;
   	        	}
			}
			for(new k=0; k<3; k++) {
     			if(VehicleInfo[vehicleid][model] == lheli[k][0]) {
       				carcost[vehicleid] = 1250000;
   	        	}
			}
			VehicleInfo[vehicleid][vehiclecost] = carcost[vehicleid];
			VehicleInfo[vehicleid][vused] = 0;
			VehicleInfo[vehicleid][bought] = 0;
			VehicleInfo[vehicleid][secure] = 0;
			VehicleInfo[vehicleid][asecure] = 0;
			VehicleInfo[vehicleid][buybar] = 0;
			VehicleInfo[vehicleid][mod1] = 0;
			VehicleInfo[vehicleid][mod2] = 0;
			VehicleInfo[vehicleid][mod3] = 0;
			VehicleInfo[vehicleid][mod4] = 0;
			VehicleInfo[vehicleid][mod5] = 0;
			VehicleInfo[vehicleid][mod6] = 0;
			VehicleInfo[vehicleid][mod7] = 0;
			VehicleInfo[vehicleid][mod8] = 0;
			VehicleInfo[vehicleid][mod9] = 0;
			VehicleInfo[vehicleid][mod10] = 0;
			VehicleInfo[vehicleid][mod11] = 0;
			VehicleInfo[vehicleid][mod12] = 0;
			VehicleInfo[vehicleid][mod13] = 0;
			VehicleInfo[vehicleid][mod14] = 0;
			VehicleInfo[vehicleid][mod15] = 0;
			VehicleInfo[vehicleid][mod16] = 0;
			VehicleInfo[vehicleid][mod17] = 0;
			VehicleInfo[vehicleid][paintjob] = -1;
			strmid(VehicleInfo[vehicleid][owner], DEFAULT_OWNER, 0, strlen(DEFAULT_OWNER), 255);
            strmid(VehicleInfo[vehicleid][name], VehicleName[GetVehicleModel(vehicleid)-400][0], 0, strlen(VehicleName[GetVehicleModel(vehicleid)-400][0]), 255);
			new addmess[256];
			format(addmess,sizeof(addmess),"--:: Vehicle %d (%s) successfully spawned ::--",vehicleid,VehicleInfo[vehicleid][name]);
			//print(addmess);
		}
	}
	fclose(file);
//	print(">------------------------------------------------");
//	print(" ");
//	print(">------------------------------------------------");
//	print("Initialising Vehicle File System - Please Wait For Confirmation...");
//	print(" ");
	SaveVehicles();
//	print(" ");
//	print("Vehicle File System 100% Initialised...");
//	print(">------------------------------------------------");
//	printf(" ");
}

stock LoadVehicles()
{
	if(fexist(V_FILE_SAVE)) {
        new SplitDiv[99][MAX_VEHICLES];
		new filestring[256];
		new File: file = fopen(V_FILE_SAVE, io_read);
		if (file) {
	    	for(new vehicleid = 1;vehicleid<=vehcount;vehicleid++)
			{
		    	fread(file, filestring);
				split(filestring, SplitDiv, ',');
				VehicleInfo[vehicleid][model] = strval(SplitDiv[0]);
				VehicleInfo[vehicleid][x_spawn] = floatstr(SplitDiv[1]);
				VehicleInfo[vehicleid][y_spawn] = floatstr(SplitDiv[2]);
				VehicleInfo[vehicleid][z_spawn] = floatstr(SplitDiv[3]);
				VehicleInfo[vehicleid][za_spawn] = floatstr(SplitDiv[4]);
				VehicleInfo[vehicleid][ox_spawn] = floatstr(SplitDiv[5]);
				VehicleInfo[vehicleid][oy_spawn] = floatstr(SplitDiv[6]);
				VehicleInfo[vehicleid][oz_spawn] = floatstr(SplitDiv[7]);
				VehicleInfo[vehicleid][oza_spawn] = floatstr(SplitDiv[8]);
				VehicleInfo[vehicleid][color_1] = strval(SplitDiv[9]);
				VehicleInfo[vehicleid][color_2] = strval(SplitDiv[10]);
				VehicleInfo[vehicleid][vehiclecost] = strval(SplitDiv[11]);
				VehicleInfo[vehicleid][bought] = strval(SplitDiv[12]);
				VehicleInfo[vehicleid][secure] = strval(SplitDiv[13]);
				VehicleInfo[vehicleid][asecure] = strval(SplitDiv[14]);
				VehicleInfo[vehicleid][vused] = 0;
				VehicleInfo[vehicleid][buybar] = strval(SplitDiv[16]);
				VehicleInfo[vehicleid][mod1] = strval(SplitDiv[17]);
				VehicleInfo[vehicleid][mod2] = strval(SplitDiv[18]);
				VehicleInfo[vehicleid][mod3] = strval(SplitDiv[19]);
				VehicleInfo[vehicleid][mod4] = strval(SplitDiv[20]);
				VehicleInfo[vehicleid][mod5] = strval(SplitDiv[21]);
				VehicleInfo[vehicleid][mod6] = strval(SplitDiv[22]);
				VehicleInfo[vehicleid][mod7] = strval(SplitDiv[23]);
				VehicleInfo[vehicleid][mod8] = strval(SplitDiv[24]);
				VehicleInfo[vehicleid][mod9] = strval(SplitDiv[25]);
				VehicleInfo[vehicleid][mod10] = strval(SplitDiv[26]);
				VehicleInfo[vehicleid][mod11] = strval(SplitDiv[27]);
				VehicleInfo[vehicleid][mod12] = strval(SplitDiv[28]);
				VehicleInfo[vehicleid][mod13] = strval(SplitDiv[29]);
				VehicleInfo[vehicleid][mod14] = strval(SplitDiv[30]);
				VehicleInfo[vehicleid][mod15] = strval(SplitDiv[31]);
				VehicleInfo[vehicleid][mod16] = strval(SplitDiv[32]);
				VehicleInfo[vehicleid][mod17] = strval(SplitDiv[33]);
				VehicleInfo[vehicleid][paintjob] = strval(SplitDiv[36]);
				strmid(VehicleInfo[vehicleid][owner], SplitDiv[34], 0, strlen(SplitDiv[34]), 255);
				strmid(VehicleInfo[vehicleid][name], SplitDiv[35], 0, strlen(SplitDiv[35]), 255);
			 	CreateVehicle(VehicleInfo[vehicleid][model], VehicleInfo[vehicleid][x_spawn], VehicleInfo[vehicleid][y_spawn], VehicleInfo[vehicleid][z_spawn], VehicleInfo[vehicleid][za_spawn], VehicleInfo[vehicleid][color_1], VehicleInfo[vehicleid][color_2],20000);
                onsys[vehicleid] = 1;
				new addmess[256];
				format(addmess,sizeof(addmess),"--:: Vehicle %d (%s) successfully Loaded and placed - owner: %s ::--",vehicleid,VehicleInfo[vehicleid][name],VehicleInfo[vehicleid][owner]);
				//print(addmess);
			}
		}
		fclose(file);
	}
	else {
		SetupVehiclesFile();
	}
}

stock SaveVehicles()
{
	new filestring[512];
	new File: vfile = fopen(V_FILE_SAVE, io_write);
    for(new vehicleid = 1;vehicleid<=vehcount;vehicleid++)
 	{
		format(filestring, sizeof(filestring), "%d,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s,%d\n",
		VehicleInfo[vehicleid][model],
		VehicleInfo[vehicleid][x_spawn],
		VehicleInfo[vehicleid][y_spawn],
		VehicleInfo[vehicleid][z_spawn],
		VehicleInfo[vehicleid][za_spawn],
		VehicleInfo[vehicleid][ox_spawn],
		VehicleInfo[vehicleid][oy_spawn],
		VehicleInfo[vehicleid][oz_spawn],
		VehicleInfo[vehicleid][oza_spawn],
		VehicleInfo[vehicleid][color_1],
		VehicleInfo[vehicleid][color_2],
		VehicleInfo[vehicleid][vehiclecost],
		VehicleInfo[vehicleid][bought],
		VehicleInfo[vehicleid][secure],
		VehicleInfo[vehicleid][asecure],
		VehicleInfo[vehicleid][vused],
		VehicleInfo[vehicleid][buybar],
		VehicleInfo[vehicleid][mod1],
		VehicleInfo[vehicleid][mod2],
		VehicleInfo[vehicleid][mod3],
		VehicleInfo[vehicleid][mod4],
		VehicleInfo[vehicleid][mod5],
		VehicleInfo[vehicleid][mod6],
		VehicleInfo[vehicleid][mod7],
		VehicleInfo[vehicleid][mod8],
		VehicleInfo[vehicleid][mod9],
		VehicleInfo[vehicleid][mod10],
		VehicleInfo[vehicleid][mod11],
		VehicleInfo[vehicleid][mod12],
		VehicleInfo[vehicleid][mod13],
		VehicleInfo[vehicleid][mod14],
		VehicleInfo[vehicleid][mod15],
		VehicleInfo[vehicleid][mod16],
		VehicleInfo[vehicleid][mod17],
		VehicleInfo[vehicleid][owner],
		VehicleInfo[vehicleid][name],
		VehicleInfo[vehicleid][paintjob]
		);
		fwrite(vfile, filestring);
	}
	fclose(vfile);
}

stock ModVehicle(vehicleid)
{
	new tuned2 = 0;
	if(VehicleInfo[vehicleid][mod1] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod1]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod2] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod2]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod3] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod3]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod4] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod4]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod5] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod5]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod6] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod6]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod7] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod7]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod8] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod8]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod9] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod9]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod10] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod10]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod11] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod11]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod12] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod12]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod13] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod13]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod14] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod14]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod15] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod15]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod16] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod16]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][mod17] != 0) {
		AddVehicleComponent(vehicleid,VehicleInfo[vehicleid][mod17]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][color_1] > -1 || VehicleInfo[vehicleid][color_2] > -1) {
		ChangeVehicleColor(vehicleid,VehicleInfo[vehicleid][color_1],VehicleInfo[vehicleid][color_2]);
		tuned2 = 1;
	}
	if(VehicleInfo[vehicleid][paintjob] > -1) {
		ChangeVehiclePaintjob(vehicleid,VehicleInfo[vehicleid][paintjob]);
		tuned2 = 1;
	}
	if(tuned2 == 1) {
		tuned++;
	}
}
stock CountVehicles(filename[]) {
	new File:VehicleFile;
	new blank[256];
	new count = 0;
	if (fexist(V_FILE_SAVE)) {
		VehicleFile = fopen(V_FILE_SAVE);
		while(fread(VehicleFile, blank, sizeof blank)) {
			count++;
		}
		fclose(VehicleFile);
	}
	else {
		VehicleFile = fopen(filename);
		while(fread(VehicleFile, blank, sizeof blank)) {
			count++;
		}
		fclose(VehicleFile);
	}
	return count;
}
With these things, How can i make a code to load the vehicles in the server? A code to load the vehicles to my server. Please, help me.

Anyone can help me, +REP.
Reply
#2

I do not understand what you mean, to create and load vehicles?
Reply
#3

Simply, can you just make me a code to load vehicles? With LoadVehicles? Simple question.
Reply
#4

I will be thanksful if you help me
Reply
#5

Credits TheChaoz
Reply
#6

Look, i dont need this thing. I have NFTDM script by Moneypimp, Just can you give me that? I want there be:

Things:

The define will be:

Код:
new vehid1 = 1;
AddCar(model1,Float:X,Float:Y,Float:Z,Float:A,color11,color12) {
The positions, models and etc Like this:
Код:
				VehicleInfo[vehicleid][model] = strval(SplitDiv[0]);
				VehicleInfo[vehicleid][x_spawn] = floatstr(SplitDiv[1]);
				VehicleInfo[vehicleid][y_spawn] = floatstr(SplitDiv[2]);
				VehicleInfo[vehicleid][z_spawn] = floatstr(SplitDiv[3]);
				VehicleInfo[vehicleid][za_spawn] = floatstr(SplitDiv[4]);
				VehicleInfo[vehicleid][ox_spawn] = floatstr(SplitDiv[5]);
				VehicleInfo[vehicleid][oy_spawn] = floatstr(SplitDiv[6]);
				VehicleInfo[vehicleid][oz_spawn] = floatstr(SplitDiv[7]);
				VehicleInfo[vehicleid][oza_spawn] = floatstr(SplitDiv[8]);
				VehicleInfo[vehicleid][color_1] = strval(SplitDiv[9]);
				VehicleInfo[vehicleid][color_2] = strval(SplitDiv[10]);
				VehicleInfo[vehicleid][vehiclecost] = strval(SplitDiv[11]);
				VehicleInfo[vehicleid][bought] = strval(SplitDiv[12]);
				VehicleInfo[vehicleid][secure] = strval(SplitDiv[13]);
				VehicleInfo[vehicleid][asecure] = strval(SplitDiv[14]);
				VehicleInfo[vehicleid][vused] = 0;
				VehicleInfo[vehicleid][buybar] = strval(SplitDiv[16]);
				VehicleInfo[vehicleid][mod1] = strval(SplitDiv[17]);
				VehicleInfo[vehicleid][mod2] = strval(SplitDiv[18]);
				VehicleInfo[vehicleid][mod3] = strval(SplitDiv[19]);
				VehicleInfo[vehicleid][mod4] = strval(SplitDiv[20]);
				VehicleInfo[vehicleid][mod5] = strval(SplitDiv[21]);
				VehicleInfo[vehicleid][mod6] = strval(SplitDiv[22]);
				VehicleInfo[vehicleid][mod7] = strval(SplitDiv[23]);
				VehicleInfo[vehicleid][mod8] = strval(SplitDiv[24]);
				VehicleInfo[vehicleid][mod9] = strval(SplitDiv[25]);
				VehicleInfo[vehicleid][mod10] = strval(SplitDiv[26]);
				VehicleInfo[vehicleid][mod11] = strval(SplitDiv[27]);
				VehicleInfo[vehicleid][mod12] = strval(SplitDiv[28]);
				VehicleInfo[vehicleid][mod13] = strval(SplitDiv[29]);
				VehicleInfo[vehicleid][mod14] = strval(SplitDiv[30]);
				VehicleInfo[vehicleid][mod15] = strval(SplitDiv[31]);
				VehicleInfo[vehicleid][mod16] = strval(SplitDiv[32]);
				VehicleInfo[vehicleid][mod17] = strval(SplitDiv[33]);
				VehicleInfo[vehicleid][paintjob] = strval(SplitDiv[36]);
				strmid(VehicleInfo[vehicleid][owner], SplitDiv[34], 0, strlen(SplitDiv[34]), 255);
				strmid(VehicleInfo[vehicleid][name], SplitDiv[35], 0, strlen(SplitDiv[35]), 255);
			 	CreateVehicle(VehicleInfo[vehicleid][model], VehicleInfo[vehicleid][x_spawn], VehicleInfo[vehicleid][y_spawn], VehicleInfo[vehicleid][z_spawn], VehicleInfo[vehicleid][za_spawn], VehicleInfo[vehicleid][color_1], VehicleInfo[vehicleid][color_2],20000);
                onsys[vehicleid] = 1;
And for heavy cars, etc,

And when a vehicle is created it could say like:

Код:
    print("-");
    print("--------------Vehicle Created--------------");
    printf("- Carid: %d", vehid1);
    printf("- Buy Cost: %d",Cost);
    printf("- Sell Cost: %d",Cost);
    printf("- Interior: 0");
    printf("- VirtualWorld: 0");
    print("-----------------------------------------");
    }
    return vehid1 ++;
I will be thanksful if you could understand and make like that to me


Thanks !!!!!

EDIT: A buyable car if you can like that above the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)