OnPlayerSpawn not being called?
#1

Hello, I have a problem. Sometimes I am not spawning properly, I don't have any weapons or skin, so I decided to debug OnPlayerSpawn, and have noticed that the function is not even called sometimes when I spawn, but if I re-log sometimes it fixes it.

I don't know what may be the cause of OnPlayerSpawn not being called, please help me.
Thanks.
Reply
#2

The error is in your 12324 line. you are missing a ';'.
Do you mind to post your code?
Reply
#3

What the heck am I supposed to post? Sometimes the problem happens, sometimes it doesn't. Here's my OnPlayerSpawn anyway...
pawn Код:
public OnPlayerSpawn(playerid) {
    printf("[debug] OnPlayerSpawn(%d)", playerid);

    PreloadAnimLib(playerid,"BOMBER");
    PreloadAnimLib(playerid,"RAPPING");
    PreloadAnimLib(playerid,"SHOP");
    PreloadAnimLib(playerid,"BEACH");
    PreloadAnimLib(playerid,"SMOKING");
    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,"GANGS");
    PreloadAnimLib(playerid,"PED");
    PreloadAnimLib(playerid,"FAT");
   
    SetPlayerColor(playerid, COLOR_WHITE);
    SetPlayerFightingStyle(playerid, playerVariables[playerid][pFightStyle]);

    SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 998);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 998); // Skilled, but not dual-wield.
    printf("[debug] Colors & Skills set (pID %d)", playerid);
    if(playerVariables[playerid][pPrisonTime] >= 1) {
        switch(playerVariables[playerid][pPrisonID]) {
            case 1: {
                SetPlayerPos(playerid, -26.8721, 2320.9290, 24.3034);
                SetPlayerInterior(playerid, 0);
                SetPlayerVirtualWorld(playerid, 0);
            }
            case 2: {
                SetPlayerPos(playerid, 264.58, 77.38, 1001.04);
                SetPlayerInterior(playerid, 6);
                SetPlayerVirtualWorld(playerid, 0);
            }
            case 3: {
                SetPlayerInterior(playerid, 6);
                SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+1);

                new spawn = random(sizeof(JailSpawns));

                SetPlayerPos(playerid, JailSpawns[spawn][0], JailSpawns[spawn][1], JailSpawns[spawn][2]);
                SetPlayerFacingAngle(playerid, 0);
            }
        }
        printf("[debug] Prison Time >= 1 (pID %d)", playerid);
        return 1;
    }

    if(playerVariables[playerid][pTutorial] == 1) {
        SetPlayerInterior(playerid, 14);
        SetPlayerPos(playerid, 216.9770, -155.4791, 1000.5234);
        SetPlayerFacingAngle(playerid, 267.9681);
        TogglePlayerControllable(playerid, false);
        printf("[debug] Tutorial (pID %d)", playerid);
        return 1;
    }

    SetPlayerSkin(playerid, playerVariables[playerid][pSkin]);
    printf("%s skin is %d", playerVariables[playerid][pNormalName], playerVariables[playerid][pSkin]);
    SetPlayerPos(playerid, playerVariables[playerid][pPos][0], playerVariables[playerid][pPos][1], playerVariables[playerid][pPos][2]);
    SetPlayerInterior(playerid, playerVariables[playerid][pInterior]);
    SetPlayerVirtualWorld(playerid, playerVariables[playerid][pVirtualWorld]);
    SetCameraBehindPlayer(playerid);
   
    printf("[debug] Skin set (pID %d)", playerid);
   
    ResetPlayerWeapons(playerid);
    givePlayerWeapons(playerid);
   
    if(pInjured[playerid] >= 1)
        SetTimerEx("FallInjured", 500, false, "i", playerid);
    else TogglePlayerControllable(playerid, true);
   
    playerVariables[playerid][pSkinSet] = 1;

    if(playerVariables[playerid][pEvent] >= 1)
        playerVariables[playerid][pEvent] = 0;

    if(playerVariables[playerid][pAdminDuty] == 1) {
        SetPlayerHealth(playerid, 500000.0);
    }
    else {
        SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
        SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
    }

    if(!GetPlayerInterior(playerid)) {
        SetPlayerWeather(playerid, weatherVariables[0]);
    }
    else {
        SetPlayerWeather(playerid, INTERIOR_WEATHER_ID);
    }

    playerVariables[playerid][pFreezeTime] = 3;
    playerVariables[playerid][pFreezeType] = 3;
    TogglePlayerControllable(playerid, false);
   
    syncPlayerTime(playerid);
    printf("[debug] Finished spawnin' (pID %d)", playerid);
    for(new i = 0; i < MAX_ACC_SLOTS; i++) {
        if(playerVariables[playerid][pAccWearing][i] == 1 && playerVariables[playerid][pAccessory][i] != 0) {
            new bone;
            switch(playerVariables[playerid][pAccessory][i])
            {
                case 19006..19010, 19015, 19033, 19022..19029,  18921..18924, 19093, 19160,  19099, 19100: bone = 2;
                default: bone = 1;
            }
            SetPlayerAttachedObject(playerid, i, playerVariables[playerid][pAccessory][i], bone,
            playerVariables[playerid][pAccOffsetX][i], playerVariables[playerid][pAccOffsetY][i], playerVariables[playerid][pAccOffsetZ][i],
            playerVariables[playerid][pAccRotX][i], playerVariables[playerid][pAccRotY][i], playerVariables[playerid][pAccRotZ][i],
            playerVariables[playerid][pAccScaleX][i], playerVariables[playerid][pAccScaleY][i], playerVariables[playerid][pAccScaleZ][i]);
        }
    }
    return 1;
}
Reply
#4

Does it have anything to do with https://sampforum.blast.hk/showthread.php?tid=354315?
If so, add OnPlayerSpawn(playerid); under SpawnPlayer(playerid);
EDIT: my apologize for being rude the post before.
Reply
#5

It helped, thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)