[Tutorial] How to make a MySQL Admin System!
#21

Quote:
Originally Posted by Dwane
View Post
That's me!

I tried to learn MySQL when the version was R6 but I found it difficult and I also had few problems with phpMyAdmin so I stopped reading tutorials etc and I started learning SQLite. I do agree that MySQL/SQLite provides more expansion and that's why I used/use them.

I started few days ago reading AndreT's tutorial about MySQL R7 and cache and it was pretty easy. I downloaded the gamemode with simple register/login system AndreT suggested and I read it again and again. I found it very easy and I can say that R7 is a lot of easier than the older versions, atleast for me. It took 2 days to see how it works and what to do and I made a simple register/login system from scratch in less than 1 hour!
By the time I wanted to learn MySQL for sa-mp, the R7 plugin had been released for awhile, so I didn't even bother with the older versions. I'll stress my point again. If you know how the dialog feature works, you can easily grasp the threaded capabilities.
Reply
#22

Quote:
Originally Posted by VincentDunn
View Post
I would recommend separate callbacks, but it really is just personal preference.

For example with one callback
pawn Code:
#define RESULT_LOAD (1)
#define RESULT_SAVE (2)

public OnQueryExecute(resultid, playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);

    switch (resultid) {
        case RESULT_LOAD:
            // code here
        case RESULT_SAVE:
            // code here
    }

    return 1;
}
This can get pretty hard to work with the more queries you script in, but it gets the job done. You can argue that the switch statement will slow it down, but the difference would practically be zero.

with single callbacks
pawn Code:
LoadPlayer(playerid)
{
    // code here
}

public OnPlayerLoad(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);

    // code here
    return 1;
}
 
SavePlayer(playerid)
{
    // code here
}

public OnPlayerSave(playerid)
{
    printf("Player %d saved.", playerid);
    return 1;
}
It may seem like a lot more lines, but it's a lot easier to handle this way IMO. You don't have to deal with different result ids, there are less mistakes to be made, and you can safely say that your query will only execute what you put into its according callback.

tl;dr - it doesn't really matter, as long as you take efficient advantage of the plugin, then you're fine
Yeah that's what I thought. I found it more systematic with separate callbacks, so that's what I'll hold on to.
Reply
#23

Quote:
Originally Posted by PabloDiCostanzo
View Post
Code:
C:\Documents and Settings\Administrador\Escritorio\Gang Wars\filterscripts\MySQL.pwn(118) : error 017: undefined symbol "SOQ"
And now I get that
Change SOQ to 500.
Reply
#24

Im getting this all the time..:

pawn Code:
[23:07:54]    Error: Function not registered: 'mysql_init'
[23:07:54]    Error: Function not registered: 'mysql_fetch_row'
[23:07:54] Script[gamemodes/truck.amx]: Run time error 19: "File or function is not found"
Replaced all mysql files with latest versions and still getting that error..
Reply
#25

Um no you have to use the provided mysql plugin and the provided include in order for my tutorial to work:

http://forum.sa-mp.com/showthread.ph...t=Stricken%27s
Reply
#26

Probably I'm stupid, but now I get this:

pawn Code:
[MySQL] Error (0): Failed to connect. Access denied for user 'root'@'localhost' (using password: YES).
Haven't got this with other gamemode's and stuff.. I made fresh install to my xampp and still getting the same error..
Reply
#27

You probably have defined a password, no worries just go to your PhpMyAdmin, click on "Users" at the top bar. Then click on "add user", there use any User Name + Password, but in the "Host" field make sure to put this:
Code:
127.0.0.1
Underneath on Global privileges click on check all, and then click add user. Next in your script make sure you have the name user name as you made + password. compile and run and it should work .
Reply
#28

Doesn't work... I used to have:

pawn Code:
#define mysql_host "localhost" //your destination server
#define mysql_user "root" //default user name of wampserver
#define mysql_password "" //wampserver has no default password unless you have set one.
#define mysql_database "samp"//the name of your database
Now I created user and changed it to:
pawn Code:
#define mysql_host "127.0.0.1" //your destination server
#define mysql_user "sanan" //default user name of wampserver
#define mysql_password "asdfgh" //wampserver has no default password unless you have set one.
#define mysql_database "samp"//the name of your database
The error is the same.
Reply
#29

Managed to fix it..

Updated Mysql to R6: Server plugin (VS9) ( https://sampforum.blast.hk/showthread.php?tid=56564 ).

In script just needed to delete " new MySQL:mysql; " and things that were with that line.

Finally I got errors from these lines:
pawn Code:
mysql_fetch_int("id", pInfo[playerid][ID]);
        // the special identifier of a user called "id"
        mysql_fetch_int("admin", pInfo[playerid][pAdmin]);
        // the admin level of the player
        mysql_fetch_int("score", pInfo[playerid][pScore]); SetPlayerScore(playerid, pInfo[playerid][pScore]);
        // here we fetch the score and save it to the enum and also save it to the server by using setplayerscore
        mysql_fetch_int("money", pInfo[playerid][pMoney]); GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        // here we fetch the score and save it to the enum and also save it to the server by using setplayerscore
        mysql_fetch_int("kills", pInfo[playerid][pKills]);
        // the amount of kills a player has
        mysql_fetch_int("deaths", pInfo[playerid][pDeaths]);
        // the amount of deaths a player has
All I had to do was to replace " mysql_fetch_int " with " mysql_fetch_field_row ". And now it's working!

Thanks for all help before too!

EDIT// Well.. Doesn't work as expected.. If I update something @ phpmyadmin, the changes wont come to server.. Trying to solve that..
Reply
#30

Quote:
Originally Posted by Trooja
View Post
Managed to fix it..

Updated Mysql to R6: Server plugin (VS9) ( https://sampforum.blast.hk/showthread.php?tid=56564 ).

In script just needed to delete " new MySQL:mysql; " and things that were with that line.

Finally I got errors from these lines:
pawn Code:
mysql_fetch_int("id", pInfo[playerid][ID]);
        // the special identifier of a user called "id"
        mysql_fetch_int("admin", pInfo[playerid][pAdmin]);
        // the admin level of the player
        mysql_fetch_int("score", pInfo[playerid][pScore]); SetPlayerScore(playerid, pInfo[playerid][pScore]);
        // here we fetch the score and save it to the enum and also save it to the server by using setplayerscore
        mysql_fetch_int("money", pInfo[playerid][pMoney]); GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
        // here we fetch the score and save it to the enum and also save it to the server by using setplayerscore
        mysql_fetch_int("kills", pInfo[playerid][pKills]);
        // the amount of kills a player has
        mysql_fetch_int("deaths", pInfo[playerid][pDeaths]);
        // the amount of deaths a player has
All I had to do was to replace " mysql_fetch_int " with " mysql_fetch_field_row ". And now it's working!

Thanks for all help before too!

EDIT// Well.. Doesn't work as expected.. If I update something @ phpmyadmin, the changes wont come to server.. Trying to solve that..
Well like i've said in my topic, if you counldn't follow the tutorial and its not compiling successfully then you can always download it here.
Reply
#31

localhost/phpmyadmin won't load :\
Reply
#32

Very useful
Reply
#33

Quote:
Originally Posted by iJohann3s
View Post
Please somebody an Pastebin or somebody try wether this works? Because I go the error: access denied for user 'root'@'localhost' (using password yes)
youre adding wrong password. that it!
add correct password
Reply
#34

Nevermind
Reply
#35

Ah man THANKS kamzaf! This really helped me man, i was so lost trying to learn this and you made it really simple. THANK YOU!
Reply
#36

You can use mysql via xampp much easier
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)