04.09.2016, 14:57
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?
MySQL table: http://imgur.com/a/MWsxD
Errors:
MySQL table: http://imgur.com/a/MWsxD
Errors:
Код:
C:\Users\PC Aleks\Desktop\Serwer\pawno\include\sscanf2.inc(299) : warning 218: old style prototypes used with optional semicolumns C:\Users\PC Aleks\Desktop\Serwer\pawno\include\sscanf2.inc(359) : warning 218: old style prototypes used with optional semicolumns map.pwn(81) : warning 213: tag mismatch map.pwn(81) : warning 213: tag mismatch Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Warnings. ================ READY ================
Код:
#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; }