SetPlayerColour loading variable problem -
DaRoderick - 02.01.2013
So, when a player sets his colour, this happens:
pawn Код:
PlayerInfo[playerid][pIconColour] = 0xE85A7AFF;
Now the colour works and is viewable on the map perfectly.
Then, it gets saved on disconnect:
pawn Код:
dini_Set(file, "pIconColour", PlayerInfo[playerid][pIconColour]);
And on player loading, this happens:
pawn Код:
format(PlayerInfo[playerid][pIconColour], 15, "%x", dini_Get(file, "pIconColour"));
SetPlayerColor(playerid, PlayerInfo[playerid][pIconColour]);
And after that function, the player marker shows up in complete black. How do I manage to fix this?
Re: SetPlayerColour loading variable problem -
aslan890 - 02.01.2013
Try to look this 2:
https://sampwiki.blast.hk/wiki/SetPlayerMarkerForPlayer
Or
https://sampwiki.blast.hk/wiki/How_to_make_spawn_colors
Re: SetPlayerColour loading variable problem -
DaRoderick - 02.01.2013
No, should be player color, not marker only. And that spawn color thing doesn't really help since there're no variables used there.
Re: SetPlayerColour loading variable problem -
Basssiiie - 02.01.2013
You can just do this:
Код:
// Loading the color from file:
PlayerInfo[playerid][pIconColour] = dini_Int(file, "pIconColour");
// Saving the color in a file:
dini_IntSet(file, "pIconColour", PlayerInfo[playerid][pIconColour]);
Because the hex value is handled the same as an integer. It's not like a string. (dini_Set and dini_Get are for strings.)
Re: SetPlayerColour loading variable problem -
DaRoderick - 03.01.2013
Yes, but that will still not fix my problem hehe.
Re: SetPlayerColour loading variable problem -
Basssiiie - 03.01.2013
Yes, it will. Have you tried it? Oh, and remove that format thing. You can just use this and it will work fine:
Код:
PlayerInfo[playerid][pIconColour] = dini_Int(file, "pIconColour");
SetPlayerColor(playerid, PlayerInfo[playerid][pIconColour]);
Re: SetPlayerColour loading variable problem -
DaRoderick - 04.01.2013
Thanks for the help. Still, it doesn't work.
Now the playericon appears as
Код:
pIconColour=92247295
In the player's file.
On load char;
pawn Код:
format(PlayerInfo[playerid][pIconColour], 15, "%d", dini_Get(file, "pIconColour"));
SetPlayerColor(playerid, PlayerInfo[playerid][pIconColour]);
On saving;
pawn Код:
dini_IntSet(file, "pIconColour", PlayerInfo[playerid][pIconColour]);
Re: SetPlayerColour loading variable problem -
Basssiiie - 04.01.2013
Quote:
Originally Posted by ******
I suggest you use %d not %x. That colour is technically a negative number which can't be formatted correctly using %x.
|
But SetPlayerColor doesn't accept strings! So it wouldn't work anyway.
@DaRoderick: Pawn handles integers the same as hex values. These sets below will each to the same.
Код:
// Both functions set the player color to red:
SetPlayerColor(playerid, 16711680);
SetPlayerColor(playerid, 0xFF0000);
// Both lines add 255 to the number:
number += 255;
number += 0xFF;
// This will work too:
number = 0xFF00 + 255; // This will output 65535 or 0xFFFF, which both is the same.
If you don't know what number a hex value is, there's a converter
here.
If the examples in my previous posts still don't work, try making the pIconColour item in your enum a integer instead of a string.
Re: SetPlayerColour loading variable problem -
DaRoderick - 05.01.2013
So, for example, you suggest that when a player chooses a colour, he doesn't do
pawn Код:
PlayerInfo[playerid][pIconColour] = 0xE85A7AFF;
but
pawn Код:
PlayerInfo[playerid][pIconColour] = 3898243839;
Right?
Re: SetPlayerColour loading variable problem -
DaRoderick - 06.01.2013
Quote:
Originally Posted by DaRoderick
So, for example, you suggest that when a player chooses a colour, he doesn't do
pawn Код:
PlayerInfo[playerid][pIconColour] = 0xE85A7AFF;
but
pawn Код:
PlayerInfo[playerid][pIconColour] = 3898243839;
Right?
|
Above.