This is really frustrating me! Please Help!
#1

Well i have been working on a house system and it has been going well so far apart from where i enter the house ..... I am meant to go into a interior but this happens


http://imgur.com/ou1Yz


This is my house code if the need any more of it please just let me know


pawn Код:
CMD:createhouse(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You aren't an admin!");//Check if the player is currently rcon logged in.
    new HousePrice,id = HouseCount;//Creating the house price for the selected value in the command, and the last house id created.
    if(sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse [price]");//Checking if the player uses the correct syntax. The parameter "i" in sscanf means integer, also could be used as "d".
    new Float:x,Float:y,Float:z;//Creating the floats, to store the player's position.
    GetPlayerPos(playerid,x,y,z);//Getting the player's position and storing it
    HInfo[id][Price] = HousePrice;//Setting the house price to the selected one.
    HInfo[id][Owned] = 0;//Setting the house id owned = 0
    HInfo[id][XPos] = x;//Storing the XPos value to the player's x.
    HInfo[id][YPos] = y;//Storing the YPos value to the player's y.
    HInfo[id][ZPos] = z;//Storing the ZPos value to the player's z.
    HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    format(HInfo[id][Owner],24,"Nonusablenameforthishouse");//Formating the "Owner" house id value to "Nonusablenameforthishouse".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id]  = AddStaticPickup(1273, -1, x, y, z, 0);//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//Creating the house exit checkpoint and storing it in the HouseExit value.
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "House");
    INI_WriteInt(File,"Price",HousePrice);//Writing in the place "Price" the inputted "Price" value.
    INI_WriteInt(File,"Owned",0);//Setting to "Owned" = 0 in the ini file.
    INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));//Writing "VirtualWorld" = GetPlayerVirtualWorld(..);
    INI_WriteFloat(File,"XPos",x);//Writing the players pos for the check point position.
    INI_WriteFloat(File,"YPos",y);//Self explanatory.
    INI_WriteFloat(File,"ZPos",z);//Self explanatory.
    INI_WriteString(File,"Owner","Nonusablenameforthishouse");//Writing a string in "Owned" to "Nonusablenameforthishouse"
    INI_Close(File);//Closing the file with SII.
    HouseCount++;
    return 1;
}

CMD:buyhouse(playerid,params[])
{
    for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
    {
        new id = HouseCount;
        if(!IsPlayerInRangeOfPoint(playerid,8.0,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos])) continue;//Check if the player is near a house checkpoint
        if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");//Checking the players money, to see if he has enough to buy the house.
        if(HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");//Checking if the house is already owned.
        AddStaticPickup(1272, -1, HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos], 0);
        DestroyPickup(HouseEnter[id]);
        HInfo[i][Owned] = 1;//Setting the house owned var to 1.
        GameTextForPlayer(i, "Bought!", 3000, 1);
        GetPlayerName(playerid,pname,sizeof(pname));//Retrieving the player's name.
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File, "House");
        INI_WriteInt(File, "Owned",1);//Setting in the ini file "Owned" to 1
        INI_WriteString(File, "Owner",pname);//Setting the "Owner" to the player's name.
        INI_Close(File);//Closing the ini
        return 1;
    }
    SendClientMessage(playerid,-1,"You aren't near a house!");
    return 1;
}

pawn Код:
if(newkeys == KEY_CROUCH)
    {
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
    {
        new pickupid;
        if(pickupid == HouseEnter[i])//Checking if the checkpoint id corresponds to one of the house interiors
        {
            new pName[24];//Creating the new var for the players name
            GetPlayerName(playerid,pName,24);//Storing the players name
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
            {
                SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerPos(playerid,446.7281,507.0475,1001.9195);//Setting the players position.
                SetPlayerInterior(playerid,12);//Setting the players interior.
                SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);//Preventing players from different houses,
                PlayerInHouseID[playerid] = i;
            }
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)//Checking if the house is owned but the house owner and the players name don't match.
            {
                SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(HInfo[i][Owned] == 0)//Simply checking if the house isn't owned.
            {
                SendClientMessage(playerid,-1,"/buy to buy this lovely house");
            }
        }
        if(pickupid == HouseExit[i])//Checking if the checkpointid is an House exit
        {
            SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
            SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayersInteriorHouse"));//Setting the players interior to the one we stored
            SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldHouse"));//Setting the players virtual world to the one we stored.
        }
    }
 }
    return 1;
}

