SetPlayerColour loading variable problem
#1

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?
Reply
#2

Try to look this 2:

https://sampwiki.blast.hk/wiki/SetPlayerMarkerForPlayer

Or

https://sampwiki.blast.hk/wiki/How_to_make_spawn_colors
Reply
#3

No, should be player color, not marker only. And that spawn color thing doesn't really help since there're no variables used there.
Reply
#4

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.)
Reply
#5

Yes, but that will still not fix my problem hehe.
Reply
#6

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]);
Reply
#7

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]);
Reply
#8

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.
Reply
#9

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?
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)