13.02.2011, 21:25
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:
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...
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;
}