Vehicles aren't spawning
#1

I'm learning about ini_files and i wonder to make something like that.
I made a command to create vehicle and it creates a vehicle but after server restart it doasn't show on the server but everything is properly saved in scriptfiles.
Can someone help me?

Код:
for(new i = 1;i < MAX_VEHS; i++)
	{
	    new v_File[100];
	    format(v_File,sizeof(v_File),VOZILA,i);
	    if(fexist(v_File))
	    {
			INI_ParseFile(v_File,"LoadVehs",.bExtra = true, .extra = i);
			VI[i][vID] = CreateVehicle(VI[i][vModel], VI[i][vX], VI[i][vY], VI[i][vZ], VI[i][vR], VI[i][vBoja1], VI[i][vBoja2], 30000);
	    }
	}
This should spawn cars on game mode init.Where's the problem

Код:
CMD:createveh( playerid, params[] )
{
	new Float:pos[3],Float:rot,boja1,boja2,model;
	if(sscanf(params,"iii",model,boja1,boja2)) return SCM(playerid,-1,"/createveh [id] [boja1] [boja2]");
	new vid = next_vehicle();
	GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
	GetPlayerFacingAngle(playerid,rot);
	VI[vid][vModel] = model;
	VI[vid][vBoja1] = boja1;
	VI[vid][vBoja2] = boja2;
	VI[vid][vX] = pos[0] + 3;
	VI[vid][vY] = pos[1];
	VI[vid][vZ] = pos[2];
	VI[vid][vR] = rot;
	
	VI[vid][vID] = CreateVehicle(VI[vid][vModel], VI[vid][vX], VI[vid][vY], VI[vid][vZ], VI[vid][vR], VI[vid][vBoja1], VI[vid][vBoja2], 30000);
	SaveVehs(vid);
	
	return true;
	
}
This is a command for creating vehicles.

Код:
stock LoadVehs(vehid, name[], value[])
{
	INI_String("Owner",VI[vehid][vOwner],24);
	INI_Int("vID",VI[vehid][vID]);
	INI_Float("X",VI[vehid][vX]);
	INI_Float("Y",VI[vehid][vY]);
	INI_Float("Z",VI[vehid][vZ]);
	INI_Float("R",VI[vehid][vR]);
	INI_Int("Boja1",VI[vehid][vBoja1]);
	INI_Int("Boja2",VI[vehid][vBoja2]);
	INI_Int("Model",VI[vehid][vModel]);
	return 1;
}

stock SaveVehs(vehid)
{
	new vfile[128];
	format(vfile,128,VOZILA,vehid);
	new INI:file = INI_Open(vfile);
	INI_WriteString(file,"Owner",VI[vehid][vOwner]);
	INI_WriteFloat(file,"X",VI[vehid][vX]);
	INI_WriteFloat(file,"Y",VI[vehid][vY]);
	INI_WriteFloat(file,"Z",VI[vehid][vZ]);
	INI_WriteFloat(file,"R",VI[vehid][vR]);
	INI_WriteInt(file,"Boja1",VI[vehid][vBoja1]);
	INI_WriteInt(file,"Boja2",VI[vehid][vBoja2]);
	INI_WriteInt(file,"Model",VI[vehid][vModel]);
	INI_WriteInt(file,"ID",VI[vehid][vID]);
	INI_Close(file);
	return 1;
}
Reply
#2

LoadVehs must be a public function. Also don't abuse "stock" keyword - if you want to define a function, just write its name. stock is used when you don't want a warning about unused function - usually it is used by libraries.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
LoadVehs must be a public function. Also don't abuse "stock" keyword - if you want to define a function, just write its name. stock is used when you don't want a warning about unused function - usually it is used by libraries.
Thanks a lot man !
One more question.. Do I,whenever I wanna load something from file and whenever I'm using parsefile,loading must be forward-public?
Reply
#4

Yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)