SA-MP Forums Archive
What is wrong ? - 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: What is wrong ? (/showthread.php?tid=299220)



What is wrong ? - TheBluec0de - 24.11.2011

what is wrong to prevent player spawn ?



Код:
public OnPlayerRequestSpawn(playerid)
{
    if(UserLogged[playerid] == 0)
    {
        format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", GetPlayerNameEx(playerid));
        mysql_query(Query);
        mysql_store_result();
        if(!mysql_num_rows()) 
        {
            ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "register", "insert a password \n register your account", "register", "");
			return 0;
		}
        else
        {
            ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "login", "insert a password \n login into your account", "login", "");
            return 0;
        }
    }
    return 1;
}



Re: What is wrong ? - Jordiee - 24.11.2011

OnPlayerSpawn, Give us that.


Re: What is wrong ? - TheBluec0de - 24.11.2011

but I do not have to spawn the player, if you click on spawn both in the register login that


Re: What is wrong ? - TheBluec0de - 24.11.2011

bump


Re: What is wrong ? - Kayaque - 24.11.2011

Try this:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    TogglePlayerSpectating(playerid, 1);
    if(UserLogged[playerid] == 0)
    {
        format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", GetPlayerNameEx(playerid));
        mysql_query(Query);
        mysql_store_result();
        if(!mysql_num_rows())
        {
            ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "register", "insert a password \n register your account", "register", "");
            return 0;
        }
        else
        {
            ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "login", "insert a password \n login into your account", "login", "");
            return 0;
        }
    }
    return 1;
}



Re: What is wrong ? - TheBluec0de - 24.11.2011

but if you logging, you stay spectating ... in the other codes I set it to 0 right?


Re: What is wrong ? - Kayaque - 24.11.2011

In your first post you said players could just press the "spawn" botton to spawn, without registering or login.
The code I posted will fix that problem, and you dont need to use the /TogglePlayerSpectating(playerid, 1);/ anymore in the script. It's simply to take away the " << >> SPAWN " dialog at start-up.


Re: What is wrong ? - TheBluec0de - 24.11.2011

but if you put the password you must login or register to the spawn


Re: What is wrong ? - Kayaque - 24.11.2011

When you enter the game, the login or register dialog will pop up, yes. If that was your question.


Re: What is wrong ? - TheBluec0de - 24.11.2011

but my code is correct, when logged in I am spawn, in the register not and this is ok... in the login is problem..