06.08.2017, 08:23
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?
This should spawn cars on game mode init.Where's the problem
This is a command for creating vehicles.
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); } }
Код:
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; }
Код:
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; }