SA-MP Forums Archive
Spawn Vehicles and save to File - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawn Vehicles and save to File (/showthread.php?tid=88055)



Spawn Vehicles and save to File - Memoryz - 24.07.2009

Im looking for a script that I can spawn a vehicle, and it saves it to a file, so that when the server starts, the file is loaded and the vehicle is spawned.

Like:

/createveh (modelID)

and possibly this, it doesnt matter if it doesnt:

/changevehcolor (color1) (color2)

So what /createveh would do is it would spawn that vehicle infront of you, and it saves it to a file, so that it spawns there again, even if the server restarts.

Anyone have a script that does that or similiar to that

Thanks =)


Re: Spawn Vehicles and save to File - Joe Staff - 24.07.2009

If you're not able to find it in search than use this:
Script Request Thread

Seriously though, what you're describing is a simple script and definately a good thing to start on for a beginner. You should give it a whack atleast.


Re: Spawn Vehicles and save to File - Memoryz - 24.07.2009

Im not a coder, more of a server management typa preson. Thats why Im looking for this script =/


Re: Spawn Vehicles and save to File - Annihalation - 24.07.2009

I'll give you some tips, but no handouts

get dini.inc if you don't have it, get it here

to get it, click that link, click the "downloads" button in the upper right and find "dini v1.6" (use your browser's find function if you cant find it in the page)

then take this and paste it between the brackets in the "public OnVehicleSpawn" part in your file
Код:
  new file[256], Float:vehX, Float:vehY, Float:vehZ, Float:vehR, model;
  model = GetVehicleModel(vehicleid);
  format(file, sizeof(file), "Vehicles/%s.ini", vehicleid);
  if(dini_Exists(file)) return 1; // car exists in database
  GetVehiclePos(vehicleid, vehX, vehY, vehZ);
  GetVehicleZAngle(vehicleid, vehR);
  dini_IntSet(file, "model", model);
  dini_IntSet(file, "posX", vehX);
  dini_IntSet(file, "posY", vehY);
  dini_IntSet(file, "posZ", vehZ);
  dini_IntSet(file, "angle", vehR);
basically, what that does is save every vehicle in the game as a file, labeled the vehicle's ID. It's not very efficient, and doesn't save mods or colors (however, there is no GetVehicleColor, so that's not possible anyways :P)

you can make the "/createveh" command, that part is extremely easy, the first thing I learned about PAWN was to do "/" commands


Re: Spawn Vehicles and save to File - Memoryz - 24.07.2009

Quote:
Originally Posted by Annihalation
I'll give you some tips, but no handouts

get dini.inc if you don't have it, get it here

to get it, click that link, click the "downloads" button in the upper right and find "dini v1.6" (use your browser's find function if you cant find it in the page)

then take this and paste it between the brackets in the "public OnVehicleSpawn" part in your file
Код:
  new file[256], Float:vehX, Float:vehY, Float:vehZ, Float:vehR, model;
  model = GetVehicleModel(vehicleid);
  format(file, sizeof(file), "Vehicles/%s.ini", vehicleid);
  if(dini_Exists(file)) return 1; // car exists in database
  GetVehiclePos(vehicleid, vehX, vehY, vehZ);
  GetVehicleZAngle(vehicleid, vehR);
  dini_IntSet(file, "model", model);
  dini_IntSet(file, "posX", vehX);
  dini_IntSet(file, "posY", vehY);
  dini_IntSet(file, "posZ", vehZ);
  dini_IntSet(file, "angle", vehR);
basically, what that does is save every vehicle in the game as a file, labeled the vehicle's ID. It's not very efficient, and doesn't save mods or colors (however, there is no GetVehicleColor, so that's not possible anyways :P)

you can make the "/createveh" command, that part is extremely easy, the first thing I learned about PAWN was to do "/" commands
Okay, so it will save any vehicle spawned to Vehicles.ini ?


Re: Spawn Vehicles and save to File - Memoryz - 24.07.2009

Im getting
Quote:

C:\samp02Xserver.win32\gamemodes\DoW.pwn(67) : warning 213: tag mismatch
C:\samp02Xserver.win32\gamemodes\DoW.pwn(6 : warning 213: tag mismatch
C:\samp02Xserver.win32\gamemodes\DoW.pwn(69) : warning 213: tag mismatch
C:\samp02Xserver.win32\gamemodes\DoW.pwn(70) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Warnings.




Re: Spawn Vehicles and save to File - Memoryz - 24.07.2009

*bump*