Houses_System, need help.
#1

I have follow the tutorial of firecat about houses systems, but i have used y_ini instead of SII..
Well i don't know why, when i enter in a interior that is same to other, when i exit, i spawn in other places instead of the right place where i enter.

pawn Код:
#define MAX_CASE 500
#define casafile "case/%d.ini"

enum casainfo
{
    Float:entrataX, // enters
    Float:entrataY,
    Float:entrataZ,
    Float:uscitaX, // exits
    Float:uscitaY,
    Float:uscitaZ,
    Text3D:labelcasa,
    nomecasa[48], //house name
    proprietario[32], // owner
    interior,
    virtualworld,
    acquisita, //owned
    prezzo, // price
    chiusa, // closed
    soldi, // money
    pickup, // pickup
    rimossa, // removed
    icona, // icon
    weed,
    seeds
}

new cinfo[MAX_CASE][casainfo];
new contocase; // housescount
new entratacasa[MAX_CASE]; //enterhouse
new uscitacasa[MAX_CASE]; //exithouse
new playerincasaid[MAX_PLAYERS]; //playerinhouseid

//This stock read the houses information like Checkpoints, labels and mapicons..

stock leggicase(i)
{
    new stringa[200];
    if(cinfo[i][acquisita] == 0)
    {
        format(stringa,200,"Owner: %s\nHouse Name:%s\nPrice:%d",cinfo[i][proprietario],cinfo[i][nomecasa],cinfo[i][prezzo]);
        cinfo[i][pickup] = CreateDynamicPickup(1273, 23,cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],-1,-1,-1,100.0);
        cinfo[i][icona] = CreateDynamicMapIcon(cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],31,0,0,-1);
        cinfo[i][labelcasa] = Create3DTextLabel(stringa,0xFFFFFF,cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],100.0,0);
        entratacasa[i] = CreateDynamicCP(cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],2.5,0, -1);
        uscitacasa[i] = CreateDynamicCP(cinfo[i][uscitaX],cinfo[i][uscitaY],cinfo[i][uscitaZ],2.5,0,-1);

    }
    if(cinfo[i][acquisita] == 1)
    {
        format(stringa,200,"Owner:%s\nHouse Name:%s\nPrice:%d",cinfo[i][proprietario],cinfo[i][nomecasa],cinfo[i][prezzo]);
        cinfo[i][pickup] = CreateDynamicPickup(1272, 23,cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],-1,-1,-1,100.0);
        cinfo[i][icona] = CreateDynamicMapIcon(cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],32,0,0,-1);
        cinfo[i][labelcasa] = Create3DTextLabel(stringa,0xFFFFFF,cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],100.0,0);
        entratacasa[i] = CreateDynamicCP(cinfo[i][entrataX],cinfo[i][entrataY],cinfo[i][entrataZ],2.5,0, -1);
        uscitacasa[i] = CreateDynamicCP(cinfo[i][uscitaX],cinfo[i][uscitaY],cinfo[i][uscitaZ],2.5,0,-1);

    }
}

// This function load is used for to load houses.

forward caricacase(id,name[],value[]);
public caricacase(id,name[],value[])
{
    INI_Float("Entratax",cinfo[id][entrataX]);
    INI_Float("Entratay",cinfo[id][entrataY]);
    INI_Float("Entrataz",cinfo[id][entrataZ]);
    INI_Float("Uscitax",cinfo[id][uscitaX]);
    INI_Float("Uscitay",cinfo[id][uscitaY]);
    INI_Float("Uscitaz",cinfo[id][uscitaZ]);
    INI_String("Nome_Casa",cinfo[id][nomecasa],34);
    INI_String("Proprietario",cinfo[id][proprietario],34);
    INI_Int("Prezzo",cinfo[id][prezzo]);
    INI_Int("Chiusa",cinfo[id][chiusa]);
    INI_Int("Interior",cinfo[id][interior]);
    INI_Int("VW",cinfo[id][virtualworld]);
    INI_Int("Acquisita",cinfo[id][acquisita]);
    INI_Int("Soldi",cinfo[id][soldi]);
    INI_Int("Weed",cinfo[id][weed]);
    INI_Int("Seeds",cinfo[id][seeds]);
    return 1;
}