Thank You


Please Help Me Please
Reply
#2

Quote:
Originally Posted by Scripter12345
Посмотреть сообщение
Thank You


Please Help Me Please
You maybe forget this:
pawn Код:
public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        if(checkpointid == HouseEnter[i])
        {
            new pName[24];
            GetPlayerName(playerid,pName,24);
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)
            {
                SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));
                SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));
                SetPlayerInterior(playerid,12);
                SetPlayerPos(playerid,446.7281,507.0475,1001.4195);
                SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);
                PlayerInHouseID[playerid] = i;
            }
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)
            {
                SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(HInfo[i][Owned] == 0)
            {
                SendClientMessage(playerid,-1,"/buyhouse to buy this lovely house");
            }
        }
        if(checkpointid == HouseExit[i])
        {
            SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);
            SetPlayerInterior(playerid, GetPVarInt(playerid,"PlayersInteriorHouse"));
            SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"PlayerVirtualWorldHouse"));
    }
    return 1;
}

stock LoadHouses()
{
    new file[60],houseowner[24];
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        format(file,sizeof(file),"FAdmin/Houses/%i.ini",i);
        if(INI_Exist(file)) break;
        INI_Open(file);
        HInfo[i][Price] = INI_ReadInt("Price");
        HInfo[i][Owned] = INI_ReadInt("Owned");
        HInfo[i][XPos] = INI_ReadInt("XPos");
        HInfo[i][YPos] = INI_ReadInt("YPos");
        HInfo[i][ZPos] = INI_ReadInt("ZPos");
        HInfo[i][VirtualWorld] = INI_ReadInt("VirtualWorld");
        INI_ReadString(houseowner,"Owner");
        format(HInfo[i][Owner],24,"%s"houseowner);
        HouseEnter[i]  = CreateDynamicCP(x,y,z,1.5,HInfo[i][VirtualWorld]);
        HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HInfo[i][VirtualWorld]);
        new labelstring[100];
        switch(HInfo[i][Owned])
        {
            case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[i][Price]);}
            case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Owner]);}
        }
        HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,HInfo[i][VirtualWorld]);
        HouseCount++;
        INI_Close();
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Wickeed
Посмотреть сообщение
You maybe forget this:
pawn Код:
public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        if(checkpointid == HouseEnter[i])
        {
            new pName[24];
            GetPlayerName(playerid,pName,24);
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)
            {
                SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));
                SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));
                SetPlayerInterior(playerid,12);
                SetPlayerPos(playerid,446.7281,507.0475,1001.4195);
                SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);
                PlayerInHouseID[playerid] = i;
            }
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)
            {
                SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(HInfo[i][Owned] == 0)/
            {
                SendClientMessage(playerid,-1,"/buyhouse to buy this lovely house");
            }
        }
        if(checkpointid == HouseExit[i])
        {
            SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);
            SetPlayerInterior(playerid, GetPVarInt(playerid,"PlayersInteriorHouse"));
            SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"PlayerVirtualWorldHouse"));
    }
    return 1;
}

stock LoadHouses()
{
    new file[60],houseowner[24];
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        format(file,sizeof(file),"FAdmin/Houses/%i.ini",i);
        if(INI_Exist(file)) break;
        INI_Open(file);
        HInfo[i][Price] = INI_ReadInt("Price");
        HInfo[i][Owned] = INI_ReadInt("Owned");
        HInfo[i][XPos] = INI_ReadInt("XPos");
        HInfo[i][YPos] = INI_ReadInt("YPos");
        HInfo[i][ZPos] = INI_ReadInt("ZPos");
        HInfo[i][VirtualWorld] = INI_ReadInt("VirtualWorld");
        INI_ReadString(houseowner,"Owner");
        format(HInfo[i][Owner],24,"%s"houseowner);
        HouseEnter[i]  = CreateDynamicCP(x,y,z,1.5,HInfo[i][VirtualWorld]);
        HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HInfo[i][VirtualWorld]);
        new labelstring[100];
        switch(HInfo[i][Owned])
        {
            case 0:{format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HInfo[i][Price]);}
            case 1:{format(labelstring,sizeof(labelstring),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Owner]);}
        }
        HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,HInfo[i][VirtualWorld]);
        HouseCount++;
        INI_Close();
    }
    return 1;
}
No because i changed it .... Its not a checkpoint its a pick up


