Thanks cash!
That would be something like
re=readfile("players.dta")
player_file$=readline(re)
player_name$=readline(re)
player_party$=readline(re)
closefile re
if filetype(player_file$)=1 ; file exists?
player(count)=loadanimmesh(player_file$)
name$(count)=player_name$
party$(count)=player_party$
count=count+1
endif
Assuming there is a file named "players.dta" with the following content:
myplayer.b3d
Freddy
Soviet
The file can be created with notepad, or any other tool.
Using ReadLine is very straight forward. You won't have to worry about String delimiters etc. simply use 1 line=1parameter. You can also use numeric values that way, they will be converted from strings to float or int automaticly. This method also allows to open the file in a text editor and alter/check things manually.
Reading things from a file is simple, but you should not put the player and the ammo in an unsorted list. Instead your File(s) need a structure that can be recognized by the engine. There are several methods, one is the fixed LEnght parameter blocks method (that's what I use most times):
There is a number of objects in a list and each block has a fixed number of lines, eg:
mesh path
position x
y
z
pitch
yaw
roll
scalex
scaley
scalez
entityFX
ENtityAlpha
Basicly you should sit down and write your list of parameters you plan to use. It may be a good idea to "wrap" every possible property, simply parse the command reference to see all possible entity Properties. You best add a dozen or so of "reserved" lines to the block structure, for future updates.
Although this method may seem uneconomical, you will only waste a couple of kilobytes after all, it's a straight forward method. simply read all bocks of a file until EOF is reached.
An other method will use variable names and values. This way the blocks may have an individual lenght. But it also complicates things.
FILEPATH
ammobox.3ds
X-LOCATION
312.5
and so on...
END_OF_OBJECT
FILEPATH
crate.b3d
X_LOCATION
...
You see you need to store only the required parameters, Undefined properties may use default values (like EntityFX or EntityAlpha etc.)
So the level items can be positioned easily this way, but I would suggest to use a diffrent, special structure for an entity like Player 1, or AI Bots or Multiplayer Chars etc. Maybe you should even use a seperate File for the player info.