Create Vehicle
#1

Hi,
I wanted to make a kind of private vehicle system which allowes a player to use /buycar and /savecar...so he can park the car he bought whereever he wants...well as far as good...
np with spawning the car and changing the pos off it when it respawns... but how can I make them load again after a gamemode restart?... (I'd like to put all those vehicles into 1 file)


would be cool if you could help me
Reply
#2

are you using dini or some other file reader/writer? if not you will need to learn to use them in order to save the positions and model for use with OnGamemodeInit.
Reply
#3

I don't want to make a whole script but you can just get vehicle coords OnPlayerExitVehicle
and like
pawn Код:
OnPlayerExitVehicle(playerid, vehicleid) //I thought
{
 if(vehicleid == ownedvehicle[playerid]) /* or something */
 {
   new Float:vx, Float:vy, Float:vz, Float:va;
   GetVehiclePos(vehicleid, vx, vy, vz);
   GetVehicleZAngle(vehicleid, va);
/* and save to a file */
 }
}
Reply
#4

well I'm currently using normal "fopen , fread and fclose", but I can use dini....
and my problem is not how to save them..I was more wondering about how to reload them after the restart
Reply
#5

I use djson so im not sure how the others work but i expect you'd save the modelid x,y,z,angle into a file and load them in you're CreateVehicle function inside OnGamemodeInit, id give an example with djson but im in a rush for the england game hope this helps (probably wont)
Reply
#6

well I have no problem with making it with 1 vehicle only..
but I need to do it with more..and I don't know how to do it then:
Reply
#7

pawn Код:
public OnVehicleSpawn(vehicleid)
{
  for(new i; i<MAX_PLAYERS; i++)
  {
   if(vehicleid == ownedvehicle[i])
   {
     fopen/read/close
     SetVehiclePos...
     SetVehicleZAngle...
   }
  }
  return 1;
}
Reply
#8

yea yea...
but how to do it with MORE THAN ONE vehicle?...

I know how to get the coords of 1 vehicle..
but how can I do it with an amount I don't know?...
so like:

CreateVehicle(dini_Int(dat, "Model"), dini_Int(dat, "X"), etc)

but with all of the saved vehicles
?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)