2 problems to deal with
#1

Hello again..

Guys , i have two problems:
  1. If i press enter anywhere - gametext appears (Durys uzrakintos))
  2. When i log out and login and if i were in house my postion i setted to the sky
Here is my code:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        for(new h;h < MAX_HOUSES; h++)
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            if(IsPlayerInRangeOfPoint(playerid, 5, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]))
            {
                if(HouseInfo[h][hLocked] == 0 && (strcmp(HouseInfo[h][hOwnerName], pName, false) == 0 || strcmp(HouseInfo[h][hRenter], pName, false) == 0))
                {
                    SetPlayerInterior(playerid,HouseInfo[h][hInterior]);
                    SetPlayerVirtualWorld(playerid, HouseInfo[h][hVirtualWorld]);
                    SetPlayerPos(playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]);
                    PlayerInfo[playerid][pInHouse] = 1;
                    return 1;
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~Uzrakinta", 2000, 1);
                    return 1;
                }
            }

            if(PlayerInfo[playerid][pInHouse] == 1 && IsPlayerInRangeOfPoint(playerid, 5, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]) && HouseInfo[h][hLocked] == 0)
            {
                SetPlayerInterior(playerid,0);
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerPos(playerid, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
                PlayerInfo[playerid][pInHouse] = 0;
                return 1;
            }
            else
            {
                GameTextForPlayer(playerid, "~r~Duris Uzrakintos", 2000, 1);
                return 1;
            }
        }
    }
    return 1;
}
And here i save my players position and variable whether he is in the house.

pawn Код:
enum pInfo
{
    Float:pPosX,Float:pPosY,Float:pPosZ,Float:pAngle,
    pInterrior,
    pInHouse,
    pVirtualWorld,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Float("PositionX",PlayerInfo[playerid][pPosX]);
    INI_Float("PositionY",PlayerInfo[playerid][pPosY]);
    INI_Float("PositionZ",PlayerInfo[playerid][pPosZ]);
    INI_Float("Angle",PlayerInfo[playerid][pAngle]);
INI_Int("Interrior",PlayerInfo[playerid][pInterrior]);
INI_Int("IsInHouse",PlayerInfo[playerid][pInHouse]);
    INI_Int("VirtualWorld",PlayerInfo[playerid][pVirtualWorld]);
    return 1;
}

if(IsPlayerConnected(playerid))
    {
        GetPlayerPos(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
        GetPlayerFacingAngle(playerid,PlayerInfo[playerid][pAngle]);
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"PlayerData");
        INI_WriteFloat(File,"PositionX",PlayerInfo[playerid][pPosX]);
        INI_WriteFloat(File,"PositionY",PlayerInfo[playerid][pPosY]);
        INI_WriteFloat(File,"PositionZ",PlayerInfo[playerid][pPosZ]);
        INI_WriteFloat(File,"Angle",PlayerInfo[playerid][pAngle]);
        INI_WriteInt(File,"Interrior",PlayerInfo[playerid][pInterrior]);
        INI_WriteInt(File,"IsInHouse",PlayerInfo[playerid][pInHouse]);
        INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));
        INI_Close(File);
    }

Or maybe there is another way to save that player logged out while he was in the house and then spawn him there when he log in?
Reply


Messages In This Thread
2 problems to deal with - by Dziugsas - 25.06.2014, 14:53
Re: 2 problems to deal with - by RenovanZ - 25.06.2014, 15:05
Re: 2 problems to deal with - by Dziugsas - 25.06.2014, 15:09
Re: 2 problems to deal with - by RenovanZ - 25.06.2014, 15:13
Re: 2 problems to deal with - by Dziugsas - 25.06.2014, 15:16
Re: 2 problems to deal with - by icra - 25.06.2014, 15:26
Re: 2 problems to deal with - by Dziugsas - 25.06.2014, 15:29

Forum Jump:


Users browsing this thread: 1 Guest(s)