Help (Explain) About System
#1

hello
i want explain about house system i will use more house but i cant understand
how to make new interior with this one
Quote:

interior = 2
pos = 271.884979,306.631988,999.148437

need explain # how to make new interior in system
PHP код:
// *i had some help from a toturial to make this script*
#include <a_samp>
#include <streamer>
#include <zcmd>
#include <sscanf2>
#include <SII>
#define MAX_HOUSES 100
enum HouseInfo
{
    
Owner[24],
    
Owned,
    
Price,
    
Float:XPos,
    
Float:YPos,
    
Float:ZPos,
    
VirtualWorld,
    
Text3D:HouseLabel
}
new 
HInfo[MAX_HOUSES][HouseInfo];
new 
HouseCount;
new 
HouseEnter[MAX_HOUSES];
new 
HouseExit[MAX_HOUSES];
new 
PlayerInHouseID[MAX_PLAYERS];
public 
OnGameModeInit()
{
    
SendRconCommand("rcon_password test");
    
SetGameModeText("Beta Test");
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SpawnPlayer(playerid);
    
GivePlayerMoney(playerid10000000);
    return 
1;
}
CMD:createhouse(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You need to be logged in as RCON Admin");
    new 
HousePrice,id HouseCount;
    if(
sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse [price]");
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,x,y,z);
    
HInfo[id][Price] = HousePrice;
    
HInfo[id][Owned] = 0;
    
HInfo[id][XPos] = x;
    
HInfo[id][YPos] = y;
    
HInfo[id][ZPos] = z;
    
HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    
format(HInfo[id][Owner],24,"Nonusablenameforthishouse");
    
SendClientMessage(playerid,-1,"House created");
    
HouseEnter[id] = CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));
    
HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));
    new 
file[40],labelstring[100];
    
format(file,sizeof(file),"FHouse/Houses/%i.ini",id);
    
INI_Open(file);
    
INI_WriteInt("Price",HousePrice);
    
INI_WriteInt("Owned",0);
    
INI_WriteInt("VirtualWorld",GetPlayerVirtualWorldplayerid));
    
INI_WriteFloat("XPos",x);
    
INI_WriteFloat("YPos",y);
    
INI_WriteFloat("ZPos",z);
    
INI_WriteString("Owner","Nonusablenameforthishouse ");
    
INI_Save();
    
INI_Close();
    
format(labelstring,sizeof(labelstring),"Owned: No \nPrice: %i",HousePrice);
    
HInfo[id][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,GetPlayerVirtualWorld(playerid));
    
HouseCount++;
    return 
1;
}
CMD:buy(playerid,params[])
{
    for(new 
0MAX_HOUSES;i++)
    {
        if(!
IsPlayerInRangeOfPoint(playerid,8.0,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos])) continue;
        if(
GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");
        if(
HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");
        
HInfo[i][Owned] = 1;
        new 
file[60],pName[24],string[100];
        
GetPlayerName(playerid,pName,sizeof(pName));
        
format(HInfo[i][Owner],24,"%s",pName);
        
format(file,sizeof(file),"FHouse/Houses/%i.ini",i);
        
INI_Open(file);
        
INI_WriteInt("Owned",1);
        
INI_WriteString("Owner",pName);
        
INI_Save();
        
INI_Close();
        
format(string,sizeof(string),"Owned: Yes \nPrice: %i \nOwner: %s",HInfo[i][Price],pName);
        
Update3DTextLabelText(HInfo[i][HouseLabel],0xFF0000FF,string);
        
GivePlayerMoney(playerid,-HInfo[i][Price]);
    }
    
SendClientMessage(playerid,-1,"You aren't near a house!");
    return 
1;
}
CMD:sell(playerid,params[])
{
    for(new 
0MAX_HOUSES;i++)
    {
        if(!
IsPlayerInRangeOfPoint(playerid,8.0,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos])) continue;
        if(
HInfo[i][Owned] == 0) return SendClientMessage(playerid,-1,"This house isn't owned");
        new 
pName[24];
        
GetPlayerName(playerid,pName,sizeof(pName));
        if(
HInfo[i][Owned] == && strcmp(pName,HInfo[i][Owner]) != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");
        
HInfo[i][Owned] = 0;
        new 
file[60],string[100];
        
format(HInfo[i][Owner],24,"Nonusablenameforthishouse");
        
format(file,sizeof(file),"FHouse/Houses/%i.ini",i);
        
INI_Open(file);
        
INI_WriteInt("Owned",0);
        
INI_WriteString("Owner","Nonusablenameforthishouse ");
        
INI_Save();
        
INI_Close();
        
format(string,sizeof(string),"Owned: No \nPrice: %i \nOwner: None",HInfo[i][Price],pName);
        
Update3DTextLabelText(HInfo[i][HouseLabel],0xFF0000FF,string);
        return 
1;
    }
    
SendClientMessage(playerid,-1,"You aren't near a house!");
    return 
1;
}
public 
OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new 
0MAX_HOUSES;i++)
    {
        if(
checkpointid == HouseEnter[i])
        {
            new 
pName[24];
            
GetPlayerName(playerid,pName,24);
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName) == 0)
            {
                
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));
                
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));
                
SetPlayerInterior(playerid,12);// u can change this to the interior of ur house interior
                
SetPlayerPos(playerid,446.7281,507.0475,1001.4195);// u can change the position of the interior
                
SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]);
                
