Jump to content

Tutorial Register/Login MYSQL R39


WiDuAlK

Recommended Posts

On 03.11.2015, 18:23:06, WiDuAlK.SaMp said:

in etapele de register am scris tot de mana, informatiile fiind in capul meu. Ai erori pt ca sigur am gresit eu 1-2 chestii. Daca iti dai interesul poti sa le rezolvi imediat. E chestie de scris gresit, daca corectezi va merge perfect.

Uite ce imi da cand il fac cu tot cu etapele de register...

C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(374) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(376) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(485) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(499) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Link to comment
Share on other sites

Acum 3 ore, david1995 a spus:

Uite ce imi da cand il fac cu tot cu etapele de register...

C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(374) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(376) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(485) : error 017: undefined symbol "rows"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(499) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

new rows; :| si nu stiu ce ai la linia 499

Link to comment
Share on other sites

1 hour ago, WiDuAlK.SaMp said:

new rows; :| si nu stiu ce ai la linia 499

linia 498 (inainte 499)

cache_get_data(rows, fields);// facem interogarea lor

si dupa ce pun new rows;

C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(374) : error 017: undefined symbol "fields"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(458) : error 017: undefined symbol "fields"
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(497) : warning 219: local variable "rows" shadows a variable at a preceding level
C:\Users\Zydrax\Desktop\new\pawno\darois.pwn(498) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase

 

la 497

new rows, fields[200];// definim randurile si domeniile, iar temporar se va folosi la extragerea stringurilor

 

 

Edited by david1995
Link to comment
Share on other sites

4 minutes ago, WiDuAlK.SaMp said:

pai si eu ti-am dat definirea :| new fields; :| daca nici erorile acestea simple nu poti sa le faci iti sugerez sa lasi deocamdata crearea de GM, si sa te ocumi mai intai cu aprofundarea cunostintelor.

Bun am facut eu ceva si uite ce mia dat acuma.. error 029: invalid expression, assumed zero

iar linia este

 

 
    else// altfel , daca parola este gresita
 

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Salut, multumesc pentru tutorial.. Am facut tot ce trebuie, nu primesc nici o eroare/warning dar am incercat sa fac sa se salveze si email, ani, sex, pin.. si nu se salveaza nici nume, parola si ip.. Iti las codul mai jos, imi spui ce trebuie modificat, te rog.

//=====[INCLUDE]================================================================

#include <a_samp>
#include <a_mysql>

//====[CONECTARE LA MYSQL]======================================================

#define mysql_host	"localhost"
#define mysql_db 	"bazadate"
#define mysql_user 	"root"
#define mysql_pass 	""

//====[ENUM]====================================================================

enum
{
	DIALOG_REGISTER,
    DIALOG_LOGIN,
    DIALOG_AGE,
    DIALOG_GENDER,
    DIALOG_EMAIL,
    DIALOG_PIN
};

enum pInfo 
{
    pParola,
    pID
};

new P_Data[MAX_PLAYERS][pInfo];

//====[HANDLE]==================================================================

new handle = -1;

//====[FORWARD]=================================================================

forward MySQLConnect();
forward OnPlayerLogin(playerid);
forward OnLogin(playerid);

//====[SCRIPT]==================================================================


main()
{
	print("\n----------------------------------");
	print("    GameMode incarcat cu succes     ");
	print("----------------------------------\n");
}

public MySQLConnect()
{
    handle = mysql_connect(mysql_host, mysql_user, mysql_db, mysql_pass);
    if(mysql_errno() != 0)
    {
        printf("(MySQL) Conexiunea la baza de date %s a esuat.", mysql_db);
        SendRconCommand("exit");
    }
    else
    {
        printf("(MySQL) Conexiunea la baza de date %s a reusit.", mysql_db);
    }
    return 1;
}

public OnPlayerLogin(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Logheaza-te!", "Te rog sa-ti introduci parola contuului mai jos!", "Logare", "Exit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Inregistrare", "Trebuie sa iti creezi un cont ca sa joci pe server. nTasteaza mai jos o parola, pentru a te inregistra!", "Inregistreaza", "Exit");
    }
    return 1;
}