public OnGameModeInit()
{
    DisableInteriorEnterExits();
    for(new i = 0; i < MAX_CASE; i++)
    {
        new hfile[35];
        format(hfile,35,casafile,i);
        if(fexist(hfile))
        {
            INI_ParseFile(hfile,"caricacase", .bExtra = true, .extra = i); // function that load houses.
            leggicase(i); //readhouses
        }
    }

//....

return 1;
}

public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_CASE; i++)
    {
        if(checkpointid == entratacasa[i]) // if checkpointid is enterhouses checkpoints
        {
            new nome[24];
            GetPlayerName(playerid,nome,sizeof(nome));
            if(cinfo[i][acquisita] == 1 && strcmp(cinfo[i][proprietario],nome) == 0) //if the house is owned and owner is true..
            {
                SetPVarInt(playerid,"PlayersInteriorCase",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldCase",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerInterior(playerid,cinfo[i][interior]); //Set Player interior
                SetPlayerPos(playerid,cinfo[i][uscitaX]+3,cinfo[i][uscitaY],cinfo[i][uscitaZ]); //set player pos to pos of exit. (inside interior)
                SetPlayerVirtualWorld(playerid,cinfo[i][virtualworld]);
                playerincasaid[playerid] = i; // This is the variable that should save the player pos in house i so that him when exit don't spawn in other places.. (but i think that doesn't works)..
            }
            if(cinfo[i][acquisita] == 1 && cinfo[i][chiusa] == 1 && strcmp(cinfo[i][proprietario],nome) != 0)
            {
                GameTextForPlayer(playerid,"House ~r~Closed!",2000,3);
            }
            if(cinfo[i][acquisita] == 1 && strcmp(cinfo[i][proprietario],nome) != 0 && cinfo[i][chiusa] == 0)
            {
                SetPVarInt(playerid,"PlayersInteriorCase",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldCase",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerInterior(playerid,cinfo[i][interior]);
                SetPlayerPos(playerid,cinfo[i][uscitaX]+3,cinfo[i][uscitaY],cinfo[i][uscitaZ]);
                SetPlayerVirtualWorld(playerid,cinfo[i][virtualworld]);
                playerincasaid[playerid] = i; //same if the player isn't the really owner but the door is open.
            }
            if(cinfo[i][acquisita] == 0) // if isn't owned..
            {
                GameTextForPlayer(playerid,"~g~/bhouse for buy this~r~ House!",2000,3);
            }
        }
        if(checkpointid == uscitacasa[i]) // this set the player outside the interior..
        {
            SetPlayerPos(playerid,cinfo[i][entrataX]+3,cinfo[i][entrataY],cinfo[i][entrataZ]);
            SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayerInteriorCase"));
            SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldCase"));
        }
    }

//CMD for creating houses..

CMD:chouse(playerid,params[])
{
    new id = contocase; // id = housescount
    new Prezzo; // price
    new Float:Posx,Float:Posy,Float:Posz;
    new nome[32]; //name
    new stringa[100]; //string

    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "[SERVER] You must be RCON admin");
    if(sscanf(params,"s[32]i",nome,Prezzo)) return SendClientMessage(playerid,-1,"[SERVER] Use /chouse [Name][Price]");
    if(id >= MAX_CASE) return SendClientMessage(playerid, -1, "[SERVER] Try Again. You have typed a wrong house id");
    format(stringa,sizeof(stringa),casafile,id);
    if(fexist(stringa)) return SendClientMessage(playerid, -1, "[SERVER] House on that id already exist");

    GetPlayerPos(playerid,Posx,Posy,Posz);

    new hfile[40];
    format(hfile,40,casafile,id);
    new INI:file = INI_Open(hfile);

    INI_WriteFloat(file,"Entratax",Posx);
    INI_WriteFloat(file,"Entratay",Posy);
    INI_WriteFloat(file,"Entrataz",Posz);
    INI_WriteFloat(file,"Uscitax",443.9237);
    INI_WriteFloat(file,"Uscitay",509.4609);
    INI_WriteFloat(file,"Uscitaz",1001.4195);
    INI_WriteString(file,"Nome_Casa",nome);
    INI_WriteString(file,"Proprietario","Apartment");
    INI_WriteInt(file,"Prezzo",Prezzo);
    INI_WriteInt(file,"Chiusa",1);
    INI_WriteInt(file,"Interior",12);
    INI_WriteInt(file,"VW",GetPlayerVirtualWorld(playerid));
    INI_WriteInt(file,"Acquisita",0);
    INI_WriteInt(file,"Soldi",0);
    INI_WriteInt(file,"Weed",0);
    INI_WriteInt(file,"Seeds",0);

    INI_Close(file);

    cinfo[id][entrataX] = Posx;
    cinfo[id][entrataY] = Posy;
    cinfo[id][entrataZ] = Posz;
    cinfo[id][uscitaX] = 443.9237;
    cinfo[id][uscitaY] = 509.4609;
    cinfo[id][uscitaZ] = 1001.4195;
    format(cinfo[id][nomecasa],48,"%s",nome);
    format(cinfo[id][proprietario],32,"Apartment");
    cinfo[id][prezzo] = Prezzo;
    cinfo[id][chiusa] = 1;
    cinfo[id][interior] = 12;
    cinfo[id][virtualworld] = GetPlayerVirtualWorld(playerid);
    cinfo[id][acquisita] = 0;
    cinfo[id][soldi] = 0;
    cinfo[id][weed] = 0;
    cinfo[id][seeds] = 0;

    cinfo[id][pickup] = CreateDynamicPickup(1273, 23, Posx,Posy,Posz,-1,-1,-1,100.0);
    format(stringa,100,"Owner: Apartment\nHouse Name:%s\nPrice:%d\n ID:%d",nome,Prezzo,id);
    cinfo[id][labelcasa] = Create3DTextLabel(stringa,0xFFFFFF,Posx,Posy,Posz,3.5,GetPlayerVirtualWorld(playerid));
    cinfo[id][icona] = CreateDynamicMapIcon(Posx,Posy,Posz,31,0,GetPlayerVirtualWorld(playerid),-1);
    entratacasa[id] = CreateDynamicCP(Posx,Posy,Posz,2.5,GetPlayerVirtualWorld(playerid), -1);
    uscitacasa[id] = CreateDynamicCP(cinfo[id][uscitaX],cinfo[id][uscitaY],cinfo[id][uscitaZ],2.5,GetPlayerVirtualWorld(playerid),-1);

    contocase++;
   
    SendClientMessage(playerid, -1, "[SERVER] You have create a house");
    return 1;
}
Well, i hope that you help me.. cuz i have search for to study one solution and i haven't find it yet, i think that the variable

pawn Код:
playerincasaid[playerid] = i; // playerinhouseid[playerid] = i;
should works for don't fall in to this mistake.. but it doesn't work.. please, help me, thanks.
Reply
#2

Nobody can help me ?? з_з
Reply
#3

bump
Reply
#4

omg, nobody knows help me..?! bahh.
Reply
#5

Ceate an array with a pos for each house id. When a player enter in a house set into a variable which house he is. Then set his pos when he exits house based on that array positions.
Reply
#6

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Ceate an array with a pos for each house id. When a player enter in a house set into a variable which house he is. Then set his pos when he exits house based on that array positions.
can you do an exemple with my script ?
Anyway, thanks for read.
Reply
#7

You are not saving the right positions of the exits (uscita) in your "createhouse" CMD. Make sure you don't just put them in hard coded like you do it now: "443.9237", "509.4609", "1001.4195.
pawn Код:
INI_WriteFloat(file,"Entratax",Posx);
INI_WriteFloat(file,"Entratay",Posy);
INI_WriteFloat(file,"Entrataz",Posz);
INI_WriteFloat(file,"Uscitax",443.9237);
INI_WriteFloat(file,"Uscitay",509.4609);
INI_WriteFloat(file,"Uscitaz",1001.4195);
....
....
....
cinfo[id][entrataX] = Posx;
cinfo[id][entrataY] = Posy;
cinfo[id][entrataZ] = Posz;
cinfo[id][uscitaX] = 443.9237;
cinfo[id][uscitaY] = 509.4609;
cinfo[id][uscitaZ] = 1001.4195;
You need to create an extra step in the creation of a house, where you ask the player to go to the exit position, and maybe type a CMD. Then in your script you can set the right positions for Uscitax, Uscitay and Uscitaz when the player types the command.
Reply
#8

you havn't read this?
pawn Код:
entratacasa[id] = CreateDynamicCP(Posx,Posy,Posz,2.5,GetPlayerVirtualWorld(playerid), -1);
    uscitacasa[id] = CreateDynamicCP(cinfo[id][uscitaX],cinfo[id][uscitaY],cinfo[id][uscitaZ],2.5,GetPlayerVirtualWorld(playerid),-1);
pawn Код:
public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i = 0; i < MAX_CASE; i++)
    {
        if(checkpointid == entratacasa[i]) // if checkpointid is enterhouses checkpoints
        {
            new nome[24];
            GetPlayerName(playerid,nome,sizeof(nome));
            if(cinfo[i][acquisita] == 1 && strcmp(cinfo[i][proprietario],nome) == 0) //if the house is owned and owner is true..
            {
                SetPVarInt(playerid,"PlayersInteriorCase",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldCase",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerInterior(playerid,cinfo[i][interior]); //Set Player interior
                SetPlayerPos(playerid,cinfo[i][uscitaX]+3,cinfo[i][uscitaY],cinfo[i][uscitaZ]); //set player pos to pos of exit. (inside interior)
                SetPlayerVirtualWorld(playerid,cinfo[i][virtualworld]);
                playerincasaid[playerid] = i; // This is the variable that should save the player pos in house i so that him when exit don't spawn in other places.. (but i think that doesn't works)..
            }
            if(cinfo[i][acquisita] == 1 && cinfo[i][chiusa] == 1 && strcmp(cinfo[i][proprietario],nome) != 0)
            {
                GameTextForPlayer(playerid,"House ~r~Closed!",2000,3);
            }
            if(cinfo[i][acquisita] == 1 && strcmp(cinfo[i][proprietario],nome) != 0 && cinfo[i][chiusa] == 0)
            {
                SetPVarInt(playerid,"PlayersInteriorCase",GetPlayerInterior(playerid));//Storing, so later we can reset it back
                SetPVarInt(playerid,"PlayerVirtualWorldCase",GetPlayerVirtualWorld(playerid));//Storing, so later we can reset it back
                SetPlayerInterior(playerid,cinfo[i][interior]);
                SetPlayerPos(playerid,cinfo[i][uscitaX]+3,cinfo[i][uscitaY],cinfo[i][uscitaZ]);
                SetPlayerVirtualWorld(playerid,cinfo[i][virtualworld]);
                playerincasaid[playerid] = i; //same if the player isn't the really owner but the door is open.
            }
            if(cinfo[i][acquisita] == 0) // if isn't owned..
            {
                GameTextForPlayer(playerid,"~g~/bhouse for buy this~r~ House!",2000,3);
            }
        }
        if(checkpointid == uscitacasa[i]) // this set the player outside the interior..
        {
            SetPlayerPos(playerid,cinfo[i][entrataX]+3,cinfo[i][entrataY],cinfo[i][entrataZ]);
            SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayerInteriorCase"));
            SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldCase"));
        }
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)