SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/01/2020, 01:15 AM   #1
cipi89
Little Clucker
 
Join Date: Sep 2018
Posts: 30
Reputation: 3
Default Help with mysql

Okay so first of all, I am rookie with mysql and I can't figure the way to set up my database and start working with it.

I've created DB with table called UserIds. I need to have user_Name and user_kills in that table for every player on server BUT! I can't figure out how to create that, so far what I've got is this:

Code:
CREATE TABLE "UserIds" (
	"user_Name"	TEXT,
	"user_kills"	INTEGER
);
I'm using DB Browser for SQLite to create the DB and the table. My whole gamemode is in Y_INI and I have folder in my scriptfiles called 'UserIds' that had .ini files in it called 'user_1.ini', 'user_2.ini' etc. In those files i had only user's name and kills stored, so now all I'm looking for is to create that but in mysql.
I have already 1000+ users in scriptfiles and I'm looking to store all of them in my mysql database if there's any code that could help me out to do that I'd appreciate it very much!

Oh and also, does my hosting need to provide me with some mysql database thingy so I can link it or can it all work as it did before? Again, I'm not saving every user's info, i have seperate folder for that and its in Y_INI, all i want to save in mysql is user's name and user's kills.
cipi89 is offline   Reply With Quote
Old 07/01/2020, 01:03 PM   #2
oghabanjb
Little Clucker
 
Join Date: May 2018
Posts: 37
Reputation: 1
Default Re: Help with mysql

PHP Code:
CREATE TABLE `UserIds`(`User_NameVARCHAR(24NOT NULL , `User_KillsINT(11NOT NULLENGINE MyISAM
__________________
+REP if I helped you.
Sorry for my bad english.
oghabanjb is offline   Reply With Quote
Old 07/01/2020, 02:50 PM   #3
cipi89
Little Clucker
 
Join Date: Sep 2018
Posts: 30
Reputation: 3
Default Re: Help with mysql

I still need help with code to convert my Y_INI savings to MySQL if anyone can help?

This was my INI code for saving:
Code:
stock SaveUserID(playerid)
{
    new u = Data[playerid][userid];
    new lFile[128];
    format(lFile, 128, USERID_FOLDER, u);
    new INI:File = INI_Open(lFile);
    INI_WriteString(File, "user_Name", User[u][user_Name]);
    INI_WriteInt(File, "user_kills", User[u][user_kills]);
    INI_Close(File);
}
cipi89 is offline   Reply With Quote
Old 08/01/2020, 02:00 PM   #4
cipi89
Little Clucker
 
Join Date: Sep 2018
Posts: 30
Reputation: 3
Default Re: Help with mysql

Bump
cipi89 is offline   Reply With Quote
Old 09/01/2020, 07:00 PM   #5
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 453
Reputation: 145
Default Re: Help with mysql

SQLite and MySQL is different. SQLite is already bundled with sa-mp server package and the database is saved as .db file under the scriptfiles folder. The DB Browser software you are using is for SQLite. And there is nothing else needed from the hosting provider.

MySQL requires a mysql client and sever, you can get a MySQL client plugin to work with the sa-mp server, and yes your hosting may needs to provide the mysql server locally, unless you connect remotely to another server.

Also please provide more details of your users Y_INI directory tree/structure, a sample would be helpful (i.e. whats inside).

EDIT: i misunderstood, seems you still want to use Y_INI as you have another files

And also please show the Data[][] & User[][] enum array definitions...
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 02:08 PM
Mysql queriesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th audriuxxx Scripting Help 4 11/04/2014 06:42 PM
BlueG MySQL plugin - Failed (plugins/mysql.so: undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM


All times are GMT. The time now is 01:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.