Force class selection after OnPlayerRequestClass return 0
#1

I'm making a login system which prevents displaying classes for a player until login:
Код:
public OnPlayerRequestClass(playerid, classid)
{
    if (!Players[playerid][IsLoggedIn])
    {
        LoadPlayer(playerid);
        return 0;
    }
    else
    {
        SetClassSelectionCamera(playerid);
        return 1;
    }
}
It works good, no classes are shown. The problem is that after a player is logged in, it does not show the classes automatically, the player have to click on arrow button to see a class. I tried ForceClassSelection with and without TogglePlayerSpectating/SpawnPlayer, but no luck:
Код:
OnPlayerLoggedIn(playerid)
{
    ForceClassSelection(playerid);
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);
}
The only solution I found is to actually spawn player and get him back to class selection:
Код:
OnPlayerLoggedIn(playerid)
{
    ForceClassSelection(playerid);
    SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 );
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);
}
But I don't like it because it shows the spawned player for some time before return to class selection. Is there a better solution?
Reply
#2

Here is the code i use for admin skin but replaced checking is player admin with is player logged in:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(GetPlayerSkin(playerid) == 163 && (PlayerInfo[playerid][LoggedIn] == 0))
    {
        SendClientMessage(playerid, COLOR_RED, "*YOUR ERROR MESSAGE*");
        return 0;
    }
    return 1;
}
Only thing is where you see 163 (That is skin id) You will have to recreate this and put all of yours skins.. Sorry i don't know is there another way. Replace *YOUR ERROR MESSAGE* whit error message you want to be when player is not logged in and press key for spawn.. Hope i helped. Btw it is tested and it works
Reply
#3

Quote:
Originally Posted by LeroyII
Посмотреть сообщение
Here is the code i use for admin skin but replaced checking is player admin with is player logged in:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(GetPlayerSkin(playerid) == 163 && (PlayerInfo[playerid][LoggedIn] == 0))
    {
        SendClientMessage(playerid, COLOR_RED, "*YOUR ERROR MESSAGE*");
        return 0;
    }
    return 1;
}
Only thing is where you see 163 (That is skin id) You will have to recreate this and put all of yours skins.. Sorry i don't know is there another way. Replace *YOUR ERROR MESSAGE* whit error message you want to be when player is not logged in and press key for spawn.. Hope i helped. Btw it is tested and it works
Change the skin id (163)to your admin skin so admins can only choose that skin .
Reply
#4

Quote:
Originally Posted by 5194Hercules
Посмотреть сообщение
Change the skin id (163)to your admin skin so admins can only choose that skin .
No, this code is to forbid player to spawn when trying to spawn with this skin and hasn't logged in yet!

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(GetPlayerSkin(playerid) == 0 && (PlayerInfo[playerid][LoggedIn] == 0))
    {
        SendClientMessage(playerid, COLOR_RED, "*YOUR ERROR MESSAGE*");
        return 0;
    }
    return 1;
}
    if(GetPlayerSkin(playerid) == 1 && (PlayerInfo[playerid][LoggedIn] == 0))
    {
        SendClientMessage(playerid, COLOR_RED, "*YOUR ERROR MESSAGE*");
        return 0;
    }
    return 1;
}
    if(GetPlayerSkin(playerid) == 2 && (PlayerInfo[playerid][LoggedIn] == 0))
    {
        SendClientMessage(playerid, COLOR_RED, "*YOUR ERROR MESSAGE*");
        return 0;
    }
    return 1;
}
Here is what it need to look like.. you have to do it with all your skins.. just replace "if(GetPlayerSkin(playerid) == [YOURSKINID]" and do it with every skin!
Reply
#5

This is not what I need. I don't want to show any skins until user is logged in. This is only possible by return 0 in OnPlayerRequestClass, not in OnPlayerRequestSpawn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)