SA-MP Forums Archive
Spawn Problem. - 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: Spawn Problem. (/showthread.php?tid=462988)



Spawn Problem. - alanhutch - 09.09.2013

Hi, I wanted to ask why in my gamemode when I spawn there's this problem.

The textdraw won't hide, and I'm a ball D:
Here's the OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
new stringa[MAX_PLAYER_NAME];
new Text3D:PlayerLabel[MAX_PLAYERS];
format(stringa,sizeof(stringa),"%s (%d)",GetPlayerRPName(playerid), playerid);
PlayerLabel[playerid] = Create3DTextLabel(stringa, WHITE, 0.0, 0.0, 0.0, 20.0, 0, 1);
Attach3DTextLabelToPlayer(PlayerLabel[playerid], playerid, 0.0, 0.0, 0.3);
    TextDrawHideForPlayer(playerid, Textdrawlogin0);
        TextDrawHideForPlayer(playerid, Textdrawlogin1);
        TextDrawHideForPlayer(playerid, Textdrawlogin2);
        TextDrawHideForPlayer(playerid, Textdrawlogin4);
        TextDrawHideForPlayer(playerid, Textdrawlogin5);
        TextDrawHideForPlayer(playerid, Textdrawlogin6);
        TextDrawHideForPlayer(playerid, Textdrawlogin7);
        TextDrawHideForPlayer(playerid, Textdrawlogin8);
       
    if(gPlayerLogged[playerid] == 0 && !IsPlayerNPC(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "** Devi loggare prima di spawnare (Kickato) **");
//      printf("OnPlayerSpawn Kick: %d",playerid);
        KickPlayer[playerid] = 1;
        return 1;
    }
    if(PlayerInfo[playerid][pClothes] != 0)
    {
        SetPlayerSkin(playerid, PlayerInfo[playerid][pClothes]);
    }
    else
    {
        SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
    }
        if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "PilotaAutobusBlu", true))
        {
            SetPlayerColor(playerid, 0xFFFFFF00);
            PutPlayerInVehicle(playerid, NPCBlueBus, 0);
            SetPlayerSkin(playerid, 255);
            ResetPlayerWeapons(playerid);
            Attach3DTextLabelToVehicle(NPCTextBlue, NPCBlueBus, 0.0, 0.0, 0.0);
        }
        if(!strcmp(npcname, "PilotaAutobusNero", true))
        {
            SetPlayerColor(playerid, 0xFFFFFF00);
            PutPlayerInVehicle(playerid, NPCBlackBus, 0);
            SetPlayerSkin(playerid, 255);
            ResetPlayerWeapons(playerid);
            Attach3DTextLabelToVehicle(NPCTextBlack, NPCBlackBus, 0.0, 0.0, 0.0);
        }
    }
    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");
        PreloadAnimLib(playerid,"GANGS");
        gPlayerAnimLibsPreloaded[playerid] = 1;
    }
    Spawned[playerid] = 1;
    SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,0);
    SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,0);
    SetPlayerWeapons(playerid);
    SetPlayerSpawn(playerid);
    PlayerFixRadio(playerid);
    gPlayerSpawned[playerid] = 1;
    TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
    /*for(new i=0; i < sizeof(TurfInfo); i++)
    {
        if(TurfInfo[i][tOwner] == 255)
        {
            GangZoneShowForPlayer(playerid, Turfs[i], COLOR_TWWHITE);
        }
        if(TurfInfo[i][tOwner] < 15)
        {
            GangZoneShowForPlayer(playerid, Turfs[i], GetFamilyColor(TurfInfo[i][tOwner]));
        }
        if(TurfAttacker[i] != -1)
        {
            GangZoneShowForPlayer(playerid, Turfs[i], COLOR_TWWHITE);
            GangZoneFlashForPlayer(playerid, Turfs[i], COLOR_TWRED);
        }
    }*/

    //SyncTurfRadar();
    return 1;
}
And Here's the SetPlayerSpawn:
pawn Код:
public SetPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, false);
    if(IsPlayerConnected(playerid))
    {
        //TUTORIAL
        if(PlayerInfo[playerid][pTut] == 0)
        {
            HideArea(playerid);
            //ShowGUI(playerid);
            gOoc[playerid] = 1; gNewbie[playerid] = 1; gNews[playerid] = 1; gFam[playerid] = 1; RegistrationStep[playerid] = 1; CanTalk[playerid] = 1;
            SetPlayerPos(playerid, 1305.5662841797,-1543.8950195313,122.20141601563);
            TogglePlayerControllable(playerid, 0);
            SetPlayerCameraPos(playerid, 1460.0, -1324.0, 287.2);
            SetPlayerCameraLookAt(playerid, 1374.5, -1291.1, 239.0);
            ShowPlayerDialog(playerid, SEXMENU, DIALOG_STYLE_MSGBOX, "{00C0FF}Centro immigrazione - Prima domanda","{FFFFFF}- Qual'и il tuo sesso?", "Maschio", "Femmina");
            return 1;
        }
        HideGUI(playerid);
        //PAINTBALL
        if(PlayerPaintballing[playerid] > 0)
        {
            HideArea(playerid);
            PlayerInfo[playerid][pHospital] = 0;
            ResetPlayerWeapons(playerid);
            GivePlayerAdminGun(playerid, 24);
            GivePlayerAdminGun(playerid, 29);
            new rand = random(sizeof(PaintballSpawns));
            SetPlayerPos(playerid, PaintballSpawns[rand][0], PaintballSpawns[rand][1], PaintballSpawns[rand][2]);
            SetPlayerToTeamColor(playerid);
            SetCameraBehindPlayer(playerid);
            return 1;
        }
        //JAIL
        if(PlayerInfo[playerid][pJailed] == 1)
        {
            HideArea(playerid);
            SetPlayerInterior(playerid, 6);
            SetPlayerPos(playerid,264.6288,77.5742,1001.0391);
            SetCameraBehindPlayer(playerid);
            SetPlayerFacingAngle( playerid, -90);
            SetPlayerToTeamColor(playerid);
            CanTalk[playerid] = 1;
            return 1;
        }
        if(PlayerInfo[playerid][pJailed] == 2)
        {
            HideArea(playerid);
            Pause(playerid);
            SetPlayerInterior(playerid, 0);
            SetCameraBehindPlayer(playerid);
            CanTalk[playerid] = 1;
            PlayerInfo[playerid][pSafeSpawn] = 0;
            TogglePlayerControllable(playerid, 1);
            new rand = random(sizeof(PrisonSpawns));
            PlayerCell = rand;
            SetPlayerPos(playerid, PrisonSpawns[rand][0], PrisonSpawns[rand][1], PrisonSpawns[rand][2]);
            SetPlayerFacingAngle(playerid, PrisonSpawns[rand][3]);
            StopAudioStreamForPlayer(playerid);
            ClearChatbox(playerid,1);
            return 1;
        }//Tree
/*      if(PlayerInfo[playerid][pJailed] == 3)
        {
            CanTalk[playerid] = 1;
            SetPlayerPos(playerid, -1070.8547,-2038.5858,49.1448);
            SetCameraBehindPlayer(playerid);
            SetPlayerWorldBounds(playerid, -1069, -1073.4076, -2036.4987, -2040.6022);
            SetPlayerInterior(playerid, 0);
            PlayerInfo[playerid][pInt] = 0;
            TogglePlayerControllable(playerid, 1);
        }*/

        //HOSPITAL
        if(DiedAtEvent[playerid] != 0)
        {
            SetPlayerPos(playerid, LasttX[playerid], LasttY[playerid], LasttZ[playerid]);
            SetPlayerHealth(playerid, LastHP[playerid]);
            SetPlayerArmour(playerid, LastAR[playerid]);
            SetPlayerWeapons(playerid);
            return 1;
        }
        if(PlayerInfo[playerid][pHospital] == 1)
        {
            SetPlayerInHospital(playerid);
            TogglePlayerControllable(playerid, 0);
            CanTalk[playerid] = 1;
            StopAudioStreamForPlayer(playerid);
            ClearChatbox(playerid,1);
            return 1;
        }
        if(PlayerInfo[playerid][pTut] == 1)
        {
            if(PlayerInfo[playerid][pSafeSpawn] == 1)
            {//FINISHED TUTORIAL
                SetPlayerInterior(playerid,0);
                SetPlayerVirtualWorld(playerid, 0);
                //SetSpawnInfo(playerid, -1, 59, 1733.1367,-1911.9568,13.5621, 1.0, -1, -1, -1, -1, -1, -1);
                SetPlayerPos(playerid,1733.1367,-1911.9568,13.5621);
                SetPlayerFacingAngle(playerid, 90);
                SetCameraBehindPlayer(playerid);
                PlayerInfo[playerid][pSafeSpawn] = 0;
                StopAudioStreamForPlayer(playerid);
                ClearChatbox(playerid,1);
            }
            else
            {//RELOGGING
                HideArea(playerid);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                //SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                //SetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                //SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SetCameraBehindPlayer(playerid);
                StopAudioStreamForPlayer(playerid);
                ClearChatbox(playerid,1);
                TextDrawHideForPlayer(playerid, SpawnClickI);
                TextDrawHideForPlayer(playerid, SpawnClickII);
                if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
                {
                SetPlayerPos(playerid, 215.87, 79.02, 1005.04);
                SetPlayerInterior(playerid, 6);
                }
                if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2)
                {
                SetPlayerPos(playerid, 368.17, -1164.89, 1227.86);
                SetPlayerInterior(playerid, 10);
                }
                if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4)
                {
                SetPlayerPos(playerid, 1866.62, -1720.25, 5206.19);
                SetPlayerInterior(playerid, 1);
                }
                 if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5)
                 {
                 SetPlayerPos(playerid, 494.18, -11.56, 1007.49);
                 SetPlayerInterior(playerid, 1);
                 }
                  if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7)
                  {
                  SetPlayerPos(playerid, 1220.53, -1352.32, 1017.88);
                  SetPlayerInterior(playerid, 1);
                  }
                  if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
                  {
                  SetPlayerPos(playerid, 1565.19, 23.16, 24.16);
                  SetPlayerInterior(playerid, 0);
                  }
                   if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
                   {
                   SetPlayerPos(playerid,345.55, 162.35, 1025.79);
                   SetPlayerInterior(playerid, 3);
                   }
                   if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10)
                   {
                   SetPlayerPos(playerid, -1988.17, 169.71, 539.00);
                   SetPlayerInterior(playerid, 15);
                   }
                   if(PlayerInfo[playerid][pMember] == 0 || PlayerInfo[playerid][pLeader] == 0)
                   {
                    SetPlayerPos(playerid, 1480.93, -1665.97, 13.33);
                    SetPlayerInterior(playerid, 0);
                   }
                new string[128];
                // Welcome
                format(string, sizeof(string), "SERVER: {FFFFFF}Benvenuto al PluriRP Project Next-Gen {FF6347}%s{FFFFFF}.", RPN(playerid));
                SendClientMessage(playerid, COLOR_NICEGREEN, string);
                // Player
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come un player di livello %d.", PlayerInfo[playerid][pLevel]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);
                // Helper
                if(PlayerInfo[playerid][pHelper]){
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come un helper di livello %d.", PlayerInfo[playerid][pHelper]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);}
                // VIP
                if(PlayerInfo[playerid][pDonateRank]){
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come un donatore di livello %d.", PlayerInfo[playerid][pDonateRank]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);}
                // Famed
                if(PlayerInfo[playerid][pFamed]){
                SendClientMessage(playerid, COLOR_NICEGREEN,"SERVER: {FFFFFF}Sei loggato come player famoso.");}
                // Developer
                if(PlayerInfo[playerid][pDeveloper]){
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come Developer di livello %d.", PlayerInfo[playerid][pDeveloper]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);}
                // Mappers
                if(PlayerInfo[playerid][pMapper]){
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come Mapper di livello %d.", PlayerInfo[playerid][pMapper]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);}
                // Admin
                if(PlayerInfo[playerid][pAdmin]){
                format(string, sizeof(string), "SERVER: {FFFFFF}Sei loggato come admin di livello %d.", PlayerInfo[playerid][pAdmin]);
                SendClientMessage(playerid, COLOR_NICEGREEN, string);}
                // Admin Messages
                //if(PlayerInfo[playerid][pAdmin]){
                //format(string, sizeof(string), "AdmLogin: Administrator %s has logged in. (Level %d)", RPN(playerid), PlayerInfo[playerid][pAdmin]);
                //SendAdminMessage(0xAA3333AA, string);}
            }
            CanTalk[playerid] = 1;
            SetPlayerToTeamColor(playerid);
        }
    }
    return 1;
}
And the OnPlayerRequestClass
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
     TogglePlayerSpectating(playerid, true);
    if(IsPlayerNPC(playerid))
    {
        printf("NPC: OnPlayerRequestClass: %d", playerid);
            return 1;
    }
    if(gPlayerLogged[playerid] == 0)
    {
        switch(gPlayerAccount[playerid])
    {
            case 0: DisplayDialogForPlayer(playerid, 2); //register
            case 1: DisplayDialogForPlayer(playerid, 1); //login
        }
    }
    SetupPlayerForClassSelection(playerid);
    if(gPlayerSpawned[playerid] == 1)
    {
        if(PlayerInfo[playerid][pMember] > 0 || PlayerInfo[playerid][pLeader] > 0 || PlayerInfo[playerid][pFMember] != 255)
        {
            SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
        }
        else
        {
            PlayerInfo[playerid][pModel] = PedSkins[classid][0];
        }
    }
    else
    {
        SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
    }
    return 1;
}
Thank you


Re: Spawn Problem. - Konstantinos - 09.09.2013

You forgot to disable the spectating to off. It will also respawn the player.

pawn Код:
TogglePlayerSpectating(playerid, 0);