PlayerInHouseID[playerid] = i;
            }
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName)!= 0)
            {
                
SendClientMessage(playerid,-1,"You don't own this house");
            }
            if(
HInfo[i][Owned] == 0)
            {
            
SendClientMessage(playerid,-1,"/buy 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 
0MAX_HOUSES;i++)
    {
        
format(file,sizeof(file),"FAdmin/Houses/%i.ini",i);
        if(!
INI_Exist(file)) continue;
        
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(HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos],1.5,HInfo[i][VirtualWorld]);
        
HouseExit[i] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,HI nfo[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][Price],HInfo[i][Owner]);
        }
        
HInfo[i][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos],25.0,HInfo[i][VirtualWorld]);
        
HouseCount++;
        
INI_Close();
    }
    return 
1;

+Rep
Reply
#2

Bump!!!
Reply
#3

Replace OnPlayerEnterDynamicCP with this. Your code currently will only allow one interior to be used by all the houses loaded. You can perhaps use an array to store the details of possible interiors and then store the key into the file associated with each house.
PHP код:
public OnPlayerEnterDynamicCP(playerid,checkpointid

    for(new 
0MAX_HOUSES;i++) 
    { 
        if(
checkpointid == HouseEnter[i]) 
        { 
            new 
pName[24]; 
            
GetPlayerName(playerid,pName,24); 
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName) == 0
            { 
                
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid)); 
                
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid)); 
                
SetPlayerInterior(playerid,2);// u can change this to the interior of ur house interior 
                
SetPlayerPos(playerid,271.884979,306.631988,999.148437);// u can change the position of the interior 
                
SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]); 
                
PlayerInHouseID[playerid] = i
            } 
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName)!= 0
            { 
                
SendClientMessage(playerid,-1,"You don't own this house"); 
            } 
            if(
HInfo[i][Owned] == 0
            { 
            
SendClientMessage(playerid,-1,"/buy 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

Reply
#4

Quote:
Originally Posted by 4D1L
Посмотреть сообщение
Replace OnPlayerEnterDynamicCP with this. Your code currently will only allow one interior to be used by all the houses loaded. You can perhaps use an array to store the details of possible interiors and then store the key into the file associated with each house.
PHP код:
public OnPlayerEnterDynamicCP(playerid,checkpointid

    for(new 
0MAX_HOUSES;i++) 
    { 
        if(
checkpointid == HouseEnter[i]) 
        { 
            new 
pName[24]; 
            
GetPlayerName(playerid,pName,24); 
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName) == 0
            { 
                
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid)); 
                
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid)); 
                
SetPlayerInterior(playerid,2);// u can change this to the interior of ur house interior 
                
SetPlayerPos(playerid,271.884979,306.631988,999.148437);// u can change the position of the interior 
                
SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]); 
                
PlayerInHouseID[playerid] = i
            } 
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName)!= 0
            { 
                
SendClientMessage(playerid,-1,"You don't own this house"); 
            } 
            if(
HInfo[i][Owned] == 0
            { 
            
SendClientMessage(playerid,-1,"/buy 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

thats my problems i can made 1 house only
and i want add more interior house you know what i mean now ?

PHP код:
public OnPlayerEnterDynamicCP(playerid,checkpointid

    for(new 
0MAX_HOUSES;i++) 
    { 
        if(
checkpointid == HouseEnter[i]) 
        { 
            new 
pName[24]; 
            
GetPlayerName(playerid,pName,24); 
            if(
HInfo[i][Owned] == && strcmp(HInfo[i][Owner],pName) == 0
            { 
                
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid)); 
                
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid)); 
                
SetPlayerInterior(playerid,2);// u can change this to the interior of ur house interior 
                
SetPlayerPos(playerid,271.884979,306.631988,999.148437);// u can change the position of the interior 
                
SetPlayerVirtualWorld(playerid,HInfo[i][VirtualWorld]); 
                
PlayerInHouseID[playerid] = i
            } 
this my problems cant made new interior in this system 1only can use and i want explain to add new interior
Reply
#5

Bump!
Reply
#6

You can create an array just as you have your HInfo one, it'd look like this:

Код:
new Float:HousePos[][] =
{
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int}
};
And make the order match your MAX_HOUSES loop

So instead of doing this:

Код:
SetPlayerPos(playerid,271.884979,306.631988,999.148437)
You'd use your array with help of the loop, like this:

Код:
SetPlayerPos(playerid,HousePos[i][0],HousePos[i][1],HousePos[i][2])
Same for the interior.
Reply
#7

Quote:
Originally Posted by Troydere
Посмотреть сообщение
You can create an array just as you have your HInfo one, it'd look like this:

Код:
new Float:HousePos[][] =
{
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int},
	{pos1,pos2,pos3,int}
};
And make the order match your MAX_HOUSES loop

So instead of doing this:

Код:
SetPlayerPos(playerid,271.884979,306.631988,999.148437)
You'd use your array with help of the loop, like this:

Код:
SetPlayerPos(playerid,HousePos[i][0],HousePos[i][1],HousePos[i][2])
Same for the interior.
+Rep
But i Cant understand
only i want way to make new interior + pos + exit checkpoints
interior (12)
Pos House(2324.419921,-1145.568359,1050.710083)
Checkpoints Exit Pos (2320.419921,-1145.568359,1050.710083)
/createhouse (Amount already here) (choose house 1 or 2)for what house i will made it.
Reply
#8

Oh! I see now, sorry, my previous answer was not accurate regarding your problem.

You can't make a new interior out of the blue whenever you want, you have to either map it yourself and get its coordinates, or find already made interiors mappings.

That system (as far I can see) only uses one interior position and changes the virtual world of the player only. You can only change the entrance points as you can see.

Other thing you could do with my previous answer is to enable the default San Andreas entrances/exits, save the position inside one of them and use them in the array as I explained to you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)