SA-MP Forums Archive
OnPlayerSpawn is not being called. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerSpawn is not being called. (/showthread.php?tid=254981)



OnPlayerSpawn is not being called. - admantis - 13.05.2011

Hello, well, I was working on my script, and I hadn't tested it for a couple days so I expected to have big changes, however when I log in I find out for my surprise that I spawn in the middle of the map, CJ skin, no weapons, anything..
Okay so, I was like desperate trying alternate methods trying to figure my mistake, when I tried to debug it adding printf in every line that does something and when I check the RCON console it's blank. Nothing printed.

My conclusions? OnPlayerSpawn is not being called, however it's very important for me as it gives weapons, skin, spawn, and important aspects.

P.S: I don't know if this helps, but I changed my includes to another ones who a friend I'm working who gave me and their different.

And if you want the code...
pawn Код:
public OnPlayerSpawn(playerid)
{
    new
        szString[128],
        iWeaponToGive,
        iSecondWepToGive,
        iThirdWepToGive,
        iFourthWepToGive;

    if (iHunt == -1)
    {
        AssignManhunt();
    }

    if (iHunt != playerid)
    {
        format(szString, 128, "{FF9900}The manhunt victim is %s(%d), kill him to get $%d and %d score!", GetName(iHunt), iHunt, iMoneyReward, iScoreReward);
        SendClientMessageToAll(-1, szString);
    }

    if (iHunt == playerid)
    {
        SetPlayerColor(playerid, 0xFF0000FF);
        SendClientMessage(playerid, -1, "{FF0000}Start running, you are the manhunt victim!");
    }

    if (iHunt != playerid)
    {
        switch (GetPVarInt(playerid, "Score"))
        {
            case 0..15:
            {
                iWeaponToGive = 23;
                iSecondWepToGive = 25;
            }

            case 16..70:
            {
                iWeaponToGive = 22;
                SetPlayerSkillLevel(playerid, 0, 400);
                iSecondWepToGive = 29;
            }

            case 71..120:
            {
                iWeaponToGive = 24;
                iSecondWepToGive = 26;
                SetPlayerSkillLevel(playerid, 4, 1);
            }

            case 121..170:
            {
                iWeaponToGive = 24;
                iSecondWepToGive = 31;
            }

            default:
            {
                iWeaponToGive = 24;
                iSecondWepToGive = 31;
                iThirdWepToGive = 27;
            }
        }

        if (GetPVarInt(playerid, "Premium") == 1)
        {
            iFourthWepToGive = 16;
        }

        if (iFourthWepToGive > 0)
        {
            GiveWeapon(playerid, iFourthWepToGive, 15);
        }

        if (iThirdWepToGive > 0)
        {
            GiveWeapon(playerid, iThirdWepToGive, 150);
        }

        GiveWeapon(playerid, iWeaponToGive, 200);
        GiveWeapon(playerid, iSecondWepToGive, 200);
    }
    else
    {
        iWeaponToGive = 9;
        iSecondWepToGive = 22;
       
        GiveWeapon(playerid, iWeaponToGive, 1);
        GiveWeapon(playerid, iSecondWepToGive, 500000);
    }
   
    new iRandom = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
    SetPlayerSkin(playerid, GetPVarInt(playerid, "Skin"));
    return true;
}
To make the thing harder, the callback is technically being called untill a point, which appears to be to the mesage 'Start running, you are the manhunt victim!'. The rest (giving weapons, skin, position) is not working or prints anything.

Cheers.


Re: OnPlayerSpawn is not being called. - DRIFT_HUNTER - 13.05.2011

you sure you have AddPlayerClass()?


Respuesta: OnPlayerSpawn is not being called. - admantis - 13.05.2011

I didn't, but I have now. The skin is now being set but I still spawn at the center of the map.


Re: OnPlayerSpawn is not being called. - Sasino97 - 13.05.2011

Quote:

and when I check the RCON console it's blank.

Blank? ? ? ? It should be black XDDD Joking.... I don't really know why it isn't being called.

Did you make a GiveWeapon function?? If not, the real function name is GivePlayerWeapon


Re: OnPlayerSpawn is not being called. - DRIFT_HUNTER - 13.05.2011

Try to SetPlayerPos(......); on top of the OnPlayerSpawn and than tell me whats happening
And if you loading player position from variable or file than make sore its not 0


Re: OnPlayerSpawn is not being called. - Sasino97 - 13.05.2011

Do you have some filterscripts that returns 0 in their OnPlayerSpawn? This can be the real problem, try to disable the filterscripts!


Respuesta: Re: OnPlayerSpawn is not being called. - admantis - 13.05.2011

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Try to SetPlayerPos(......); on top of the OnPlayerSpawn and than tell me whats happening
And if you loading player position from variable or file than make sore its not 0
He will spawn in a random position from these
pawn Код:
new Float:RandomSpawn[][3] =
{
    {300.8380,1141.2859,9.1375},
    {-87.5598,1378.4382,10.273},
    {-373.0963,2220.7695,42.4912},
    {-1476.2640,2562.5850,56.1762},
    {-729.4885,1545.6746,39.0060},
    {-254.4105,2603.3188,62.8582},
    {710.4941,1207.7087,13.8481},
    {-736.2938,2747.2800,47.2266},
    {-604.9268,2716.5518,72.7231},
    {693.5667,1964.2379,5.5391},
    {116.9315,1110.1823,13.6094},
    {-857.0551,1536.6832,22.5870}
};
And Sansino, I have made the GiveWeapon function for anti weapon hacks and no filterscripts enabled.


Re: OnPlayerSpawn is not being called. - DRIFT_HUNTER - 13.05.2011

Well try make a small debug...
At top of the OnPlayerSpawn GetPlayerPos and print it so you can see player pos maybe its not 0,0,0 (farm)
And after that SetPlayerPos(to some your coordinates but use FLOAT not some variable)
GetPlayerPos and print it again

If player first printed pos is not 0 0 0 than you bugged your player spawn with something else


Re: OnPlayerSpawn is not being called. - Deskoft - 13.05.2011

Are you sure you are actually having the gamemode in the server.cfg?


Re: OnPlayerSpawn is not being called. - Seven_of_Nine - 14.05.2011

Soo easy. [I had that problem twice!] All you need is you check again / give us [without pass] the server.cfg and what do you have? Windows / Linux.

I think a mistyped format() can crash the gamemode too.