SA-MP Forums Archive
[++REP] Change automatic ID! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [++REP] Change automatic ID! (/showthread.php?tid=592279)



[++REP] Change automatic ID! - norton2 - 22.10.2015

Hello, MYSQL using R39, and when it comes 2-3 players on server, and I'm already entered the server, I change the game ID in the variable pInfo[playerid][pID].
I always change only number 48.
Код HTML:
CMD:debug(playerid, params [])
{
    new st[100];
    format(st, sizeof(st), "ID: %d", pInfo[playerid][pID]);
    SendClientMessage(playerid, -1, st);
    return 1;
}
Server Message: ID: 48
pInfo[playerid][pID] is 1, 1 is my pID from DataBase MYSQL! Not 48.
Please help.


Re: [++REP] Change automatic ID! - AbyssMorgan - 22.10.2015

show
writing values to pInfo[playerid][pID]


Re: [++REP] Change automatic ID! - norton2 - 22.10.2015

OnPlayerConnect:
Код HTML:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid));
    mysql_pquery(MySQLCon, query, "OnAccountCheck", "d", playerid);
-----------------------------------------------------------------------------------------
Код HTML:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    new string[228], rows = cache_num_rows();
    if(rows)
    {
        cache_get_row(0, 2, pInfo[playerid][pPass], MySQLCon, 129);
        cache_get_field_content(0, "LastLogin", string), strmid(pInfo[playerid][pLastLogin], string, 0, 255, 255);

   		//string.....
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{EDDC57}Login",string,"Login","Cancel");
	}
    else
    {
        //string.....
        ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"{FFFB80}Registration",string,"Register","Cancel");
    }
    return 1;
}
Код HTML:
if(dialogid == DIALOG_LOGIN)
{
    if(!response) return Kick(playerid);
    if(!strcmp(PasswordHash(inputtext), pInfo[playerid][pPass], false))
    {
        mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid));
        mysql_pquery(MySQLCon, query, "OnPlayerLogin", "d", playerid);
	}
}
Код HTML:
forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
	new rows = cache_num_rows();
	if(rows)
	{
	    pInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
	    pInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin");
	    pInfo[playerid][pHelper] = cache_get_field_content_int(0, "Helper");
	    pInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money");
	    pInfo[playerid][pScore] = cache_get_field_content_int(0, "Score");
	    pInfo[playerid][pStatus] = cache_get_field_content_int(0, "Status");
	    pInfo[playerid][pReg] = cache_get_field_content_int(0, "Reg");
	    pInfo[playerid][pSex] = cache_get_field_content_int(0, "Sex");
	    pInfo[playerid][pAge] = cache_get_field_content_int(0, "Age");
	    pInfo[playerid][pMute] = cache_get_field_content_int(0, "Mute");
	    // ................. and so on
	}
	return 1;
}



Re: [++REP] Change automatic ID! - norton2 - 23.10.2015

bump.


Re: [++REP] Change automatic ID! - Vince - 23.10.2015

The number 48 happens to be the character code for the character 0. For me, that immediately raises a red flag because that likely means that there is a either a type mismatch or a buffer overflow.

However, I can't seem to spot any obvious mistake at first glance. You may try using tquery instead of pquery and see if that helps. Also run crashdetect and see if any runtime error (runtime error 4, especially) comes up. In your enum declaration, is there anything before ID?


Re: [++REP] Change automatic ID! - AbyssMorgan - 23.10.2015

try so
PHP код:
new szID[12];
cache_get_field_content(0"ID"szID);
sscanf(szID"p<|>d"pInfo[playerid][pID]); 



Re: [++REP] Change automatic ID! - norton2 - 23.10.2015

I used and tquery, the problem was the same.
Crashdetect use and I not found errors!
Код HTML:
enum PlayerInfo
{
    pID, pPass[129], pAdmin, pHelper, pMoney, pScore, pStatus, pReg, pSex, pAge, pMute, pHoursPlayed, pRPoints, pBankMoney, pWantedLevel,
    pPhoneBook //......................... and so on
}
new pInfo[MAX_PLAYERS][PlayerInfo];



Re: [++REP] Change automatic ID! - norton2 - 23.10.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
The number 48 happens to be the character code for the character 0. For me, that immediately raises a red flag because that likely means that there is a either a type mismatch or a buffer overflow.

However, I can't seem to spot any obvious mistake at first glance. You may try using tquery instead of pquery and see if that helps. Also run crashdetect and see if any runtime error (runtime error 4, especially) comes up. In your enum declaration, is there anything before ID?
I found something... Variable "IP" it is in the database .SQL
But "IP" is not in players enum.
Is this the problem?


Re: [++REP] Change automatic ID! - J0sh... - 23.10.2015

No, no reason to if you don't really want to read the IP.


Re: [++REP] Change automatic ID! - norton2 - 23.10.2015

How to find the cause of the problem?