OnPlayerRequestClass help
#1

Hello,
I have a problem with my Script.
When i press F4 on my Server, i came on the ClassSelection, but when i press the Spawn Button, i Spawn and came back to the ClassSelection.

My OnPlayerRequestClass Public:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    print("OnPlayerRequestClass called...");
    SpawnPlayer(playerid);
    return 1;
}
I hope someone has a solution for my problem.

/Edit: I use SA-MP 0.3d R1, and this problem i had it in 0.3c too.

* Zunno
Reply
#2

Show the code "OnPlayerSpawn"
Reply
#3

OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetCameraBehindPlayer(playerid);
    SetPlayerTextLabel(playerid);
    if(GetPVarInt(playerid, "FreezeTime") == 0) { TogglePlayerControllable(playerid, 1); }
    InitLockDoors(playerid);
    STDPlayer[playerid] = 0;
    gTeam[playerid] = PlayerInfo[playerid][pTeam];
    if(gTeam[playerid] == 4) { gTeam[playerid] = 3; }
    //if(IsPlayerNPC(playerid)) { Eingeloggt[playerid] = 1; }
    if(GetPVarInt(playerid, "TBan") > 0) { DeletePVar(playerid, "TBan"); }
    if(Eingeloggt[playerid] == 0 && !IsPlayerNPC(playerid)) { SendClientMessage(playerid, COLOR_LIGHTRED, "** This server requires a login before spawning! **"); Kick(playerid); }
    //if(GetPVarInt(playerid, "AtClothes") == 1) { PlayerInfo[playerid][pModel] = GetPlayerSkin(playerid); DeletePVar(playerid, "AtClothes"); }
    if(gTeam[playerid] == 3)
    {
        if(PlayerInfo[playerid][pMember] > 0 || PlayerInfo[playerid][pLeader] > 0)
        {
            new model = GetPVarInt(playerid, "Char");
            if(PlayerInfo[playerid][pMember] == 1) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pMember] == 2) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pMember] == 3) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pMember] == 4) { SetSpawnInfo(playerid, 1, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 1; gTeam[playerid] = 1; }
            else if(PlayerInfo[playerid][pMember] == 5) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
            else if(PlayerInfo[playerid][pMember] == 6) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
            else if(PlayerInfo[playerid][pMember] == 7) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pMember] == 8) { SetSpawnInfo(playerid, 10, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 10; gTeam[playerid] = 10; }
            else if(PlayerInfo[playerid][pMember] == 9) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 10) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 11) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 12) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 13) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 14) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 15) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 16) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 17) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pMember] == 18) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 1) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pLeader] == 2) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pLeader] == 3) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pLeader] == 4) { SetSpawnInfo(playerid, 1, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 1; gTeam[playerid] = 1; }
            else if(PlayerInfo[playerid][pLeader] == 5) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
            else if(PlayerInfo[playerid][pLeader] == 6) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
            else if(PlayerInfo[playerid][pLeader] == 7) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
            else if(PlayerInfo[playerid][pLeader] == 8) { SetSpawnInfo(playerid, 10, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 10; gTeam[playerid] = 10; }
            else if(PlayerInfo[playerid][pLeader] == 9) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 10) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 11) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 12) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 13) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 14) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 15) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 16) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 17) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            else if(PlayerInfo[playerid][pLeader] == 18) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
            SpawnPlayer(playerid);
        }
    }
    if(PlayerInfo[playerid][pMember] > 0 || PlayerInfo[playerid][pLeader] > 0) { SetPlayerSkin(playerid, GetPVarInt(playerid, "Char")); }
    else { SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]); }
   
    if(!gPlayerAnimLibsPreloaded[playerid])
    {
        PreloadAnimLib(playerid,"BOMBER");
        PreloadAnimLib(playerid,"RAPPING");
        PreloadAnimLib(playerid,"SHOP");
        PreloadAnimLib(playerid,"BEACH");
        PreloadAnimLib(playerid,"SMOKING");
        PreloadAnimLib(playerid,"FOOD");
        PreloadAnimLib(playerid,"ON_LOOKERS");
        PreloadAnimLib(playerid,"DEALER");
        PreloadAnimLib(playerid,"CRACK");
        PreloadAnimLib(playerid,"CARRY");
        PreloadAnimLib(playerid,"COP_AMBIENT");
        PreloadAnimLib(playerid,"PARK");
        PreloadAnimLib(playerid,"INT_HOUSE");
        PreloadAnimLib(playerid,"FOOD");
        PreloadAnimLib(playerid,"PED");
        gPlayerAnimLibsPreloaded[playerid] = 1;
    }
    if(AntiSpawnKill[playerid] == false)
    {
        SetTimerEx("AntiSpawnKillTimer", 10000, 0, "i", playerid);
        AntiSpawnKill[playerid] = true;
        SetPlayerHealth(playerid, 999999.99);
        TextDrawShowForPlayer(playerid, AntiKill);
    }
    //
    SetPlayerWeapons(playerid);
    SetPlayerSpawn(playerid);
    SetPlayerToTeamColor(playerid);
    PlayerFixRadio(playerid);
    return 1;
}
Reply
#4

Quote:
Originally Posted by Zunno
Посмотреть сообщение
Hello,
I have a problem with my Script.
When i press F4 on my Server, i came on the ClassSelection, but when i press the Spawn Button
So SpawnPlayer isn't actually working under OnPlayerRequestClass. Try a timer of about 100 MS.
Reply
#5

Okay I'll try

/Edit: it doesn't work

my code now:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    print("OnPlayerRequestClass called...");
    //SpawnPlayer(playerid);
    SetTimerEx("ZSpawn",100,0,"i",playerid);
    return 1;
}

public ZSpawn(playerid)
{
    return SpawnPlayer(playerid);
}
But even if I'm standing there, nothing inside, I'll post the press the spawn button again sent into the skin selection. Furthermore, I'll be right after I F4 in the skin selection, and not next to the dead.
Reply
#6

The problem happent only when you press F4 for the class selection?
Reply
#7

yes exactly.
I don't know why this is so.
Reply
#8

I cant find anything from the script.
I suggest you to use ForceClassSelection
pawn Код:
if (strcmp("/class", cmdtext, true, 10) == 0)
    {
        ForceClassSelection(playerid);
        SendClientMessage(playerid, 0xAA3333AA,"[CLASS]> You have been forced to the class selection");
        SetPlayerHealth(playerid, 0.00);
        return 1;
        }
OR
pawn Код:
CMD:class(playerid,params[]){
    ForceClassSelection(playerid);
    SendClientMessage(playerid, 0xAA3333AA,"[CLASS]> You have been forced to the class selection");
    SetPlayerHealth(playerid, 0.00);
    return 1;}
Reply
#9

One solution could be not use to use GF as a script.
Reply
#10

Yes but, the problem is, if someone provided on F4 comes, he must make a relog out because he does not anymore from the skin selection.

Edit:
Yes but i work now 1 year on the script, and now even to start a self-made is quite time consuming if you have a running server
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)