Saving HeX numbers to file.
#1

I've got a problem. Basically, I would like to save a players HeX colour to their account when they leave or w/e but every time I try to save it it doesn't work. Is there something I need to do?
Reply
#2

Are you using dini? Use dini and save the hex color code to their file.
Reply
#3

Just show us what you did

Basically you only need to get the color of the player and save it (its a number)
Reply
#4

%x for hex. But you can also use %d.. It's saved different but it has the same result.

Yeah, also show us you codes..
Reply
#5

Ok, so I re-wrote the command (it was written in 0.2x originally and wasn't using sscanf ... or ZMCD :X) uhh, so .. Yeah, now it seems to be working, as in; saving the colour to file but now I have another problem. I have written it so that if the player is not connected it will check for a user database to write in, but it doesn't seem to work :S

Any help appreciated

pawn Код:
CMD:spawncolour(playerid,params[])
{
  if(PlayerInfo[playerid][LoggedIn] == 1)
    {
        if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
        {
          new pID, colour;
            if(sscanf(params, "ux", pID, colour)) return SendClientMessage(playerid, Red, "USAGE: /spawncolour [playerid] [code]");

            if(IsPlayerConnected(pID))
            {
                if(PlayerInfo[pID][LoggedIn] && PlayerInfo[pID][Registered] && IsPlayerVIP(pID))
                {
                    dUserSetINT(PlayerName2(pID)).("SpawnColour", colour);
                    PlayerInfo[pID][SpawnColour] = dUserINT(PlayerName2(pID)).("SpawnColour");
                    SetPlayerColor(playerid, PlayerInfo[pID][SpawnColour]);
                    SendClientMessage(playerid,MANAGEMENT, "*** Spawncolour for this player successfully set");
                    return 1;
                }
                else return SendClientMessage(playerid,red,"ERROR: Player must be registered, logged in and be a V.I.P.");
            }
            else
            {
                if(udb_Exists(pName(pID)))
            {
              SendClientMessage(playerid,MANAGEMENT, "*** Spawncolour for this player successfully set");
                    dUserSetINT(PlayerName2(pID)).("SpawnColour", colour);
                return 1;
                }
                else return SendClientMessage(playerid, red, "A player database with that name was not found.");
            }
        }
        return 0;
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
[/code]
Reply
#6

Any errors? And yea what do you mean by
Quote:
Originally Posted by _❼_
I have written it so that if the player is not connected it will check for a user database to write in,
Reply
#7

No, no errors, it compiles perfectly. But if I go in-game and use the command on someone who is not connected it says "Player is not connected." Which is strange because that phrase isn't even used in the command, lol.

To answer your question: The command should be able to be used in two ways, using sscanf you can either type a name in or player ID, right? So if the player isn't connected, it should then skip that part and check that a player with that name is registered and then change the colour for that player in their file. For example, if they are offline and they want their spawn colour changed? Are you with me? :P
Reply
#8

Oh rite I understand you now. You want to be able to change their spawn color from their even when they are not connected.

Код:
CMD:spawncolour(playerid,params[])
{
  	if(PlayerInfo[playerid][LoggedIn] == 1)
	{
		if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
		{
			new pID, colour;
			if(sscanf(params, "ux", pID, colour)) return SendClientMessage(playerid, Red, "USAGE: /spawncolour [playerid] [colorcode]"); 

			if(IsPlayerConnected(pID))
			{
				if(PlayerInfo[pID][LoggedIn] && PlayerInfo[pID][Registered] && IsPlayerVIP(pID))
				{
					dUserSetINT(PlayerName2(pID)).("SpawnColour", colour);
					PlayerInfo[pID][SpawnColour] = dUserINT(PlayerName2(pID)).("SpawnColour");
					SetPlayerColor(playerid, PlayerInfo[pID][SpawnColour]);
					SendClientMessage(playerid,MANAGEMENT, "*** Spawncolour for this player successfully set");
				}
				else return SendClientMessage(playerid,red,"ERROR: Player must be registered, logged in and be a V.I.P.");
			}
			else
			{
  				if(udb_Exists(pName(pID)))
  				{
    					SendClientMessage(playerid,MANAGEMENT, "*** Spawncolour for this player successfully set");
    					dUserSetINT(PlayerName2(pID)).("SpawnColour", colour);
				}
				else return SendClientMessage(playerid, red, "A player database with that name was not found.");
			}
		}
		else return SendClientMessage(playerid,0xffffffaa,"You are not authorised to use this command.");
	}
	else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply
#9

Uh .. what you changed? lol
Reply
#10

Firstly: I indented your code.
Secondly: I removed the unnecessary "return 1;"s.
And some minor adjustments.

Does it work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)