SA-MP Forums Archive
Saving object materials (textures AND text) for maps - 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)
+--- Thread: Saving object materials (textures AND text) for maps (/showthread.php?tid=355582)



Saving object materials (textures AND text) for maps - MP2 - 30.06.2012

I have a mapping system on my server and maps are saved in raw data in this format:

model x y z rx ry rz group

But I'd like to implement saving for material textures and text. I need help working out the best way to do this.

Obviously only material indexes that HAVE materials changed need to be saved - no need to waste space. The thing is the format will be different for textures and text - textures have this data to be saved:

materialindex, &modelid, txdname[], texturename[], &materialcolor

while text has:
materialindex, text[], &materialsize, fontface[], &fontsize, &bold, &fontcolor, &backcolor, &textalignment

So obviously I would need to identify in the data what type of material is applied - texture or text.

I have a rough idea how to do this, just not sure how to implement it with sscanf. Also a problem is spaces - there may be spaces in the material text and the material text font. Would there be a better option than sscanf or what? Would I have to use a different delimiter? I don't want to edit the format of the model x y z rx ry rz group part because then players lose their old maps. It seems very complicated to me (not sscanf - trying to save all this data on one line).

Thoughts please.

Here is one of my theories:

Write the line like so, for text at least, material textures are easier:

model x y z rx ry rz group materialindex materialtype text[?] materialsize fontface[?] fontsize, bold, fontcolor backcolor textalignment

By changing the delimiter in sscanf you could find the end of the text/fontface. Ugh. I'm really confused about this for some reason. Another thing I need to stress is that materials can either be textures or text - so sscanf would need to be used twice - one to read the 'material type' then again to get the data for that ONE material index, and do the same for them all on that line.

Theory #2
Perhaps materials should go down on to the next line?


AW: Saving object materials (textures AND text) for maps - Drebin - 30.06.2012

Use an integer for every object which defines the material. 0 for default texture, 1 for different material, 2 for text written on it. Simply check the value of this integer and relating this value process the data of the object.


Re: Saving object materials (textures AND text) for maps - MP2 - 30.06.2012

You didn't read my entire post though. Objects can have many material indexes - some may be textures some may be text. I'm also not sure how to 'process' this data. Writing it isn't really a problem, apart from the spaces issue.