Hello everyone, I'm trying to create a login link to a site but only a part is connected, I'll explain better: the password is in the MySQL DB and data are saved in file% s.ini
I managed to make the password plugged in but now I have a problem: when you enter the correct password and it should load the data from file, I check "Unknown Command" without loading anything, this is the command:
Код:
if (strcmp(cmd, "/login", true) ==0 || strcmp(cmd, "/l", true) ==0)
{
if(IsPlayerConnected(playerid))
{
new tmppass[64];
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "SERVER: You are already logged in.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "USAGE: (/l)ogin [password]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
mysql_connect("127.0.0.1","root","samprp","mypassword");
new tmp2[256];
new string2[64];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
split(playername2, playernamesplit, '_');
new pnamedi[24];
new query[1024], line[1024];
GetPlayerName(playerid,pnamedi,24);
format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s'", pnamedi);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(line);
new password[14];
password[13] = strval(tmp);
new passwd[14];
mysql_get_field("code", password);
if(strcmp(tmp, password, true) == 0)
{
new string2[64];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
split(playername2, playernamesplit, '_');
format(string2, sizeof(string2), "users/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
new nab[256];
format(nab,256,"|DEBUG| pLevel: %d",PlayerInfo[playerid][pLevel]);
SendClientMessage(playerid,COLOR_RED,nab);
return 1;
}
fclose(UserFile);
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"Password errata");
}
}
return 1;
}