MySQL Loading and Saving Help
#1

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

Let's start with the basics: are you capable of writing an SQL query?
Reply
#3

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)