format and save to a file..hex colours
#1

I'm trying to save co-ordinates to a text file, i can only get it to save 0.0000

I'm also trying to save hex colours to a text file.

this is what i've tried

pawn Код:
new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    format(GangZoneInfo[spaces][zXpos1], 32, "%f", X);
    format(GangZoneInfo[spaces][zYpos1], 32, "%f", Y);
it compiles fine, no errors or warnings, then when i try to save the position with a command i made it saves as 0.0000

Alsoi've tried this

pawn Код:
new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    GangZoneInfo[spaces][zXpos1] = X;//warning 213: tag mismatch
    GangZoneInfo[spaces][zYpos1] = Y;//warning 213: tag mismatch
only this time i get two warnings.
Reply
#2

Код:
new Float:zXpos1,Float:zYpos1;
Reply
#3

That won't work. zXpos1 is already a created variable.

Reply
#4

Yes and it must be a float
Reply
#5

The variable zXpos1 is used to store the float, for it to be saved into a file.

pawn Код:
enum gzInfo
{
zName[32],
zXpos1,
zYpos1,
zXpos2,
zYpos2
};

new GangZoneInfo[MAX_GANG_ZONES][gzInfo];
Reply
#6

Код:
enum gzInfo
{
zName[32],
Float:zXpos1,
Float:zYpos1,
Float:zXpos2,
Float:zYpos2
};
Reply
#7

Ah yes, cool. Thanks it works now


Do you know how to store hex colours in a variable?

I've tried adding zColor to the gangzone file.

Instead of it saving as a hex colour it saves as a number. for example "30"

pawn Код:
format(GangZoneInfo[spaces][zColor], 32, "0x00000042");
And for writing to the file
pawn Код:
format(info, 32, "Colour=%x\n", GangZoneInfo[spaces][zColor]);fwrite(gzfile, info);
Reply
#8

save them as a string
Reply
#9

Thanks ******, im always hopeful of a solution when i see you've replied to one of my posts

Also thanks to Jefff for all the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)