[HELP]Help me with MySQL.
#1

Please convert these scripts to a_mysql or simple mysql
Код:
SQL::Connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);

    if(!SQL::ExistsTable(""PLAYERS_TABLE""))
    {
        new handle = SQL::Open(SQL::CREATE, ""PLAYERS_TABLE"");
        SQL::AddTableEntry(handle, "id", SQL_TYPE_INT, 11, true);
        SQL::AddTableEntry(handle, "username", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "password", SQL_TYPE_VCHAR, 114);
        SQL::AddTableEntry(handle, "ip", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "score", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "cash", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "kills", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "deaths", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "vip", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "level", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "helper", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "hours", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "minutes", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "seconds", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "wanteds", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "laston", SQL_TYPE_VCHAR, 48);
        SQL::AddTableEntry(handle, "joined", SQL_TYPE_VCHAR, 48);
        SQL::AddTableEntry(handle, "mutedsec", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "cmdmutedsec", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "jailedsec", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "warns", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "fs", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "skin", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Pistol", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Ammo1", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Sub", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Ammo2", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Rifle", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Ammo3", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Assault", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Ammo4", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Shotgun", SQL_TYPE_INT);
        SQL::AddTableEntry(handle, "Ammo5", SQL_TYPE_INT);
        
        SQL::Close(handle);
        print("[SSF]: '"PLAYERS_TABLE"' table created successfully!");
    }
    else if(SQL::ExistsTable(""PLAYERS_TABLE""))
    {
        printf("[SSF]: Total %d accounts loaded from '"PLAYERS_TABLE"'", SQL::CountRows(""PLAYERS_TABLE""));
	}
 	if(!SQL::ExistsTable(""BANS_TABLE""))
    {
        new handle = SQL::Open(SQL::CREATE, ""BANS_TABLE"");
        SQL::AddTableEntry(handle, "ban_id", SQL_TYPE_INT, 11, true);
        SQL::AddTableEntry(handle, "ban_username", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "ban_ip", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "ban_by", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "ban_on", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "ban_reason", SQL_TYPE_VCHAR, 24);
        SQL::AddTableEntry(handle, "ban_expire", SQL_TYPE_INT);
        SQL::Close(handle);
        
        print("[SSF]: '"BANS_TABLE"' table created successfully!");
    }
    else if(SQL::ExistsTable(""BANS_TABLE""))
    {
        printf("[SSF]: Total %d bans loaded from '"BANS_TABLE"'", SQL::CountRows(""BANS_TABLE""));
	}
Код:
    if(SQL::RowExistsEx(""BANS_TABLE"", "ban_username", GetName(playerid)))
    {
		new handle = SQL::OpenEx(SQL::READ, ""BANS_TABLE"", "ban_username", GetName(playerid));
        SQL::ReadString(handle, "ban_username", string[1], 24);
        SQL::ReadString(handle, "ban_ip", string[2], 24);
        SQL::ReadString(handle, "ban_by", string[3], 24);
        SQL::ReadString(handle, "ban_on", string[4], 24);
        SQL::ReadString(handle, "ban_reason", string[5], 24);
        SQL::ReadInt(handle, "ban_expire", expire);
        SQL::Close(handle);

        if(expire > gettime() || expire == 0)
        {

			strcat(DIALOG, ""white"Your account is banned from this server,\n\n");

		    format(string2, sizeof(string2), ""white"Username: "red"%s\n", string[1]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"IP: "red"%s\n", string[2]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Banned by: "red"%s\n", string[3]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Reason: "red"%s\n", string[5]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Ban date: "red"%s\n", string[4]);
			strcat(DIALOG, string2);

		    new expire2[68];
			if(expire == 0) expire2 = "PERMANENT";
			else expire2 = ConvertTime(expire);
		    format(string2, sizeof(string2), ""white"Timeleft: "red"%s\n\n", expire2);
			strcat(DIALOG, string2);

			strcat(DIALOG, ""white"If you think that you got banned wrongfully, please make an appeal on our forums.\n");
			strcat(DIALOG, "Make sure you saved this box by pressing F8.");

			ShowPlayerDialog(playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "Notice", DIALOG, "Close", "");
            DelayKick(playerid);

            return true;
        }
        else
        {
            SQL::DeleteRowEx(""BANS_TABLE"", "ban_username", GetName(playerid));
            Server(playerid, "Your account's ban has expired.");
		}
    }

    else if(SQL::RowExistsEx(""BANS_TABLE"", "ban_ip", GetIP(playerid)))
    {
    	new handle = SQL::OpenEx(SQL::READ, ""BANS_TABLE"", "ban_ip", GetIP(playerid));
        SQL::ReadString(handle, "ban_username", string[1], 24);
        SQL::ReadString(handle, "ban_ip", string[2], 24);
        SQL::ReadString(handle, "ban_by", string[3], 24);
        SQL::ReadString(handle, "ban_on", string[4], 24);
        SQL::ReadString(handle, "ban_reason", string[5], 24);
        SQL::ReadInt(handle, "ban_expire", expire);
        SQL::Close(handle);

        if(expire > gettime() || expire == 0)
        {
			
			strcat(DIALOG, ""white"Your IP is banned from this server,\n\n");

		    format(string2, sizeof(string2), ""white"Username: "red"%s\n", string[1]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"IP: "red"%s\n", string[2]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Banned by: "red"%s\n", string[3]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Reason: "red"%s\n", string[5]);
			strcat(DIALOG, string2);

		    format(string2, sizeof(string2), ""white"Ban date: "red"%s\n", string[4]);
			strcat(DIALOG, string2);

		    new expire2[68];
			if(expire == 0) expire2 = "PERMANENT";
			else expire2 = ConvertTime(expire);
		    format(string2, sizeof(string2), ""white"Timeleft: "red"%s\n\n", expire2);
			strcat(DIALOG, string2);

			strcat(DIALOG, ""white"If you think that you got banned wrongfully, please make an appeal on our forums.\n");
			strcat(DIALOG, "Make sure you saved this box by pressing F8.");

			ShowPlayerDialog(playerid, DIALOG_COMMON, DIALOG_STYLE_MSGBOX, "Notice", DIALOG, "Close", "");
            DelayKick(playerid);
            
            return true;
        }
        else
        {
            SQL::DeleteRowEx(""BANS_TABLE"", "ban_username", GetName(playerid));
            Server(playerid, "Your IP's ban has expired.");
		}
    }
Reply
#2

please help me
Reply
#3

If we just convert the script, then how does this help you? Yes, you might have the script, however, how would you write more SQL? The best thing to do, is actually going to learn how to do it and then convert it yourself, there are many different tutorials that you're able to read and then learn about MySQL for example, AndreT's threaded MySQL tutorial.
After you have read the tutorials, you must also try and use it! You cannot just read something and understand everything about the language, you must practise and use it to see how it works and what it does.

MySQL is another language, you need to learn it before you can use it in your script; if someone just converted it for you, you wouldn't be able to do more in your script and if you didn't understand it; what is the point having it... it's like having a chocolate bar but not knowing how to eat it..
Reply
#4

i want to just convert this easy mysql plugin code i know mysql
Reply
#5

i want help with MYSQL pls how to login with MYSQL
Reply
#6

Quote:
Originally Posted by S0nicZ
Посмотреть сообщение
i want to just convert this easy mysql plugin code i know mysql
If you already know mysql, convert it yourself. No one is going to convert it for you.
Reply
#7

i dont know how easy-mysql.inc plugin works thats why i am asking.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)