The Problem?
#1

When i register to my server, its spawns me without letting me choose my skin.

Here is the code:

Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","Great, now please relog to save your stats!","Ok","");
                new stringl[128];
                new name[MAX_PLAYER_NAME];
				GetPlayerName(playerid, name, MAX_PLAYER_NAME);
                format(stringl, sizeof(stringl), "Porsh: {FFFFFF}You've successfully registered the name ({F2D82C}%s{FFFFFF}) with the password ({F2D82C}%s{FFFFFF})", name, inputtext);
                SendClientMessage(playerid, COLOR_GREEN, stringl);
            }
        }


Here is photo:
https://imgur.com/a/R0A5BuA (I dont know what wrong i did.)

Also, when i fail my password it gets me where i can choose my skin and click spawn, and it spawns me! Of course you cant move but you can spawn, and thats not good! How to remove that? So when i fail my password it doesnt gets me where i can choose my player skin and spawn.

Here is code:
Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }

Heres photo:
https://imgur.com/a/g0X83aK

Help?
Reply
#2

Remove SpawnPlayer from your first code.
Make some kind of logged in variable which will restrict players from spawning if they aren't logged in. Simply do return 0; under onplayerrequestclass if logged in value is 0.
Reply
#3

Ok i added:

Код:
new pLogged[MAX_PLAYERS]
and added it on DIALOG_REGISTER:

Код:
pLogged[playerid] = 1;
and added it on OnPlayerRequestSpawn

Код:
if(pLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREEN, "You need to be registered/logged in to spawn!");
But again its spawning me but only says the message.
If i add kick(playerid); It will kick the player before the message shows, what to do?
Reply
#4

PHP код:
case DIALOG_REGISTER:
{
    if (!
response) return Kick(playerid);
    if(
response)
    {
        if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
        new 
INI:File INI_Open(UserPath(playerid));
        
INI_SetTag(File,"data");
        
INI_WriteInt(File,"Password",udb_hash(inputtext));
        
INI_WriteInt(File,"Cash",0);
        
INI_WriteInt(File,"Admin",0);
        
INI_WriteInt(File,"Kills",0);
        
INI_WriteInt(File,"Deaths",0);
        
INI_Close(File);
        
        new 
stringl[128];
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnameMAX_PLAYER_NAME);
        
format(stringlsizeof(stringl), "Porsh: {FFFFFF}You've successfully registered the name ({F2D82C}%s{FFFFFF}) with the password ({F2D82C}%s{FFFFFF})"nameinputtext);
        
SendClientMessage(playeridCOLOR_GREENstringl);
        
        
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,"Success!","Great, now please relog to save your stats!","Ok","");
    }

That should prevent the player from spawning while registering.

Now this code:
PHP код:
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
SpawnPlayer(playerid); 
Add that where the player selects their skin. If it's a dialog, then add it in where they give a response to what skin ID they want. This will make them spawn after choosing their skin.

If you want any messages to show before kicking, add a timer to kick the player after they've been shown the message.

Example:

PHP код:
SetTimerEx("KickTimer"500false"i"playerid); //Add this after showing a player a message. 
PHP код:
forward KickTimer(playerid);
public 
KickTimer(playerid)
{
    
Kick(playerid);
    return 
1;

Reply
#5

Quote:
Originally Posted by Lixyde
Посмотреть сообщение
Ok i added:

Код:
new pLogged[MAX_PLAYERS]
and added it on DIALOG_REGISTER:

Код:
pLogged[playerid] = 1;
and added it on OnPlayerRequestSpawn

Код:
if(pLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREEN, "You need to be registered/logged in to spawn!");
But again its spawning me but only says the message.
If i add kick(playerid); It will kick the player before the message shows, what to do?
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(pLogged[playerid] == 0)
	{
	    SendClientMessage(playerid, COLOR_GREEN, "You need to be registered/logged in to spawn!");
	    return 0;
	}
        return 1;
}
That should do.
Reply
#6

Now i type my password wrong it won't spawn me, that's good.
But if i type my password right, and click the button, it says the message:

SendClientMessage(playerid, COLOR_GREEN, "You need to be registered/logged in to spawn!");
and it doesn't let me spawn

What to do?
Reply
#7

You need to put pLogged[playerid] = 1; under login dialog where logged in successfuly message is.
Reply
#8

I have already did that, here is everywhere i put pLogged:

Код:
new pLogged[MAX_PLAYERS];
Then in OnPlayerRequestClass:

Код:
if(pLogged[playerid] == 0)
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please, enter your password!");
	    return 0;
	}
Then in OnPlayerConnect:

Код:
pLogged[playerid] = 0;

Then in OnDialogResponse
DIALOG_REGISTER

Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                pLogged[playerid] = 1;
                new stringl[128];
                new name[MAX_PLAYER_NAME];
				GetPlayerName(playerid, name, MAX_PLAYER_NAME);
                format(stringl, sizeof(stringl), "Porsh: {FFFFFF}You've successfully registered the name ({F2D82C}%s{FFFFFF}) with the password ({F2D82C}%s{FFFFFF})", name, inputtext);
                SendClientMessage(playerid, COLOR_GREEN, stringl);
            }
        }

This is it.

Where should remove something? Add something. Those are the places where pLogged exists
Reply
#9

In case DIALOG_LOGIN where player logs in.
Reply
#10

What should i do?
Reply
#11

Quote:
Originally Posted by Lixyde
Посмотреть сообщение
What should i do?
pLogged[playerid] = 1; obviously.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)