public OnLogin(playerid)
{
    new rows, fields, temporar[200];
    cache_get_data(rows, fields);
    if(rows)
    {
        cache_get_field_content(0, "parola", temporar), format(P_Data[playerid][pParola], 25, temporar);
        P_Data[playerid][pID] = cache_get_field_content_int(0, "id");
        SpawnPlayer(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");
    }
    return 1;
}

public OnGameModeInit()
{
    MySQLConnect();
	SetGameModeText("Versiunea BETA");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
    mysql_close(handle);
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    new query[100];
    mysql_format(handle, query, sizeof(query), "SELECT * FROM conturi WHERE nume = '%s'", GetName(playerid));
    mysql_tquery(handle, query, "OnPlayerLogin", "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new query[128], ip[25];
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Introdu-ti o parola pentru a te inregistra pe server!", "Inregistreaza", "Exit");
                GetPlayerIp(playerid, ip, sizeof(ip));
                mysql_format(handle, query, sizeof(query), "INSERT INTO conturi (nume, parola, ip) VALUES ('%s', '%e', '%s')", GetName(playerid), inputtext, ip);
				mysql_query(handle, query);
				ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Alege sexul caracterului", "bla, bla, bla", "Masculin", "Feminin");
            }
            return 1;
        }
        case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");
                mysql_format(handle, query, sizeof(query), "SELECT * FROM `conturi` WHERE `nume`='%e' AND `parola` = '%e'", GetName(playerid), inputtext);
				mysql_tquery(handle, query, "OnLogin", "i", playerid);
            }
            return 1;
        }
        case DIALOG_GENDER:
        {
            if(!response)
            {
                mysql_format(handle, query, sizeof(query), "UPDATE conturi SET 'sex' = '2' WHERE 'nume' = '%s'", GetName(playerid));
                mysql_query(handle, query);
                ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Cati ani va avea caracterul tau?", "bla, bla, bla", "Seteaza", "Refuza");
			}
			if(response)
			{
                mysql_format(handle, query, sizeof(query), "UPDATE conturi SET 'sex' = '1' WHERE 'nume' = '%s'", GetName(playerid));
                mysql_query(handle, query);
                ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Cati ani va avea caracterul tau?", "bla, bla, bla", "Seteaza", "Refuza");
			}
            return 1;
        }
        case DIALOG_AGE:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
            	mysql_format(handle, query, sizeof(query), "UPDATE conturi SET 'ani' = '%s' WHERE 'nume' = '%s'", inputtext, GetName(playerid));
            	mysql_query(handle, query);
            	ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Ce e-mail ai?", "bla, bla, bla", "Seteaza", "Refuza");
            }
            return 1;
        }
        case DIALOG_EMAIL:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
        		mysql_format(handle, query, sizeof(query), "UPDATE conturi SET 'email' = '%s' WHERE 'nume' = '%s'", inputtext, GetName(playerid));
        		mysql_query(handle, query);
        		ShowPlayerDialog(playerid, DIALOG_PIN, DIALOG_STYLE_INPUT, "Seteaza un pin contului", "bla, bla, bla", "Seteaza", "Refuza");
			}
			return 1;
        }
        case DIALOG_PIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                new string[124];
                mysql_format(handle, query, sizeof(query), "UPDATE conturi SET 'pin' = '%s' WHERE 'nume' = '%s'", inputtext, GetName(playerid));
        		mysql_query(handle, query);
        		SpawnPlayer(playerid);
        		format(string, sizeof(string), "(Server) Felicitari %s tocmai te-ai inregistrat pe server.", GetName(playerid));
        		SendClientMessage(playerid, -1, string);
            }
			return 1;
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

//====[STOCK-URI]===============================================================

stock GetName(playerid)
{
	new playerName[MAX_PLAYER_NAME];

	GetPlayerName(playerid, playerName, sizeof(playerName));
	return playerName;
}

 

<img src="http://s15.postimage.org/q6s3fuq4r/snapshotoronthefolldsangdsa.png">

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 2 months later...
  • 5 months later...
  • 5 weeks later...

Buna seara! Am si eu nevoie de ajutor daca se poate, nu stiu ce s-a intamplat dar am urcat gm-ul meu pe un host si imi tot dadea unknown mode, bun am rezolvat dar acum imi pune serverul pe offline dar nu e din cauza la server.cfg.. Asta imi zice Failed (libmysqlclient.so.18: cannot open shared object file: No such file or directory) am incercat sa caut pe google dar nu am gasit nimic. Multumesc, sper sa ma ajutati!

Link to comment
Share on other sites

Acum 44 minute, Kidro a spus:

Buna seara! Am si eu nevoie de ajutor daca se poate, nu stiu ce s-a intamplat dar am urcat gm-ul meu pe un host si imi tot dadea unknown mode, bun am rezolvat dar acum imi pune serverul pe offline dar nu e din cauza la server.cfg.. Asta imi zice Failed (libmysqlclient.so.18: cannot open shared object file: No such file or directory) am incercat sa caut pe google dar nu am gasit nimic. Multumesc, sper sa ma ajutati!

Problema este ca pe host se utilizeaza fisierele .so, adica in functie de linux-ul folosit necesita un anumit tip de fisier .so.

https://github.com/pBlueG/SA-MP-MySQL/releases

Aici iti da mai multe versiuni pentru diferitele tipuri de linux, incearca-le pe fiecare si vezi care se potriveste cu sistemul de operare pe care il detine firma host.

Link to comment
Share on other sites

  • WopsS unfeatured and unpinned this topic
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.