Thank You


Please Help Me Please
Reply
#4

I dont know but try this(only test xDD)
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
        //Stuff here ;DD
    return 1;
Reply
#5

Quote:
Originally Posted by Wickeed
Посмотреть сообщение
I dont know but try this(only test xDD)
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
That what this bit is on


pawn Код:
if(newkeys == KEY_CROUCH)
    {
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
    {
        new pickupid;
        if(pickupid == HouseEnter[i])//Checking if the checkpoint id corresponds to one of the house interiors
        {
            new pName[24];//Creating the new var for the players name
            GetPlayerName(playerid,pName,24);//Storing the players name
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
            {
                SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerPos(playerid,446.7281,507.0475,1001.9195);//Setting the players position.
                SetPlayerInterior(playerid,12);//Setting the players interior.
                SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);//Preventing players from different houses,
                PlayerInHouseID[playerid] = i;
            }
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)//Checking if the house is owned but the house owner and the players name don't match.
            {
                SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(HInfo[i][Owned] == 0)//Simply checking if the house isn't owned.
            {
                SendClientMessage(playerid,-1,"/buy to buy this lovely house");
            }
        }
        if(pickupid == HouseExit[i])//Checking if the checkpointid is an House exit
        {
            SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
            SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayersInteriorHouse"));//Setting the players interior to the one we stored
            SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldHouse"));//Setting the players virtual world to the one we stored.
        }
    }
 }
    return 1;
}

Thank You


Please Help Me Please
Reply
#6

Quote:
Originally Posted by Scripter12345
Посмотреть сообщение
That what this bit is on


pawn Код:
if(newkeys == KEY_CROUCH)
    {
    for(new i = 0; i < MAX_HOUSES;i++)//Looping threw all houses.
    {
        new pickupid;
        if(pickupid == HouseEnter[i])//Checking if the checkpoint id corresponds to one of the house interiors
        {
            new pName[24];//Creating the new var for the players name
            GetPlayerName(playerid,pName,24);//Storing the players name
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)//String comparing between the players name and the house owners name, to check if they match.
            {
                SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerPos(playerid,446.7281,507.0475,1001.9195);//Setting the players position.
                SetPlayerInterior(playerid,12);//Setting the players interior.
                SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);//Preventing players from different houses,
                PlayerInHouseID[playerid] = i;
            }
            if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) != 0)//Checking if the house is owned but the house owner and the players name don't match.
            {
                SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(HInfo[i][Owned] == 0)//Simply checking if the house isn't owned.
            {
                SendClientMessage(playerid,-1,"/buy to buy this lovely house");
            }
        }
        if(pickupid == HouseExit[i])//Checking if the checkpointid is an House exit
        {
            SetPlayerPos(playerid,HInfo[i][XPos]+3,HInfo[i][YPos],HInfo[i][ZPos]);//Setting the players position to checkpoint position +3
            SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayersInteriorHouse"));//Setting the players interior to the one we stored
            SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldHouse"));//Setting the players virtual world to the one we stored.
        }
    }
 }
    return 1;
}

Thank You


Please Help Me Please
You're creating a new pickup variable that will default at 0...I would use IsPlayerInRangeOfPoint instead of what you're using now...If they're in range of any house

Also you should probably do

pawn Код:
if(newkeys & KEY_CROUCH)
Reply
#7

Thank You


Please Help Me Please
Reply
#8

Thank You


Please Help Me Please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)