Spawn on login
#1

Hey guys. I've got a little problem. I want that once you log in you'll spawn automaticly.
But it bugs. When I spawn I can walk but the camera doesn't move.

pawn Код:
if (dialogid == Login)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return  ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
        SendClientMessage(playerid, COLOR_RED, "Wrong password");
        ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
        }
        else
        {
            logged[playerid] = 1;
            PlayerInfo[playerid][adminlevel] = dini_Int(file, "adminlevel");
            PlayerInfo[playerid][money] = dini_Int(file, "money");
            PlayerInfo[playerid][score] = dini_Int(file, "score");
            GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
            SetPlayerScore(playerid, dini_Int(file, "score")-GetPlayerScore(playerid));
            SendClientMessage(playerid,COLOR_RED, "Successfully logged in!");
            SpawnPlayer(playerid);
         
        }
    }
    return 0;
}
Reply
#2

Anything else used before than
pawn Код:
public OnGameModeInit()
{
    AddPlayerClass();
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerCameraPos(); ()
    SetPlayerCameraLookAt();
}
to change camera etc.?
Reply
#3

I think that it can solve your problem:

pawn Код:
if (dialogid == Login)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return  ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
        SendClientMessage(playerid, COLOR_RED, "Wrong password");
        ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
        }
        else
        {
            logged[playerid] = 1;
            PlayerInfo[playerid][adminlevel] = dini_Int(file, "adminlevel");
            PlayerInfo[playerid][money] = dini_Int(file, "money");
            PlayerInfo[playerid][score] = dini_Int(file, "score");
            GivePlayerMoney(playerid, (dini_Int(file, "money")-GetPlayerMoney(playerid)));
            SetPlayerScore(playerid, (dini_Int(file, "score")-GetPlayerScore(playerid)));
            SendClientMessage(playerid,COLOR_RED, "Successfully logged in!");
            TogglePlayerControllable(playerid, true);
            SetCameraBehindPlayer(playerid);
            SpawnPlayer(playerid);
            return 1;
        }
    }
    return 0;
}
I hope that i have helped
Reply
#4

@rjj: Btw: Please label your changes next time so that we don't have to use a program to detect them all.
(Did so - return 1 is correct, but the other two additions should be unnecessary)
Reply
#5

Thanks. But I fixed it with a timer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)