SA-MP Forums Archive
Help with MySQL - 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: Help with MySQL (/showthread.php?tid=345138)



Help with MySQL - Riddy - 23.05.2012

I dont seem to be spawning after registering or logging in, I need help....


this is the part when the player connects:

Код:
 

	
	new query[150];
	format(query,sizeof(query),"SELECT IP FROM `accounts` WHERE Username = '%s' LIMIT 1",PlayerName(playerid));
	mysql_query(query);
	mysql_store_result();
	new rows = mysql_num_rows();
    if(!rows)
    if(rows == 0)
    {
        ShowRegisterScreen(playerid);
        gPlayerAccount[playerid] = 1;
        SetTimerEx("LogTimer", 60000, 0, "d", playerid);
        SetTimerEx("FixCamera", 1000, false, "i", playerid);
    }
    if(rows == 1)
    {
        ShowLoginScreen(playerid);
        gPlayerAccount[playerid] = 1;
        SetTimerEx("LogTimer", 60000, 0, "d", playerid);
        SetTimerEx("FixCamera", 1000, false, "i", playerid);
    }
	mysql_free_result();
This is the DIALOG_REGISTER and DIALOG_LOGIN

pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
        if (response == 0)
        {
            ShowLoginScreen(playerid);
            return 1;
        }
        if (response == 1)
        {
        if (strlen(inputtext) == 0)
        {
            SendClientMessage(playerid,-1,"Please enter your password for your account in the box below.");
            ShowLoginScreen(playerid);
            return 1;
        }
        }
        new query[200], pass[100];
        mysql_real_escape_string(inputtext,pass);
        format(query,200,"SELECT `Username` FROM accounts WHERE Username = '%s' AND password = SHA1('%s')",PlayerName(playerid), pass);
        mysql_query(query);
        mysql_store_result();
        new numrows = mysql_num_rows();
        if(numrows == 1) MySQL_Login(playerid);
        if(!numrows)
        {
        ShowLoginScreen(playerid);
        }
        mysql_free_result();
        gPlayerLogged[playerid] = 1;
        gPlayerAccount[playerid] = 1;
        return 1;
        }
        if(dialogid == DIALOG_REGISTER)
        {
        if(response)
        {
        if(!strlen(inputtext) || strlen(inputtext) > 32)
        {
           SendClientMessage(playerid,-1,"Enter a password within 32 characters.");
           ShowRegisterScreen(playerid);
        }
        else if(strlen(inputtext) > 0 && strlen(inputtext) < 32)
        {
           new pass[100];
           mysql_real_escape_string(inputtext,pass);
           MySQL_Register(playerid,pass);
        }
        }
        if(!response)
        {
        ShowRegisterScreen(playerid);
        }
        gPlayerLogged[playerid] = 1;
        gPlayerAccount[playerid] = 1;
        }
This is MySQL_Register and MySQL_Login

pawn Код:
stock MySQL_Register(playerid,passwordstring[])
{
    //blah blah, query


    gPlayerLogged[playerid] = 1;
    gPlayerAccount[playerid] = 1;
   
    SetPlayerPos(playerid,1974.7544,-1927.6581,67.0056);
    SetPlayerFacingAngle(playerid,269.2993);
    SetPlayerCameraPos(playerid,1974.7544,-1927.6581,67.0056+2);
    SetPlayerCameraLookAt(playerid,1974.7544,-1927.6581,67.0056);

    SendClientMessage(playerid,-1,"Successfully registered");
    return 1;
}

stock MySQL_Login(playerid)
{
            // The rows and stuff
    mysql_free_result();
   
    gPlayerLogged[playerid] = 1;
    gPlayerAccount[playerid] = 1;

    SetPlayerPos(playerid,1974.7544,-1927.6581,67.0056);
    SetPlayerFacingAngle(playerid,269.2993);
    SetPlayerCameraPos(playerid,1974.7544,-1927.6581,67.0056+2);
    SetPlayerCameraLookAt(playerid,1974.7544,-1927.6581,67.0056);
   
    SendClientMessage(playerid,-1,"Successfully logged in.");
    return 1;
}
I cant currently spawn after logging in or registering


Re: Help with MySQL - iGetty - 23.05.2012

Try SetSpawnInfo and SpawnPlayer under it?


Re: Help with MySQL - Riddy - 23.05.2012

I have tried literally most, its just refusing to spawn the player

EDIT:

if (gPlayerAccount[playerid] == 0) {
SendClientMessage(playerid,COLOR_LIGHTRED,"[SERVER]: You have been kicked for not registering.");
Kick(playerid);
}
else if (gPlayerLogged[playerid] == 0) {
SendClientMessage(playerid,COLOR_LIGHTRED,"[SERVER]: You have been kicked for not logging in.");
Kick(playerid);
}

This is also a problem, I set it so, if Spawn is clicked then spawn the player but it kicks the player even though there registered


Re: Help with MySQL - iGetty - 23.05.2012

Hmmmm. Are you using "OnPlayerRequestClass"?


Re: Help with MySQL - Riddy - 23.05.2012

No, I removed that after that didnt even work


Re: Help with MySQL - Riddy - 23.05.2012

OnPlayerRequestClass
{
return 0;
}

OnPlayerRequestSpawn
{
return 0;
}


Re: Help with MySQL - Riddy - 23.05.2012

I would like to get this done as fast as possible, can someone help?


Re: Help with MySQL - Riddy - 24.05.2012

Anyone that can help me maybe?