SA-MP Forums Archive
Saving HeX numbers to file. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving HeX numbers to file. (/showthread.php?tid=153550)



Saving HeX numbers to file. - dcmd_crash - 09.06.2010

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?


Re: Saving HeX numbers to file. - DJDhan - 09.06.2010

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


Re: Saving HeX numbers to file. - Nero_3D - 09.06.2010

Just show us what you did

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


Re: Saving HeX numbers to file. - RyDeR` - 09.06.2010

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


Re: Saving HeX numbers to file. - dcmd_crash - 10.06.2010

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]



Re: Saving HeX numbers to file. - DJDhan - 10.06.2010

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,



Re: Saving HeX numbers to file. - dcmd_crash - 10.06.2010

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


Re: Saving HeX numbers to file. - DJDhan - 10.06.2010

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");
}



Re: Saving HeX numbers to file. - dcmd_crash - 10.06.2010

Uh .. what you changed? lol


Re: Saving HeX numbers to file. - DJDhan - 10.06.2010

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

Does it work?