MySQL Loading and Saving Help - 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)
+--- Thread: MySQL Loading and Saving Help (
/showthread.php?tid=429460)
MySQL Loading and Saving Help -
Zalman - 09.04.2013
Hello, when I have make a table for an enum for my script how do I then load the variables from the mysql table to then use to script commands and such, hope this made scene.
Re: MySQL Loading and Saving Help -
Vince - 09.04.2013
Let's start with the basics: are you capable of writing an SQL query?
Re: MySQL Loading and Saving Help -
Zalman - 09.04.2013
Quote:
Originally Posted by Vince
Let's start with the basics: are you capable of writing an SQL query?
|
Yes I am I just don't get how you would receive all the variables from the table to then use them to script commands.
Re: MySQL Loading and Saving Help -
Scenario - 09.04.2013
You PMed me moments ago asking this exact same question. You also stated that you downloaded my MySQL script. This was the enum (or basically, array) that comes with the download:
pawn Код:
enum PLAYER_VARIABLES
{
pDataID, // we use database ID's (data ID) as it's easier to handle than a username and provides easy table linking
pPassword[129], // passwords are hashed, the hash is 128 + 1 for the null terminator, equaling 129
pAdmin,
pCash,
pSavings,
pBankAccount,
pLevel,
pKills,
pDeaths,
pRegTime, // registration time/date; saved as a timestamp
pLastOn, // last time/date online; saved as a timestamp
Float:pHealth,
Float:pArmour,
Float:pLastX, // on the last disconnect, this was the X position of the player
Float:pLastY, // on the last disconnect, this was the Y position of the player
Float:pLastZ, // on the last disconnect, this was the Z position of the player
pSkin,
pGender[7],
pAge,
};
new pInfo[MAX_PLAYERS][PLAYER_VARIABLES]; // this allows usage of the "pInfo" variable with the "PLAYER_VARIABLES" enumerator
So, say we want to figure out someone's admin level and show it to the player. This code would do exactly that:
pawn Код:
new szString[128];
format(szString, sizeof(szString), "Your admin level is: %d", pInfo[playerid][pAdmin]);
SendClientMessage(playerid, -1, szString);
The same goes for ALL of the other variables, however strings and floats obviously work a little differently.