Saving Player Owned Cars to a File
#1

Hello. I am a very logical person and an experienced scripter, but I am having a problem with one thing. I am not very skilled or logical when it comes to appending and reading data from files.

Here is the format I would like to use for the cars:
Code:
owner|posX|posY|posZ|rotation|alarm
the owner field would be a name, such as Kyle_Smith or Damian_Oden
posX, posY, posZ, rotation; we all know these
alarm is a numeric value - either 0, 1 or 2

What I would like to do is make it so that when someone uses a command and it spawns the car using CreateVehicle, I would like it to write this to a file named PlayerCars.cfg, mind you, with the alarm variable at 0. I would also like to make a /park command which lets the player place their vehicle anywhere they want. When they do /park, I would like it to get the car's position and write it to posX|posY|posZ|rotation. Can anyone provide me these snippets?
Reply
#2

hmmm. nobody can help?
Reply
#3

Try to use dini or DJson, however it doesn't save to .cfg and it wouldn't be the same format. The format will be like this.
Code:
Owner=Neoz
Price=13905719
Alarm=1
For example.
Reply
#4

Quote:
Originally Posted by ʎυe‾ʎ
Hello. I am a very logical person and an experienced scripter, but I am having a problem with one thing. I am not very skilled or logical when it comes to appending and reading data from files.

Here is the format I would like to use for the cars:
Code:
owner|posX|posY|posZ|rotation|alarm
the owner field would be a name, such as Kyle_Smith or Damian_Oden
posX, posY, posZ, rotation; we all know these
alarm is a numeric value - either 0, 1 or 2

What I would like to do is make it so that when someone uses a command and it spawns the car using CreateVehicle, I would like it to write this to a file named PlayerCars.cfg, mind you, with the alarm variable at 0. I would also like to make a /park command which lets the player place their vehicle anywhere they want. When they do /park, I would like it to get the car's position and write it to posX|posY|posZ|rotation. Can anyone provide me these snippets?
That can be done using the native Pawn functions (fopen, fwrite, fread, fclose), 'strtok' and 'format'.
But, as told before by neoz, it is best if you use Dini or DJSon (Never tried it, but looks good)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)