House problem
#1

Hello everybody How are you ? I Have got a one problem with house script. When i tried to buy house and server said "You already have a house" But i dont have got a house. And when my friends tried, also that. How can i fix this or delete maximum house.I Have got only this House system. Please help me i really need from that: that's the script :

pawn Код:
#define FILTERSCRIPT

#include <a_samp>
#include <float>
#include <zcmd>
#include <foreach>
#define MODE_NAME "BG RC RP 1"
#include <YSI\y_svar>
#include <Streamer>
#include <sscanf2>


#define YELLOW 0xDABB3EAA
#define WHITE 0xFFFFFFAA
#define RED 0xFF0000FF
#define GREY 0xBFC0C2FF
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define randomEx(%0,%1)             (random((%1) - (%0)) + (%0))
#define MaxApartments 500
enum Apartments
{
    Float:sEnterx,
    Float:sEntery,
    Float:sEnterz,
    Float:sExitx,
    Float:sExity,
    Float:sExitz,
    sOwner[MAX_PLAYER_NAME],
    sDescription[MAX_PLAYER_NAME],
    sOwned,
    sCreated,
    sLocked,
    sMoney,
    sPrice,
    sWorld,
    sMessage[32],
    sInt,
    sLevel,
    sSpawn
};

new ApartmentInfo[MaxApartments][Apartments];
new InApartment[MAX_PLAYERS]; // checking is player in apartment
new ApartmentPickup[sizeof(ApartmentInfo)]; // apartment pickup
new Text3D:ApartmentLabel[sizeof(ApartmentInfo)]; // 3d text in front of door
new plname[MAX_PLAYER_NAME]; // checking player name
new randomINT;

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("--------------------------------------\n");
    new string[828];
    for(new s = 0; s < sizeof(ApartmentInfo); s++)
    {
        new gFile[35];
        format(gFile, 35, "Apartments/%d.ini" ,s);
        INI_ParseFile(gFile, "LoadApartments", .bExtra = true, .extra = s);
        if(ApartmentInfo[s][sCreated] == 1)
        {
            if(ApartmentInfo[s][sOwned] == 0)
            {
                format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[s][sWorld], ApartmentInfo[s][sPrice],ApartmentInfo[s][sLevel], ApartmentInfo[s][sDescription]);
                ApartmentLabel[s] = Create3DTextLabel(string ,0x00FF00AA,ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz],25, 0, 1);
                ApartmentPickup[s] = CreateDynamicPickup(1273, 1, ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz]);
            }
            if(ApartmentInfo[s][sOwned] == 1)
            {
                format(string,sizeof(string)," {458B00}Owner: {FFFFFF}%s \n {458B00}Adress: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[s][sOwner],ApartmentInfo[s][sWorld], ApartmentInfo[s][sDescription]);
                ApartmentLabel[s] = Create3DTextLabel(string ,0x00FFFFAA,ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz],25, 0, 1);
                ApartmentPickup[s] = CreateDynamicPickup(1273, 1, ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz]);
            }
        }
    }
    return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if (IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(ApartmentInfo[i][sLocked] == 0|| strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    SetPlayerInterior(playerid,ApartmentInfo[i][sInt]); SetPlayerVirtualWorld(playerid,ApartmentInfo[i][sWorld]);
                    SetPlayerPos(playerid,ApartmentInfo[i][sExitx],ApartmentInfo[i][sExity],ApartmentInfo[i][sExitz]);
                    InApartment[playerid] = i;
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
            }
        }
        if(InApartment[playerid] != MaxApartments+1)
        {
            new i = InApartment[playerid];
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]))
            {
                SetPlayerInterior(playerid,0); SetPlayerVirtualWorld(playerid,0);
                SetPlayerPos(playerid,ApartmentInfo[i][sEnterx],ApartmentInfo[i][sEntery],ApartmentInfo[i][sEnterz]);
                InApartment[playerid] = MaxApartments+1;
                return 1;
            }
        }
    }
    return 1;
}
public OnPlayerSpawn(playerid)
{
    for(new i = 0; i < sizeof(ApartmentInfo); i++)
    {
        GetPlayerName(playerid, plname, sizeof(plname));
        if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && ApartmentInfo[i][sSpawn] == 1)
        {
            SetPlayerPos(playerid, ApartmentInfo[i][sEnterx],ApartmentInfo[i][sEntery],ApartmentInfo[i][sEnterz]);
        }
    }
    return 1;
}
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, WHITE, "Тази система е направена от:~w~~h~Bulgarian ~g~Red County ~r~Roleplay");
    return 1;
}
stock SaveApartment(idstana)
{
    new dFile[128];
    format(dFile, sizeof(dFile),"Apartments/%d.ini",idstana);
    new
    INI:File = INI_Open(dFile);

    INI_WriteFloat(File, "Enter_X",ApartmentInfo[idstana][sEnterx]);
    INI_WriteFloat(File, "Enter_Y", ApartmentInfo[idstana][sEntery]);
    INI_WriteFloat(File, "Enter_Z",ApartmentInfo[idstana][sEnterz]);
    INI_WriteFloat(File, "Exit_X", ApartmentInfo[idstana][sExitx]);
    INI_WriteFloat(File, "Exit_Y", ApartmentInfo[idstana][sExity]);
    INI_WriteFloat(File, "Exit_Z", ApartmentInfo[idstana][sExitz]);
    INI_WriteString(File, "Owner", ApartmentInfo[idstana][sOwner]);
    INI_WriteString(File, "Description", ApartmentInfo[idstana][sDescription]);
    INI_WriteInt(File, "Owned", ApartmentInfo[idstana][sOwned]);
    INI_WriteInt(File, "Created", ApartmentInfo[idstana][sCreated]);
    INI_WriteInt(File, "Locked", ApartmentInfo[idstana][sLocked]);
    INI_WriteInt(File, "Money", ApartmentInfo[idstana][sMoney]);
    INI_WriteInt(File, "Price", ApartmentInfo[idstana][sPrice]);
    INI_WriteInt(File, "World", ApartmentInfo[idstana][sWorld]);
    INI_WriteString(File, "Message", ApartmentInfo[idstana][sMessage]);
    INI_WriteInt(File, "Int", ApartmentInfo[idstana][sInt]);
    INI_WriteInt(File, "Level", ApartmentInfo[idstana][sLevel]);
    INI_WriteInt(File, "Spawn", ApartmentInfo[idstana][sSpawn]);

    INI_Close(File);
}
forward LoadApartments(idstana, name[], value[]);
public LoadApartments(idstana, name[], value[])
{
        INI_Float("Enter_X",ApartmentInfo[idstana][sEnterx]);
        INI_Float("Enter_Y",ApartmentInfo[idstana][sEntery]);
        INI_Float("Enter_Z",ApartmentInfo[idstana][sEnterz]);
        INI_Float("Exit_X",ApartmentInfo[idstana][sExitx]);
        INI_Float("Exit_Y",ApartmentInfo[idstana][sExity]);
        INI_Float("Exit_Z",ApartmentInfo[idstana][sExitz]);
        INI_String("Owner",ApartmentInfo[idstana][sOwner],32);
        INI_String("Description",ApartmentInfo[idstana][sDescription],32);
        INI_Int("Owned",ApartmentInfo[idstana][sOwned]);
        INI_Int("Created",ApartmentInfo[idstana][sCreated]);
        INI_Int("Locked",ApartmentInfo[idstana][sLocked]);
        INI_Int("Money",ApartmentInfo[idstana][sMoney]);
        INI_Int("Price",ApartmentInfo[idstana][sPrice]);
        INI_Int("World",ApartmentInfo[idstana][sWorld]);
        INI_String("Message",ApartmentInfo[idstana][sMessage],32);
        INI_Int("Int",ApartmentInfo[idstana][sInt]);
        INI_Int("Level",ApartmentInfo[idstana][sLevel]);
        INI_Int("Spawn",ApartmentInfo[idstana][sSpawn]);
        return 1;
}
stock LabelIPickup(idstana)
{
    new string[828];
    if(ApartmentInfo[idstana][sOwned] == 0)
    {
        Delete3DTextLabel(ApartmentLabel[idstana]);
        format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[idstana][sWorld], ApartmentInfo[idstana][sPrice],ApartmentInfo[idstana][sLevel], ApartmentInfo[idstana][sDescription]);
        ApartmentLabel[idstana] = Create3DTextLabel(string ,0x00FF00AA,ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz],25, 0, 1);
    }
    if(ApartmentInfo[idstana][sOwned] == 1)
    {
        Delete3DTextLabel(ApartmentLabel[idstana]);
        format(string,sizeof(string),"{458B00}Owner: {FFFFFF}%s \n {458B00}Adress: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[idstana][sOwner],ApartmentInfo[idstana][sWorld], ApartmentInfo[idstana][sDescription]);
        ApartmentLabel[idstana] = Create3DTextLabel(string ,0x00FFFFAA,ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz],25, 0, 1);
    }
    DestroyDynamicPickup(ApartmentPickup[idstana]);
    ApartmentPickup[idstana] = CreateDynamicPickup(1273, 1, ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz]);
}
//======================[CMD]==============================
CMD:apartment(playerid, params[]) // main commands
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s[48]i",text , novac))
    {
        SendClientMessage(playerid, WHITE, "HELP: /apartment info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                if(ApartmentInfo[i][sLocked] == 0)
                {
                    SendClientMessage(playerid, WHITE, "Locked: No");
                }
                format(string, sizeof(string), "Money in safe: %d $", ApartmentInfo[i][sMoney]);
                SendClientMessage(playerid, WHITE, string);
                format(string, sizeof(string), "Apartment Price: %d $", ApartmentInfo[i][sPrice]);
                SendClientMessage(playerid, WHITE, string);
                SendClientMessage(playerid, YELLOW, "|========================================|");
                return 1;
            }
        }
        return 1;
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            if(IsPlayerInRangeOfPoint(playerid, 25,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]))
            {
                if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    return 1;
}
CMD:buyapartment(playerid, params[]) // cmd to buy apartment
{
    for(new i = 0; i < sizeof(ApartmentInfo); i++)
    {
        GetPlayerName(playerid, plname, sizeof(plname));
        if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
        {
            SendClientMessage(playerid, WHITE, "You alerdy have apartment!");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && ApartmentInfo[i][sOwned] == 0)
        {
            if(GetPlayerMoney(playerid) > ApartmentInfo[i][sPrice])
            {
                if(GetPlayerScore(playerid) >= ApartmentInfo[i][sLevel])
                {
                    strmid(ApartmentInfo[i][sOwner], plname, 0, strlen(plname), 255);
                    ApartmentInfo[i][sOwned] = 1;
                    GivePlayerMoney(playerid,-ApartmentInfo[i][sPrice]);
                    SendClientMessage(playerid, WHITE, "Congratz on new apartment, type /aphelp to see all commands!");
                    strmid(ApartmentInfo[i][sOwner], plname, 0, strlen(plname), 255);
                    LabelIPickup(i);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid, GREY, "Your level is too low!"); return 1; }
            }
            else { SendClientMessage(playerid, GREY, "You don't have enough't money!"); return 1; }
        }
    }
    return 1;
}
CMD:sellapartment(playerid, params[]) // selling apartment
{
    for(new i = 0; i < sizeof(ApartmentInfo); i++)
    {
        GetPlayerName(playerid, plname, sizeof(plname));
        if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
        {
            strmid(ApartmentInfo[i][sOwner], "State", 0, strlen("State"), 255);
            ApartmentInfo[i][sOwned] = 0;
            ApartmentInfo[i][sLocked] = 1;
            GivePlayerMoney(playerid,ApartmentInfo[i][sPrice]);
            SendClientMessage(playerid, WHITE, "You have sold you apartment!");
            LabelIPickup(i);
            SaveApartment(i);
            return 1;
        }
    }
    return 1;
}
CMD:changespawn(playerid, params[]) // change spawn
{
    for(new i = 0; i < sizeof(ApartmentInfo); i++)
    {
        GetPlayerName(playerid, plname, sizeof(plname));
        if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
        {
            if(ApartmentInfo[i][sSpawn] == 1)
            {
                ApartmentInfo[i][sSpawn] = 0;
                SendClientMessage(playerid, YELLOW, "Now you will not spawn in apartment.");
                SaveApartment(i);
                return 1;
            }
            if(ApartmentInfo[i][sSpawn] == 0)
            {
                ApartmentInfo[i][sSpawn] = 1;
                SendClientMessage(playerid, YELLOW, "From now, you will spawn in apartment!");
                SaveApartment(i);
                return 1;
            }
            return 1;
        }
    }
    return 1;
}
CMD:aphelp(playerid, params[]) // list of all commands
{
    if(IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, WHITE, "Admin Commands: /setapartment | /aptel | /reapartment | /apedit");
    }
    SendClientMessage(playerid, WHITE, "User Commands: /buyapartment | /sellapartment | /changespawn");
    SendClientMessage(playerid, WHITE, "User Commands: /apartment info [any number] | lock [any number]| putmoney [value] | takemoney [value]");
    return 1;
}
//======================[ADMIN CMD]=============================
CMD:setapartment(playerid, params[]) // making apartment (ONLY RCON)
{
    if(IsPlayerAdmin(playerid))
    {
        new Float:X, Float:Y, Float:Z; new string[828]; new apid = 0;
        GetPlayerPos(playerid, X,Y,Z);
        for(new s = 0; s < sizeof(ApartmentInfo); s++)
        {
            if(ApartmentInfo[s][sCreated] == 1)
            {
                apid = s + 1;
            }
        }
        ApartmentInfo[apid][sEnterx] = X;
        ApartmentInfo[apid][sEntery] = Y;
        ApartmentInfo[apid][sEnterz] = Z;
        ApartmentInfo[apid][sOwned] = 0;
        ApartmentInfo[apid][sCreated] = 1;
        ApartmentInfo[apid][sLocked] = 1;
        ApartmentInfo[apid][sSpawn] = 1;
        ApartmentInfo[apid][sWorld] = apid;
        randomINT = randomEx(1,6); // random number from 1 to 5
        if(randomINT == 1)
        {
            ApartmentInfo[apid][sExitx] = 225.756989;
            ApartmentInfo[apid][sExity] = 1240.000000;
            ApartmentInfo[apid][sExitz] = 1082.149902;
            ApartmentInfo[apid][sInt] = 2;
            ApartmentInfo[apid][sPrice] = 37000;
            ApartmentInfo[apid][sLevel] = 1;
            SaveApartment(apid);
        }
        if(randomINT == 2)
        {
            ApartmentInfo[apid][sExitx] = 260.983978;
            ApartmentInfo[apid][sExity] = 1286.549927;
            ApartmentInfo[apid][sExitz] = 1080.299927;
            ApartmentInfo[apid][sInt] = 4;
            ApartmentInfo[apid][sPrice] = 38000;
            ApartmentInfo[apid][sLevel] = 2;
            SaveApartment(apid);
        }
        if(randomINT == 3)
        {
            ApartmentInfo[apid][sExitx] = 385.803986;
            ApartmentInfo[apid][sExity] = 1471.769897;
            ApartmentInfo[apid][sExitz] = 1080.209961;
            ApartmentInfo[apid][sInt] = 15;
            ApartmentInfo[apid][sPrice] = 39000;
            ApartmentInfo[apid][sLevel] = 3;
            SaveApartment(apid);
        }
        if(randomINT == 4)
        {
            ApartmentInfo[apid][sExitx] = -42.4992;
            ApartmentInfo[apid][sExity] = 1406.0690;
            ApartmentInfo[apid][sExitz] = 1084.4297;
            ApartmentInfo[apid][sInt] = 8;
            ApartmentInfo[apid][sPrice] = 40000;
            ApartmentInfo[apid][sLevel] = 4;
            SaveApartment(apid);
        }
        if(randomINT == 5)
        {
            ApartmentInfo[apid][sExitx] = 446.5014;
            ApartmentInfo[apid][sExity] = 507.0295;
            ApartmentInfo[apid][sExitz] = 1001.4195;
            ApartmentInfo[apid][sInt] = 12;
            ApartmentInfo[apid][sPrice] = 41000;
            ApartmentInfo[apid][sLevel] = 5;
            SaveApartment(apid);
        }
        format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[apid][sWorld], ApartmentInfo[apid][sPrice],ApartmentInfo[apid][sLevel], ApartmentInfo[apid][sDescription]);
        ApartmentLabel[apid] = Create3DTextLabel(string ,0x00FF00AA,X,Y,Z,25, 0, 1);
        strmid(ApartmentInfo[apid][sOwner],"State",0,strlen("State"),255);
        strmid(ApartmentInfo[apid][sDescription], "Apartment", 0, strlen("Apartment"), 255);
        strmid(ApartmentInfo[apid][sMessage],"For Sale",0,strlen("For Sale"),255);
        ApartmentPickup[apid] = CreateDynamicPickup(1273, 1, ApartmentInfo[apid][sEnterx], ApartmentInfo[apid][sEntery], ApartmentInfo[apid][sEnterz]);
        format(string, sizeof(string),"You have made Apartment ID: %d",apid);
        SendClientMessage(playerid, RED, string);
        LabelIPickup(apid);
        SaveApartment(apid);
        return 1;
    }
    else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
}
CMD:reapartment(playerid, params[]) // removing apartment (ONLY RCON)
{
    if(IsPlayerAdmin(playerid))
    {
        new apid;
        if(sscanf(params, "i", apid))
        {
            SendClientMessage(playerid, WHITE, "/reapartment [id]");
            return 1;
        }
        if(ApartmentInfo[apid][sCreated] == 1)
        {
            new string[500]; new file[500];
            ApartmentInfo[apid][sCreated] = 0;
            Delete3DTextLabel(ApartmentLabel[apid]);
            DestroyDynamicPickup(ApartmentPickup[apid]);
            SaveApartment(apid);
            format(string, sizeof(string),"You have removed apartment id: %d",apid);
            SendClientMessage(playerid, RED, string);
            format(file,sizeof(file),"Apartments/%d.ini",apid);
            fremove(file);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, GREY, "That apartment does not exist!");
            return 1;
        }
    }
    else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
}
CMD:aptel(playerid, params[]) // teleporting to apartment(ONLY RCON)
{
    if(IsPlayerAdmin(playerid))
    {
        new stan;
        if(sscanf(params, "i", stan))
        {
            SendClientMessage(playerid, WHITE, "/apartment [id]");
            return 1;
        }
        SetPlayerInterior(playerid,ApartmentInfo[stan][sInt]);
        SetPlayerVirtualWorld(playerid,ApartmentInfo[stan][sWorld]);
        SetPlayerPos(playerid,ApartmentInfo[stan][sExitx],ApartmentInfo[stan][sExity],ApartmentInfo[stan][sExitz]);
        InApartment[playerid] = stan;
        return 1;
    }
    else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
}
CMD:apedit(playerid, params[]) // editing apartments
{
    if(IsPlayerAdmin(playerid))
    {
        new text[48]; new broj; // broj = number
        if(sscanf(params, "s[48]i",text, broj))
        {
            SendClientMessage(playerid, WHITE, "HELP: /sedit price [cena] | level [lvl] | int [1-3]");
            return 1;
        }
        if(strcmp(text,"price",true) == 0) // editing price
        {
            if(broj < 0) { return 1; }
            for(new i = 0; i < sizeof(ApartmentInfo); i++)
            {
                new string[128];
                if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
                {
                    ApartmentInfo[i][sPrice] = broj;
                    format(string, sizeof(string), "You ahve changed Apartment ID: %d price, to: %d $", i, broj);
                    SendClientMessage(playerid, WHITE, string);
                    LabelIPickup(i);
                    SaveApartment(i);
                    return 1;
                }
            }
            return 1;
        }
        if(strcmp(text,"level",true) == 0) // editing level
        {
            if(broj < 0) { return 1; }
            for(new i = 0; i < sizeof(ApartmentInfo); i++)
            {
                new string[128];
                if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
                {
                    ApartmentInfo[i][sLevel] = broj;
                    format(string, sizeof(string), "You ahve changed Apartment ID: %d level to: %d", i, broj);
                    SendClientMessage(playerid, WHITE, string);
                    LabelIPickup(i);
                    SaveApartment(i);
                    return 1;
                }
            }
            return 1;
        }
        if(strcmp(text,"int",true) == 0) // editing interior(furniture)
        {
            if(broj < 0 || broj > 5) { SendClientMessage(playerid,GREY,"Interior(furniture) cannot be under 0 and over 5 !"); return 1; }
            for(new i = 0; i < sizeof(ApartmentInfo); i++)
            {
                new string[128];
                if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
                {
                    if(broj == 1) // default furniture
                    {
                        ApartmentInfo[i][sExitx] = 225.756989;
                        ApartmentInfo[i][sExity] = 1240.000000;
                        ApartmentInfo[i][sExitz] = 1082.149902;
                        ApartmentInfo[i][sInt] = 2;
                        format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d (this is default furniture)", i, broj);
                        SendClientMessage(playerid, WHITE, string);
                        SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
                        SaveApartment(i);
                        return 1;
                    }
                    if(broj == 2)
                    {
                        ApartmentInfo[i][sExitx] = 260.983978;
                        ApartmentInfo[i][sExity] = 1286.549927;
                        ApartmentInfo[i][sExitz] = 1080.299927;
                        ApartmentInfo[i][sInt] = 4;
                        format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
                        SendClientMessage(playerid, WHITE, string);
                        SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
                        SaveApartment(i);
                        return 1;
                    }
                    if(broj == 3)
                    {
                        ApartmentInfo[i][sExitx] = 385.803986;
                        ApartmentInfo[i][sExity] = 1471.769897;
                        ApartmentInfo[i][sExitz] = 1080.209961;
                        ApartmentInfo[i][sInt] = 15;
                        format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
                        SendClientMessage(playerid, WHITE, string);
                        SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
                        SaveApartment(i);
                        return 1;
                    }
                    if(broj == 4)
                    {
                        ApartmentInfo[i][sExitx] = -42.4992;
                        ApartmentInfo[i][sExity] = 1406.0690;
                        ApartmentInfo[i][sExitz] = 1084.4297;
                        ApartmentInfo[i][sInt] = 8;
                        format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
                        SendClientMessage(playerid, WHITE, string);
                        SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
                        SaveApartment(i);
                        return 1;
                    }
                    if(broj == 5)
                    {
                        ApartmentInfo[i][sExitx] = 446.5014;
                        ApartmentInfo[i][sExity] = 507.0295;
                        ApartmentInfo[i][sExitz] = 1001.4195;
                        ApartmentInfo[i][sInt] = 12;
                        format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
                        SendClientMessage(playerid, WHITE, string);
                        SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
                        SaveApartment(i);
                        return 1;
                    }
                }
            }
            return 1;
        }
    }
    else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)