Hey, i'm learning how to make a login/register system, and i made a login/register system but this system doesn't work. Someone help me?
Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
#include <mysql>
#define D_LOGIN 1
#define D_REGISTER 2
main() {}
enum E_PLAYER
{
pUID,
pName[24],
pPassword,
pCash,
Float:pHealth,
Float:pArmor,
pSkin,
Float:pPosX,
Float:pPosY,
Float:pPosZ
}
new PlayerData[MAX_PLAYERS][E_PLAYER];
public OnGameModeInit()
{
mysql_init();
mysql_connect("localhost","Aleks","123","tutorial");
AddPlayerClass(0, 1481.8151,-1740.1632,13.5469,1.5110, 0,0,0,0,0,0);
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerLogin(playerid);
return 1;
}
public OnPlayerDisconnect(playerid)
{
PlayerLogout(playerid);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetSpawnInfo(playerid,0,PlayerData[playerid][pSkin],PlayerData[playerid][pPosX],PlayerData[playerid][pPosY],PlayerData[playerid][pPosZ],0.0,0,0,0,0,0,0);
SpawnPlayer(playerid);
return 1;
}
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
if(dialogid == D_LOGIN)
{
if(strlen(inputtext) > 0)
{
if(!strcmp(PlayerData[playerid][pPassword],inputtext, false))
{
SendClientMessage(playerid, 0xFFFF00FF, "Zostales zalogowany!"); //Login
} else{
ShowPlayerDialog(playerid,D_LOGIN,DIALOG_STYLE_PASSWORD, "Logowanie","Haslo nieprawidlowe\nWpisz haslo","OK","Anuluj"); //Invalid password
}
}else {
ShowPlayerDialog(playerid,D_LOGIN,DIALOG_STYLE_PASSWORD, "Logowanie","Haslo nieprawidlowe\nWpisz haslo","OK","Anuluj"); //Invalid password
}
}
if(dialogid == D_REGISTER)
{
if(strlen(inputtext) > 0)
{
new query[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(query,sizeof(query), "INSERT INTO members(name, password) VALUES('%s','%s')",pName, pPassword);
mysql_query(query)
PlayerLogin(playerid);
return 1;
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, PlayerData[playerid][pCash]);
SetPlayerHealth(playerid, PlayerData[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerData[playerid][pArmor]);
SetPlayerPos(playerid , PlayerData[playerid][pPosX],PlayerData[playerid][pPosY],PlayerData[playerid][pPosZ]);
SendClientMessage(playerid, 0xFFFF00FF, "Witaj na serwrze!");
return 1;
}
stock PlayerLogin(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new query[128];
new data[128];
format(query,sizeof(query), "SELECT * FROM members WHERE name = '%s'", name);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row(data, "|"))
{
sscanf(data, "p<|>ds[24]s[24]dffdfff",
PlayerData[playerid][pUID],
PlayerData[playerid][pName],
PlayerData[playerid][pPassword],
PlayerData[playerid][pCash],
PlayerData[playerid][pHealth],
PlayerData[playerid][pArmor],
PlayerData[playerid][pSkin],
PlayerData[playerid][pPosX],
PlayerData[playerid][pPosY],
PlayerData[playerid][pPosZ]);
} else {
ShowPlayerDialog(playerid, D_REGISTER, DIALOG_STYLE_PASSWORD, "Rejestracja","Nie masz jeszcze konta\nZarejestruj sie!","Zapisz","Anuluj");
return 1;
}
mysql_free_result();
ShowPlayerDialog(playerid,D_LOGIN,DIALOG_STYLE_PASSWORD, "Logowanie","Wpisz haslo","OK","Anuluj");
return 1;
}
stock PlayerLogout(playerid)
{
new Float:hp,Float:armor,query[256];
GetPlayerHealth(playerid, hp);
GetPlayerArmour(playerid, armor);
format(query,sizeof(query), "UPDATE members SET hp = '%f', armor = '%f' WHERE uid = '%d'", hp,armor,PlayerData[playerid][pUID]);
mysql_query(query);
return 1;
}
and please show us line 81 (i mean not the whole script highlight the 81st line )
Edit:after looking into your script i found that password is defined as integer and using as string in format statement
format(query,sizeof(query), "INSERT INTO members(name, password) VALUES('%s','%s')",pName, pPassword);
C:\Users\PC Aleks\Desktop\Serwer\pawno\include\sscanf2.inc(258 ) : warning 202: number of arguments does not match definition
C:\Users\PC Aleks\Desktop\Serwer\pawno\include\sscanf2.inc(271 ) : error 025: function heading differs from prototype