SA-MP Forums Archive
[PROBLEM] SetPlayerPos - 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: [PROBLEM] SetPlayerPos (/showthread.php?tid=225546)



[PROBLEM] SetPlayerPos - viKKmaN - 13.02.2011

For some reason my players fall through the floor when they spawn, and sometimes they don't, which annoys me ALLOT.

Here's my code:

pawn Код:
new Float:CivilianRandomSpawns[3][3] = {
{1481.0154, -1770.7731, 18.7958},
{2446.4629, 2376.1675, 12.1635},
{-1494.1964, 920.0549, 7.1875}
};
new Float:PoliceRandomSpawns[3][3] = {
{2295.2734, 2468.7920, 10.8203},
{-1620.3188, 690.2934, 7.1875},
{1550.9331, -1675.5458, 15.6261}
};

public OnPlayerSpawn(playerid)
{
           SetPlayerRandomSpawn(playerid);
           return 1;
}
function SetPlayerRandomSpawn(playerid)
{
    if(PlayerLogged[playerid] && PlayerInfo[playerid][pHouse])// Player is logged in & owns a house
    {
        SetPlayerInterior(playerid, HouseInfo[PlayerInfo[playerid][pHouse]][hIntID]);
        SetPlayerPos(playerid, HouseInfo[PlayerInfo[playerid][pHouse]][hIntX], HouseInfo[PlayerInfo[playerid][pHouse]][hIntY], HouseInfo[PlayerInfo[playerid][pHouse]][hIntZ]);
        SetPlayerVirtualWorld(playerid, HouseInfo[PlayerInfo[playerid][pHouse]][hIntWorld]);
        return 1;
    }
    if(PlayerTeam[playerid] == TEAM_POLICE)
    {
        SetPlayerInterior(playerid, 0);
        new rand = random(sizeof(PoliceRandomSpawns));
        SetPlayerPos(playerid, PoliceRandomSpawns[rand][0], PoliceRandomSpawns[rand][1], PoliceRandomSpawns[rand][2]);
    }
    if(PlayerTeam[playerid] == TEAM_CIVILIAN || PlayerTeam[playerid] == TEAM_CRIMINAL)
    {
        SetPlayerInterior(playerid, 0);
        new rand = random(sizeof(CivilianRandomSpawns));
        SetPlayerPos(playerid, CivilianRandomSpawns[rand][0], CivilianRandomSpawns[rand][1], CivilianRandomSpawns[rand][2]);
    }
    return 1;
}
Can anyone try to figure this out? I also tried SetPlayerPosFindZ() but if i use this then i can't set the player's interior/world anymore. Anyone... this is frustrating...


Re: [PROBLEM] SetPlayerPos - Mokerr - 13.02.2011

You should use elseif, cause what if someone owns a house and is part of police.


Re: [PROBLEM] SetPlayerPos - viKKmaN - 13.02.2011

That's why i placed 'return 1;' there. If he's police he'll spawn in the house also.
But that's not what bothers me. My players fall through the floor!


Re: [PROBLEM] SetPlayerPos - Steven82 - 14.02.2011

Your not making sense


Re: [PROBLEM] SetPlayerPos - Antonio [G-RP] - 14.02.2011

It's probably because the interior hasn't loaded fully. Try freezing the player and putting a 1 second timer in to unfreeze the player.


Re: [PROBLEM] SetPlayerPos - -Rebel Son- - 14.02.2011

or set their Z Cord +2 Example. "XXX.XXX+2);


Re: [PROBLEM] SetPlayerPos - bartje01 - 14.02.2011

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
It's probably because the interior hasn't loaded fully. Try freezing the player and putting a 1 second timer in to unfreeze the player.
I recommend you this one.
I used it too.

Quote:
Originally Posted by -Rebel Son-
Посмотреть сообщение
or set their Z Cord +2 Example. "XXX.XXX+2);
This'll probaly work as well but I don't like the way it works. Like when you enter the house it's like a slap.
So use the first option





Quote:
Originally Posted by Steven82
Посмотреть сообщение
Your not making sense
Are you?....


Re: [PROBLEM] SetPlayerPos - viKKmaN - 14.02.2011

I tried
pawn Код:
#define SetPlayerPosEx(%0,%1,%2,%3) SetPlayerPos(%0,%1,%2,%3); TogglePlayerControllable(%0,0); SetTimerEx("TogglePlayerControllable",1000,false,"ii",%0,1)
But it has a flaw:
- It sets the player's position
- It freezes the player
- It DOESN'T unfreeze the player!!!!!


Re: [PROBLEM] SetPlayerPos - smeti - 14.02.2011

Quote:
Originally Posted by viKKmaN
Посмотреть сообщение
I tried
pawn Код:
#define SetPlayerPosEx(%0,%1,%2,%3) SetPlayerPos(%0,%1,%2,%3); TogglePlayerControllable(%0,0); SetTimerEx("TogglePlayerControllable",1000,false,"ii",%0,1)
But it has a flaw:
- It sets the player's position
- It freezes the player
- It DOESN'T unfreeze the player!!!!!
SetTimer called public function, not native.

Try:
pawn Код:
#define SetPlayerPosEx(%0,%1,%2,%3) SetPlayerPos(%0,%1,%2,%3); TogglePlayerControllable(%0,0); SetTimerEx("UnFreeze",1000,false,"i",%0)

forward UnFreeze(playerid);
public UnFreeze(playerid)
{
     TogglePlayerControllable(playerid, true);
}



Re: [PROBLEM] SetPlayerPos - viKKmaN - 14.02.2011

They still fall through the texture... and they seem to be spawning at coords 0.0 0.0 0.0 under the floor...