SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 18/05/2020, 05:15 AM   #1
StevenLV
Big Clucker
 
StevenLV's Avatar
 
Join Date: Apr 2017
Location: Pakistan
Posts: 144
Reputation: 11
Default Steven's Dynamic House System [MySQL]

Well, I was lurking around with scripting and scripted a filterscript. It is a Dynamic House system. Hope you like it:

Features:
- Totally Dynamic + MYSQL R41
- Drugs storage
- Money storage

-- I did this in one day btw, so any errors please tell me, i didnt find any bug btw.

CMDS:
- /ahouse - for admin to create or edit house
- /house for the owner

I havent took screenshots and its just simple so no ss:
AND I know ppl will say this is same thing others have posted so yeah maybe but this is basic for someone to learn or Maybe I myself will learn by posting here.
Criticism is highly appreciated.

CODE: (Pastenbin is dead)
PHP Code:


#define FILTERSCRIPT

#include <a_samp>
#include <a_mysql>
#include <zcmd>
#include <sscanf2>
#include <streamer>
#include <a_zones>

new MySQL:MySQL;
#define mysql_host                                                      "localhost"
#define mysql_user                                                      "root"
#define mysql_password                                               ""
#define mysql_database                                                  "lvrporiginal"

#define MAX_HOUSES      200
#define DRUGS_TYPES             3
#define HOUSE_WEAPON_SLOTS       2

#define PUBLIC:%0(%1) forward %0(%1); public %0(%1)

#define COLOR_GREY                                                          0x5D5D5DFF
#define COLOR_WHITE                                                       0xFFFFFFFF
#define COLOR_BLACK                                                          0x000000FF
#define COLOR_RED                                                         0xFF0000FF
#define COLOR_GREEN                                                     0x33AA33AA
#define COLOR_GOLD                                                         0xB8860BAA
#define COLOR_SUCCESS                                                   0x33AA33AA

// macros
#define  CANT_USE_CMD "You are not allowed to use this cmd."
#define PNF "Player is not connected"

RPName(playerid)
{
    new 
pname[24];
    
format(pname24NoUnderscore(GetName(playerid)));
    return 
pname;
}

enum pDatais
{
    
Admin,
    
pDrugs[DRUGS_TYPES],
    
Money,
}
new 
pData[MAX_PLAYERS][pDatais];

enum HouseData
{
    
hOwner[24],
    
Float:hX,
    
Float:hY,
    
Float:hZ,
    
hInt,
    
hVW,
    
hAlarm,
    
hMoney,
    
hInteriorPack,

    
hPickupID,
    
Text3D:hLabel,
    
hActive,

    
hLocked,
    
hSell,
    
hSafe,
    
hDrugs [DRUGS_TYPES],
    
hGuns [HOUSE_WEAPON_SLOTS],
    
hAmmo [HOUSE_WEAPON_SLOTS],
}
new 
hData[MAX_HOUSES][HouseData];

enum
{
    
DRUG_COCAINE,
    
DRUG_CANNABIS,
    
DRUG_HEROIN,
}

enum drugstypes
{
    
drugid// id
    
drugname[24], // name
    
drugprice// Drug dealer has to buy for
    
drughp// health ++
}
new 
DrugData[DRUGS_TYPES][drugstypes] = {

    {
DRUG_CANNABIS,         "Cannabis",        100,        20}, // 0
    
{DRUG_COCAINE,             "Cocaine",        100,        30}, // 1
    
{DRUG_HEROIN,             "Heroin",        100,        40// 2
};

enum _Interiors {
    
hintpack,
    
Float:hintx,
    
Float:hinty,
    
Float:hintz,
    
hinterior,
    
hvirtual,
    
hprice,
}
new 
HouseInteriors[][_Interiors] = {
//  intpack     x           y           z       int     vw      price
    
{0,        445.04,        508.86,     1001.42,    12,        2,         0     },
    {
1,        2807.62,    -1171.90,    1025.57,    8,        15,        100000},
    {
2,        27.13,        1341.15,    1084.38,    10,        20,        100000},
    {
3,        2333.11,    -1075.10,    1049.02,    6,        17,        100000},
    {
4,        261.00,     1286.00,     1080.2600,     4,        1,        100000},
    {
5,        2350.34,    -1181.65,    1027.98,    5,        16,        100000},
    {
6,        2268.39,    -1210.45,    1047.75,    10,        18,        100000},
    {
7,        318.57,        1118.21,    1083.88,    5,        19,        100000},
    {
8,        219.34,        1251.26,    1082.15,    2,        4,        100000},
    {
9,        295.34,        1473.09,    1080.26,    15,        3,        100000},
    {
10,    447.73,        1400.44,    1084.30,    2,        8,        100000},
    {
11,    2282.91,    -1138.29,    1050.90,    11,        14,        100000},
    {
12,    83.30,        1324.70,    1083.86,    9,        11,        100000},
    {
13,    2194.79,    -1204.35,    1049.02,    6,        12,        100000},
    {
14,    2365.30,    -1132.92,    1050.88,    8,        13,        100000},
    {
15,    227.72,        1114.39,    1080.99,    5,        9,        100000},
    {
16,    225.74,        1024.54,    1084.00,    7,        10,        100000},
    {
17,    1261.4819,    -785.4633,    1091.9063,    9,        11,        100000}
};

enum
{
    
DIALOG_ADMIN_HOUSE,
    
DIALOG_ADMIN_HOUSE_OWNER,
    
DIALOG_ADMIN_HOUSE_SELL,
    
DIALOG_ADMIN_HOUSE_INT,
    
DIALOG_ADMIN_HOUSE_MONEY,
    
DIALOG_PLAYER_HOUSE_OUT,
    
DIALOG_PLAYER_HOUSE_SELL,
    
DIALOG_PLAYER_HOUSE_ALARM,
    
DIALOG_PLAYER_HOUSE_INT,
    
DIALOG_PLAYER_HOUSE,
    
DIALOG_PLAYER_HOUSE_IN,
    
DIALOG_HOUSE_IN_SAFE,
    
DIALOG_HOUSE_IN_MONEY,
    
DIALOG_HOUSE_IN_DRUGS,
    
DIALOG_HOUSE_IN_GUNS,
    
DIALOG_HOUSE_MONEY_TAKE,
    
DIALOG_HOUSE_MONEY_PUT,
    
DIALOG_HOUSE_DRUGS_TAKE,
    
DIALOG_HOUSE_DRUGS_PUT,
    
DIALOG_HOUSE_GUNS_TAKE,
    
DIALOG_HOUSE_GUNS_PUT,
    
DIALOG_HOUSE_DRUGS_TAKE0,
    
DIALOG_HOUSE_DRUGS_TAKE1,
    
DIALOG_HOUSE_DRUGS_TAKE2,
    
DIALOG_HOUSE_DRUGS_PUT0,
    
DIALOG_HOUSE_DRUGS_PUT1,
    
DIALOG_HOUSE_DRUGS_PUT2,
}

public 
OnFilterScriptInit()
{
    
MySQL mysql_connect(mysql_hostmysql_usermysql_passwordmysql_database);
    if(
mysql_errno() == 0)
    {
        print(
"================================================================");
        print(
"       MySQL has successfully connected to the database         ");
        print(
"================================================================");
    }
    else
    {
        print(
"================================================================");
        print(
"         MySQL has FAILED!!! to connect to the database         ");
        print(
"================================================================");
        
SendRconCommand("exit");
    }
    
LoadHouses();
}

LoadHouses()
{
    
mysql_tquery(MySQL"SELECT * FROM `housedata`""OnLoadHouses");
}

PUBLIC:
OnLoadHouses()
{
    if(
cache_num_rows())
    {
        new 
hid;
        for(new 
0cache_num_rows(); i++)
        {
            
cache_get_value_name_int(i"SQLID"hid);
            
cache_get_value_name(i"Owner"hData[hid][hOwner]);
            
cache_get_value_name_float(i"hX"hData[hid][hX]);
            
cache_get_value_name_float(i"hY"hData[hid][hY]);
            
cache_get_value_name_float(i"hZ"hData[hid][hZ]);
            
cache_get_value_name_int(i"hInt"hData[hid][hInt]);
            
cache_get_value_name_int(i"hVW"hData[hid][hVW]);
            
cache_get_value_name_int(i"hAlarm"hData[hid][hAlarm]);
            
cache_get_value_name_int(i"hMoney"hData[hid][hMoney]);
            
cache_get_value_name_int(i"hInteriorPack"hData[hid][hInteriorPack]);
            
cache_get_value_name_int(i"hLocked"hData[hid][hLocked]);
            
cache_get_value_name_int(i"hSell"hData[hid][hSell]);
            
cache_get_value_name_int(i"hSafe"hData[hid][hSafe]);
            new 
iGet[256];

            
cache_get_value_name(i"hDrugs"iGet);
            new 
iP[35];
            
strcat(iP"p<,>");
            for(new 
drugID 0drugID sizeof(DrugData); drugID++) strcat(iP"i");
              
sscanf(iGetiPhData[hid][hDrugs][0], hData[hid][hDrugs][1], hData[hid][hDrugs][2]);

            
cache_get_value_name(i"hGuns"iGet);
            new 
iPP[35];
            
strcat(iPP"p<,>");
            for(new 
gunID 0gunID HOUSE_WEAPON_SLOTSgunID++) strcat(iPP"i");
            
sscanf(iGetiPPhData[hid][hGuns][0], hData[hid][hGuns][1]);

            
cache_get_value_name(i"hAmmo"iGet);
            new 
iPPP[35];
            
strcat(iPPP"p<,>");
            for(new 
ammoID 0ammoID HOUSE_WEAPON_SLOTSammoID++) strcat(iPPP"i");
            
sscanf(iGetiPPPhData[hid][hAmmo][0], hData[hid][hAmmo][1]);

            
hData[hid][hActive] = 1;
             
hData[hid][hPickupID] = CreateDynamicPickup(127323hData[hid][hX], hData[hid][hY], hData[hid][hZ], hData[hid][hVW], hData[hid][hInt], -1100.0);
            new 
string[512], zone[48];
            
GetZone(hData[hid][hX], hData[hid][hY], hData[hid][hZ], zone);
            if(
hData[hid][hSell] < 1format(string,sizeof(string),"Owner: %s\nAddress: %s, %d",NoUnderscore(hData[hid][hOwner]),zone,hid);
            else 
format(string,sizeof(string),"Owner: %s\nAddress: %s %d\nPrice: $%d (/buyhouse to  buy)",NoUnderscore(hData[hid][hOwner]),zone,hidhData[hid][hSell]);
            
hData[hid][hLabel] = CreateDynamic3DTextLabel(string, -1,  hData[hid][hX], hData[hid][hY], hData[hid][hZ], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -15);
        }

    }
}

InsertHouse(hid)
{
    new 
mQuery[800];
    
mysql_format(MySQLmQuery800"INSERT INTO `housedata` (`SQLID`, `Owner`, `hX`, `hY`, `hZ`, `hInt`, `hVW`, \
    `hAlarm`, `hMoney`, `hInteriorPack`, `hLocked`, `hSell`, `hSafe`, `hDrugs`, `hGuns`, `hAmmo`) VALUES ('%i', '%s', '%f', '%f', '%f', '%i', '%i', \
    '%i', '%i', '%i', '%i', '%i', '%i', '%e', '%e', '%e')"
hidhData[hid][hOwner], hData[hid][hX], hData[hid][hY], hData[hid][hZ], hData[hid][hInt], hData[hid][hVW], hData[hid][hAlarm], hData[hid][hMoney], hData[hid][hInteriorPack], hData[hid][hLocked], hData[hid][hSell],
    
hData[hid][hSafe], "0,0,0""0,0""0,0");
    
mysql_tquery(MySQLmQuery);
}

SaveHouse(hid)
{
    new 
iString50 ], tmp10 ];
    new 
iString250 ], tmp210 ];
    new 
iString350 ], tmp310 ];
    for(new 
0DRUGS_TYPESc++)
    {
        
format(tmp,sizeof(tmp),"%d,"hData[hid][hDrugs][c]);
        
strcat(iString,tmp);
    }
    
strdel(iStringstrlen(iString)-1strlen(iString));
    for(new 
0HOUSE_WEAPON_SLOTSc++)
    {
        
format(tmp2,sizeof(tmp2),"%d,"hData[hid][hGuns][c]);
        
strcat(iString2,tmp2);
    }
    
strdel(iString2strlen(iString2)-1strlen(iString2));
    for(new 
0HOUSE_WEAPON_SLOTSc++)
    {
        
format(tmp3,sizeof(tmp3),"%d,"hData[hid][hAmmo][c]);
        
strcat(iString3,tmp3);
    }
    
strdel(iString3strlen(iString3)-1strlen(iString3));
    new 
mQuery[800];
    
mysql_format(MySQLmQuery800"UPDATE `housedata` SET `Owner` = '%e', `hX` = '%f', `hY` = '%f', `hZ`= '%f', `hInt` = '%i', `hVW` = '%i', \
    `hAlarm` = '%i', `hMoney`= '%i', `hInteriorPack`= '%i', `hLocked`= '%i', `hSell`= '%i', hDrugs = '%e', `hGuns` = '%e', `hAmmo` = '%e', `hSafe` = '%i' WHERE `SQLID` = '%i'"
hData[hid][hOwner], hData[hid][hX], hData[hid][hY], hData[hid][hZ], hData[hid][hInt], hData[hid][hVW],
     
hData[hid][hAlarm], hData[hid][hMoney], hData[hid][hInteriorPack], hData[hid][hLocked], hData[hid][hSell], iStringiString2iString3hData[hid][hSafe], hid);
    
mysql_tquery(MySQLmQuery);
}

PUBLIC:
SaveHouses()
{
    for(new 
0MAX_HOUSESi++)
    {
        if(
hData[i][hActive] != 1) continue;
        
SaveHouse(i);
    }
}

DeleteHouse(hid)
{
    
DestroyDynamicPickup(hData[hid][hPickupID]);
    
DestroyDynamic3DTextLabel(hData[hid][hLabel]);
    
hData[hid][hActive] = 0;
    new 
mQuery[256];
    
mysql_format(MySQLmQuery256"DELETE FROM `housedata` WHERE SQLID = '%i'"hid);
    
mysql_tquery(MySQLmQuery);
}

ReloadHouse(hid)
{
    
SaveHouse(hid);
    
DestroyDynamicPickup(hData[hid][hPickupID]);
    
DestroyDynamic3DTextLabel(hData[hid][hLabel]);
    
hData[hid][hActive] = 0;
    new 
mQuery[256];
    
mysql_format(MySQLmQuery256"SELECT * FROM `housedata` WHERE `SQLID` = '%i' LIMIT 1"hid);
    
mysql_tquery(MySQLmQuery"OnReloadHouse""i"hid);
}

PUBLIC:
OnReloadHouse(hid)
{
    if(
cache_num_rows())
    {
        
cache_get_value_name(0"Owner"hData[hid][hOwner]);
        
cache_get_value_name_float(0"hX"hData[hid][hX]);
        
cache_get_value_name_float(0"hY"hData[hid][hY]);
        
cache_get_value_name_float(0"hZ"hData[hid][hZ]);
        
cache_get_value_name_int(0"hInt"hData[hid][hInt]);
        
cache_get_value_name_int(0"hVW"hData[hid][hVW]);
        
cache_get_value_name_int(0"hAlarm"hData[hid][hAlarm]);
        
cache_get_value_name_int(0"hMoney"hData[hid][hMoney]);
        
cache_get_value_name_int(0"hInteriorPack"hData[hid][hInteriorPack]);
        
cache_get_value_name_int(0"hLocked"hData[hid][hLocked]);
        
cache_get_value_name_int(0"hSell"hData[hid][hSell]);
        
cache_get_value_name_int(0"hSafe"hData[hid][hSafe]);
        new 
iGet[256];
        
cache_get_value_name(0"hDrugs"iGet);
        new 
iP[35];
        
strcat(iP"p<,>");
        for(new 
drugID 0drugID sizeof(DrugData); drugID++) strcat(iP"i");
        
sscanf(iGetiPhData[hid][hDrugs][0], hData[hid][hDrugs][1], hData[hid][hDrugs][2]);

        
cache_get_value_name(0"hGuns"iGet);
        new 
iPP[35];
        
strcat(iPP"p<,>");
        for(new 
gunID 0gunID HOUSE_WEAPON_SLOTSgunID++) strcat(iPP"i");
        
sscanf(iGetiPPhData[hid][hGuns][0], hData[hid][hGuns][1]);

        
cache_get_value_name(0"hAmmo"iGet);
        new 
iPPP[35];
        
strcat(iPPP"p<,>");
        for(new 
ammoID 0ammoID HOUSE_WEAPON_SLOTSammoID++) strcat(iPPP"i");
        
sscanf(iGetiPPPhData[hid][hAmmo][0], hData[hid][hAmmo][1]);

        
hData[hid][hActive] = 1;
         
hData[hid][hPickupID] = CreateDynamicPickup(127323hData[hid][hX], hData[hid][hY], hData[hid][hZ], hData[hid][hVW], hData[hid][hInt], -1100.0);
        new 
string[512], zone[48];
        
GetZone(hData[hid][hX], hData[hid][hY], hData[hid][hZ], zone);
        if(
hData[hid][hSell] < 1format(string,sizeof(string),"Owner: %s\nAddress: %s, %d",NoUnderscore(hData[hid][hOwner]),zone,hid);
        else 
format(string,sizeof(string),"Owner: %s\nAddress: %s %d\nPrice: $%d (/buyhouse to  buy)",NoUnderscore(hData[hid][hOwner]),zone,hidhData[hid][hSell]);
        
hData[hid][hLabel] = CreateDynamic3DTextLabel(string, -1,  hData[hid][hX], hData[hid][hY], hData[hid][hZ], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -15);
    }
}

public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys 16 && !IsPlayerInAnyVehicle(playerid))
    {
        
EnteringHouse(playerid);
        
ExitingHouse(playerid);
    }
    return 
1;
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ADMIN_HOUSE:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(
listitem == 0// owner
                
{
                    
ShowPlayerDialog(playeridDIALOG_ADMIN_HOUSE_OWNERDIALOG_STYLE_INPUT"House Owner""Please enter the Owner Name you want to set:""Enter""Quit");
                }
                if(
listitem == 1// interior
                
{
                    
ShowPlayerDialog(playeridDIALOG_ADMIN_HOUSE_INTDIALOG_STYLE_INPUT"House Interior""Please enter the Interior Pack (0-16) you want to set:""Enter""Quit");
                }
                if(
listitem == 2// alarm
                
{
                    if(
hData[hid][hAlarm] == 0)
                    {
                        
hData[hid][hAlarm] = 1;
                        
SendClientSuccess(playerid"Added alarm to the house successfully.");
                    }
                    else
                    {
                        
hData[hid][hAlarm] = 0;
                        
SendClientSuccess(playerid"Removed alarm from the house successfully.");
                    }
                }
                if(
listitem == 3// money
                
{
                    
ShowPlayerDialog(playeridDIALOG_ADMIN_HOUSE_MONEYDIALOG_STYLE_INPUT"House Money""Please enter the amount you want to set:""Enter""Quit");
                }
                if(
listitem == 4// locked
                
{
                    if(
hData[hid][hLocked] == 0)
                    {
                        
hData[hid][hLocked] = 1;
                        
SendClientSuccess(playerid"Locked the house successfully.");
                    }
                    else
                    {
                        
hData[hid][hLocked] = 0;
                        
SendClientSuccess(playerid"Unlocked the house successfully.");
                    }
                }
                if(
listitem == 5// sell
                
{
                    
ShowPlayerDialog(playeridDIALOG_ADMIN_HOUSE_SELLDIALOG_STYLE_INPUT"Sell House""Please enter the amount you want to sell for:""Enter""Quit");
                }
                if(
listitem == 6// save
                
{
                    
SaveHouse(hid);
                    
SendClientSuccess(playerid"Saved the house successfully.");
                }
                if(
listitem == 7// reload
                
{
                    
ReloadHouse(hid);
                    
SendClientSuccess(playerid"Reloaded the house successfull.");
                }
                if(
listitem == 8// delete
                
{
                    
DeleteHouse(hid);
                    
SendClientSuccess(playerid"Deleted the house successfully.");
                }
            }
        }

        case 
DIALOG_ADMIN_HOUSE_OWNER:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(!
strlen(inputtext)) return SendClientError(playerid"Please type the name of owner you want to set.");
                
format(hData[hid][hOwner], 24inputtext);
                
SendClientSuccess(playerid"Changed the owner successfully.");
            }
        }

        case 
DIALOG_ADMIN_HOUSE_INT:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(!
strlen(inputtext)) return SendClientError(playerid"Please type the interior pack you want to set.");
                if(!
IsNumeric(inputtext) || strval(inputtext) < || strval(inputtext) > 17) return SendClientError(playerid"Only 0-16 Packs allowed.");
                
hData[hid][hInteriorPack] = strval(inputtext);
                
SendClientSuccess(playerid"Changed the interior successfully.");
            }
        }

        case 
DIALOG_ADMIN_HOUSE_MONEY:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(!
strlen(inputtext)) return SendClientError(playerid"Please enter the amount you want to set.");
                if(!
IsNumeric(inputtext) || strval(inputtext) < 0) return SendClientError(playerid"Please type the AMOUNT you want to set.");
                
hData[hid][hMoney] = strval(inputtext);
                
SendClientSuccess(playerid"Changed the money successfully.");
            }
        }

        case 
DIALOG_ADMIN_HOUSE_SELL:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(!
strlen(inputtext)) return SendClientError(playerid"Please enter the amount you want to sell for.");
                if(!
IsNumeric(inputtext) || strval(inputtext) < 0) return SendClientError(playerid"Please type the AMOUNT you want to sell for.");
                
hData[hid][hSell] = strval(inputtext);
                
SendClientSuccess(playerid"Changed the SALE PRICE successfully.");
            }
        }

        case 
DIALOG_PLAYER_HOUSE_OUT:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(
listitem == 0// sell
                
{
                    
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSE_SELLDIALOG_STYLE_INPUT"Sell House""Please enter the amount you want to sell for:""Enter""Quit");
                }
                if(
listitem == 1// upgrade
                
{
                    new 
mstr[256], tmpr[256];
                    
format(mstr256"%i\tLevel %i\t$%i"0HouseInteriors[0][hintpack], HouseInteriors[0][hprice]);
                    for(new 
1sizeof(HouseInteriors); i++)
                    {
                        
format(tmpr256"%i\tLevel %i\t$%i"iHouseInteriors[i][hintpack], HouseInteriors[i][hprice]);
                        
strcat(mstrtmpr);
                    }
                    
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSE_INTDIALOG_STYLE_TABLIST"House Upgrade Interior"mstr"OK""Exit");
                }
                if(
listitem == 2// alarm
                
{
                    if(
hData[hid][hAlarm] != 0) return SendClientError(playerid"Your house already has installed alarm.");
                    else 
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSE_ALARMDIALOG_STYLE_MSGBOX"House Alarm""Are you  sure you want to buy house alarm?\n House alarm costs {33AA33}$50,000.""Yes""No");
                }
                if(
listitem == 3// lock
                
{
                    if(
hData[hid][hLocked] == 0)
                    {
                        
hData[hid][hLocked] = 1;
                        
GameTextForPlayer(playerid,"~r~Locked"30003);
                    }
                    else
                    {
                        
hData[hid][hLocked] = 0;
                        
GameTextForPlayer(playerid,"~g~Unlocked"30003);
                    }
                }
            }
        }

        case 
DIALOG_PLAYER_HOUSE_SELL:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(!
strlen(inputtext) || !IsNumeric(inputtext)) return SendClientError(playerid"Please type the amount you want to sell this house for.");
                if(
strval(inputtext) < 0) return SendClientError(playerid"Can not be less than zero.");
                
hData[hid][hSell] = strval(inputtext);
                
ReloadHouse(hid);
            }
        }

        case 
DIALOG_PLAYER_HOUSE_INT:
        {
            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(
GetPlayerMoneyEx(playerid) < HouseInteriors[strval(inputtext)][hprice]) return SendClientError(playerid"You do not have enough money.");
                
hData[hid][hInteriorPack] = strval(inputtext);
                
GivePlayerMoneyEx(playerid, -HouseInteriors[strval(inputtext)][hprice]);
                
SendClientSuccess(playerid"You have successfully upgraded the interior.");
                
ReloadHouse(hid);
            }
        }

        case 
DIALOG_PLAYER_HOUSE_ALARM:
        {

            if(
response)
            {
                new 
hid IsPlayerOutHouse(playerid);
                if(
hid == -1) return SendClientError(playerid"You are not outside the house anymore.");
                if(
GetPlayerMoneyEx(playerid) < 50000) return  SendClientError(playerid"You do not have enough money.");
                
GivePlayerMoneyEx(playerid, -50000);
                
hData[hid][hAlarm] = 1;
                
SendClientSuccess(playerid"You have successfully added alarm to the house.");
                
ReloadHouse(hid);
            }
        }

        case 
DIALOG_PLAYER_HOUSE_IN:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    if(
hData[hid][hSafe] == 0// unlocked
                    
{
                        new 
mstr[256];
                        
format(mstr256"Money: {33AA33}$%i\nDrugs\nWeapons"hData[hid][hMoney]);
                        
ShowPlayerDialog(playeridDIALOG_HOUSE_IN_SAFEDIALOG_STYLE_LIST"House Safe"mstr"OK"" Exit");
                    }
                    else if(
hData[hid][hSafe] == 1// locked
                    
{
                        if(
strcmp(hData[hid][hOwner], GetName(playerid), false)) return SendClientError(playerid"The safe is locked, you dont have keys aswell.");
                        else return 
SendClientError(playerid"Please unlock the safe first.");
                    }
                }
                if(
listitem == 1)
                {
                    if(
strcmp(hData[hid][hOwner], GetName(playerid), false)) return SendClientError(playerid"You dont have keys to unlock the safe.");
                    if(
hData[hid][hSafe] == 0)
                    {
                        
hData[hid][hSafe] = 1;
                        return 
GameTextForPlayer(playerid,"~r~Locked"30003);
                    }
                    if(
hData[hid][hSafe] == 1)
                    {
                        
hData[hid][hSafe] = 0;
                        return 
GameTextForPlayer(playerid,"~g~Unlocked"30003);
                    }
                }
            }
        }

        case 
DIALOG_HOUSE_IN_SAFE:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_IN_MONEYDIALOG_STYLE_LIST"House Safe""Take Money\nPut Money""OK"" Exit");
                }
                if(
listitem == 1)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_IN_DRUGSDIALOG_STYLE_LIST"House Safe""Take Drugs\nPut Drugs""OK"" Exit");
                }
                if(
listitem == 2)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_IN_GUNSDIALOG_STYLE_LIST"House Safe""Take Guns\nPut Guns""OK"" Exit");
                }
            }
        }

        case 
DIALOG_HOUSE_IN_MONEY:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0// take
                
{
                    if(
hData[hid][hMoney] < 1) return SendClientError(playerid"There is no money in the safe to take from.");
                    else 
ShowPlayerDialog(playeridDIALOG_HOUSE_MONEY_TAKEDIALOG_STYLE_INPUT"Take Money""Please enter the amount you want to take:""Enter""Quit");
                }
                if(
listitem == 1// put
                
{
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_MONEY_PUTDIALOG_STYLE_INPUT"Put Money""Please enter the amount you want to put:""Enter""Quit");
                }
            }
        }

        case 
DIALOG_HOUSE_IN_DRUGS:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0// take
                
{
                    new 
mstr[256];
                    
format(mstr256"%s: %i\n%s: %i\n%s: %i"DrugData[0][drugname], hData[hid][hDrugs][0], DrugData[1][drugname], hData[hid][hDrugs][1], DrugData[2][drugname], hData[hid][hDrugs][2]);
                    if(
hData[hid][hDrugs][0] == && hData[hid][hDrugs][1] == && hData[hid][hDrugs][2] == 0) return SendClientError(playerid"There is no any drugs stored");
                     else 
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_TAKEDIALOG_STYLE_LIST"Take Drugs"mstr"OK""Exit");
                }
                if(
listitem == 1// put
                
{
                    new 
mstr[256];
                    
format(mstr256"%s: %i\n%s: %i\n%s: %i"DrugData[0][drugname], hData[hid][hDrugs][0], DrugData[1][drugname], hData[hid][hDrugs][1], DrugData[2][drugname], hData[hid][hDrugs][2]);
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_PUTDIALOG_STYLE_LIST"Put Drugs"mstr"OK""Exit");
                }
            }
        }

        case 
DIALOG_HOUSE_IN_GUNS:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0// take
                
{
                    new 
mstr[256];
                    if(
hData[hid][hGuns][0] == && hData[hid][hGuns][1] == 0) return SendClientError(playerid"No any weapon is stored in the safe.");
                    
format(mstr256"Weapon Slot 1 (%s - %i)\nWeapon Slot 2 (%s - %i)"GetWeaponNameByID(hData[hid][hGuns][0]), hData[hid][hAmmo][0], GetWeaponNameByID(hData[hid][hGuns][1]), hData[hid][hAmmo][1]);
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_GUNS_TAKEDIALOG_STYLE_LIST"Take Gun"mstr"OK""Exit");
                }
                if(
listitem == 1// put
                
{
                    new 
mstr[256];
                    
format(mstr256"Weapon Slot 1 (%s - %i)\nWeapon Slot 2 (%s - %i)"GetWeaponNameByID(hData[hid][hGuns][0]), hData[hid][hAmmo][0], GetWeaponNameByID(hData[hid][hGuns][1]), hData[hid][hAmmo][1]);
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_GUNS_PUTDIALOG_STYLE_LIST"Put Gun"mstr"OK""Exit");
                }
            }
        }

        case 
DIALOG_HOUSE_GUNS_TAKE:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    if(
hData[hid][hGuns][0] == 0) return SendClientError(playerid"There is no any gun stored in this slot.");
                    
GivePlayerWeapon(playeridhData[hid][hGuns][0], hData[hid][hAmmo][0]);
                    
hData[hid][hGuns][0] = 0;
                    
hData[hid][hAmmo][0] = 0;
                    
GameTextForPlayer(playerid,"~g~Taken Gun"30003);
                }
                if(
listitem == 1)
                {
                    if(
hData[hid][hGuns][1] == 0) return SendClientError(playerid"There is no any gun stored in this slot.");
                    
GivePlayerWeapon(playeridhData[hid][hGuns][1], hData[hid][hAmmo][1]);
                    
hData[hid][hGuns][1] = 0;
                    
hData[hid][hAmmo][1] = 0;
                    
GameTextForPlayer(playerid,"~g~Taken Gun"30003);
                }
            }
        }

        case 
DIALOG_HOUSE_GUNS_PUT:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    if(
hData[hid][hGuns][0] != 0) return SendClientError(playerid"There is a gun stored in the slot already.");
                    if(
GetPlayerWeapon(playerid) == 0) return SendClientError(playerid"You are not holding any gun!");
                    
hData[hid][hGuns][0] = GetPlayerWeapon(playerid);
                    
hData[hid][hAmmo][0] = GetPlayerAmmo(playerid);
                    
RemovePlayerWeapon(playeridGetPlayerWeapon(playerid));
                    
GameTextForPlayer(playerid,"~g~Put Gun"30003);
                }
                if(
listitem == 1)
                {
                    if(
hData[hid][hGuns][1] != 0) return SendClientError(playerid"There is a gun stored in the slot already.");
                    if(
GetPlayerWeapon(playerid) == 0) return SendClientError(playerid"You are not holding any gun!");
                    
hData[hid][hGuns][1] = GetPlayerWeapon(playerid);
                    
hData[hid][hAmmo][1] = GetPlayerAmmo(playerid);
                    
RemovePlayerWeapon(playeridGetPlayerWeapon(playerid));
                    
GameTextForPlayer(playerid,"~g~Put Gun"30003);
                }
            }
        }

        case 
DIALOG_HOUSE_MONEY_TAKE:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to take.");
                if(
strval(inputtext) > hData[hid][hMoney]) return SendClientError(playerid"There is not this much amount in the safe.");
                
GivePlayerMoneyEx(playeridstrval(inputtext));
                
hData[hid][hMoney] -= strval(inputtext);
                
GameTextForPlayer(playerid,"~g~Taken Money"30003);
            }
        }

        case 
DIALOG_HOUSE_MONEY_PUT:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to put.");
                if(
strval(inputtext) > GetPlayerMoneyEx(playerid)) return SendClientError(playerid"You do not have this much money on you.");
                
GivePlayerMoneyEx(playerid, -strval(inputtext));
                
hData[hid][hMoney] += strval(inputtext);
                
GameTextForPlayer(playerid,"~g~Put Money"30003);
            }
        }

        case 
DIALOG_HOUSE_DRUGS_TAKE:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    if(
hData[hid][hDrugs][0] < 1) return SendClientError(playerid"There is no drug stored.");
                    else 
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_TAKE0DIALOG_STYLE_INPUT"Take Cannabis""Please enter the amount you want to take:""OK""Exit");
                }
                if(
listitem == 1)
                {
                    if(
hData[hid][hDrugs][1] < 1) return SendClientError(playerid"There is no drug stored.");
                    else 
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_TAKE1DIALOG_STYLE_INPUT"Take Cocaine""Please enter the amount you want to take:""OK""Exit");
                }
                if(
listitem == 2)
                {
                    if(
hData[hid][hDrugs][2] < 1) return SendClientError(playerid"There is no drug stored.");
                    else 
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_TAKE2DIALOG_STYLE_INPUT"Take Heroin""Please enter the amount you want to take:""OK""Exit");
                }
            }
        }

        case 
DIALOG_HOUSE_DRUGS_TAKE0:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to take.");
                if(
strval(inputtext) > hData[hid][hDrugs][0]) return SendClientError(playerid"You do not have this much drugs in the safe.");
                
pData[playerid][pDrugs][0] += strval(inputtext);
                
hData[hid][hDrugs][0] -= strval(inputtext);
                
GameTextForPlayer(playerid"~g~Taken Cannabis"30003);
            }
        }
        case 
DIALOG_HOUSE_DRUGS_TAKE1:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to take.");
                if(
strval(inputtext) > hData[hid][hDrugs][1]) return SendClientError(playerid"You do not have this much drugs in the safe.");
                
pData[playerid][pDrugs][1] += strval(inputtext);
                
hData[hid][hDrugs][1] -= strval(inputtext);
                
GameTextForPlayer(playerid"~g~Taken Cocaine"30003);
            }
        }
        case 
DIALOG_HOUSE_DRUGS_TAKE2:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to take.");
                if(
strval(inputtext) > hData[hid][hDrugs][2]) return SendClientError(playerid"You do not have this much drugs in the safe.");
                
pData[playerid][pDrugs][2] += strval(inputtext);
                
hData[hid][hDrugs][2] -= strval(inputtext);
                
GameTextForPlayer(playerid"~g~Taken Heroin"30003);
            }
        }

        case 
DIALOG_HOUSE_DRUGS_PUT:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(
listitem == 0)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_PUT0DIALOG_STYLE_INPUT"Put Cannabis""Please enter the amount you want to put:""OK""Exit");
                }
                if(
listitem == 1)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_PUT1DIALOG_STYLE_INPUT"Put Cocaine""Please enter the amount you want to put:""OK""Exit");
                }
                if(
listitem == 2)
                {
                    
ShowPlayerDialog(playeridDIALOG_HOUSE_DRUGS_PUT2DIALOG_STYLE_INPUT"Put Heroin""Please enter the amount you want to put:""OK""Exit");
                }
            }
        }

        case 
DIALOG_HOUSE_DRUGS_PUT0:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to put.");
                if(
strval(inputtext) > pData[playerid][pDrugs][0]) return SendClientError(playerid"You do not have this much drugs on you.");
                
pData[playerid][pDrugs][0] -= strval(inputtext);
                
hData[hid][hDrugs][0] += strval(inputtext);
                
GameTextForPlayer(playerid"~g~Put Cannabis"30003);
            }
        }

        case 
DIALOG_HOUSE_DRUGS_PUT1:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to put.");
                if(
strval(inputtext) > pData[playerid][pDrugs][1]) return SendClientError(playerid"You do not have this much drugs on you.");
                
pData[playerid][pDrugs][1] -= strval(inputtext);
                
hData[hid][hDrugs][1] += strval(inputtext);
                
GameTextForPlayer(playerid"~g~Put Cocaine"30003);
            }
        }

        case 
DIALOG_HOUSE_DRUGS_PUT2:
        {
            new 
hid IsPlayerInHouse(playerid);
            if(
hid == -1) return SendClientError(playerid"You are not inside the house anymore.");
            if(
response)
            {
                if(!
strlen(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 1) return SendClientError(playerid"Please enter the amount you want to put.");
                if(
strval(inputtext) > pData[playerid][pDrugs][2]) return SendClientError(playerid"You do not have this much drugs on you.");
                
pData[playerid][pDrugs][2] -= strval(inputtext);
                
hData[hid][hDrugs][2] += strval(inputtext);
                
GameTextForPlayer(playerid"~g~Put Heroin"30003);
            }
        }
    }
    return 
1;
}



CMD:ahouse(playeridparams[])
{
    new 
wat[10];
    if(
pData[playerid][Admin] < 5) return SendClientError(playeridCANT_USE_CMD);
    new 
hid IsPlayerOutHouse(playerid);
    new 
hd IsPlayerInHouse(playerid);
    if(
hid != -&& hd == -1// if outside
    
{
        new 
mstr[256], onestr[256], alrm[10], locked[10];
        
format(onestr256"%s's House (ID: %i)"hData[hid][hOwner], hid);
        if(
hData[hid][hAlarm] == 0format(alrm10"No"); else format(alrm10"Yes");
        if(
hData[hid][hLocked] == 0format(locked10"No"); else format(locked10"Yes");
        
format(mstr256"Owner:\t\t\t%s\nInterior:\t\t%i\nAlarm:\t\t\t%s\nMoney:\t\t\t$%i\nLocked:\t\t%s\nSell:\t\t\t%i\nSave\nReload\nDelete",
        
hData[hid][hOwner], hData[hid][hInteriorPack], alrmhData[hid][hMoney], lockedhData[hid][hSell]);
        
ShowPlayerDialog(playeridDIALOG_ADMIN_HOUSEDIALOG_STYLE_LISTonestrmstr"OK""Exit");
    }
    else if(
hid == -&& hd == -1)
    {
        if(
sscanf(params"s[10]"wat)) return SendClientUsage(playerid"/ahouse [create]");
        if(!
strcmp(wat"create"true6))
        {
            
hid GetUnusedHouseID();
            
format(hData[hid][hOwner], 24"None");
            new 
Float:tmpxFloat:tmpyFloat:tmpzinttvww;
            
GetPlayerPos(playeridtmpxtmpytmpz);
            
intt GetPlayerInterior(playerid);
            
vww GetPlayerVirtualWorld(playerid);
            
hData[hid][hX] = tmpx;
            
hData[hid][hY] = tmpy;
            
hData[hid][hZ] = tmpz;
            
hData[hid][hInt] = intt;
            
hData[hid][hVW] = vww;
            
hData[hid][hAlarm] = 0;
            
hData[hid][hMoney] = 0;
            
hData[hid][hInteriorPack] = 0;
            
hData[hid][hLocked] = 0;
            
hData[hid][hSell] = 0;
            
hData[hid][hActive] = 1;
            
InsertHouse(hid);
            
hData[hid][hActive] = 1;
             
hData[hid][hPickupID] = CreateDynamicPickup(127323hData[hid][hX], hData[hid][hY], hData[hid][hZ], hData[hid][hVW], hData[hid][hInt], -1100.0);
            new 
string[512], zone[48];
            
GetZone(hData[hid][hX], hData[hid][hY], hData[hid][hZ], zone);
            if(
hData[hid][hSell] < 1format(string,sizeof(string),"Owner: %s\nAddress: %s, %d",NoUnderscore(hData[hid][hOwner]),zone,hid);
            else 
format(string,sizeof(string),"Owner: %s\nAddress: %s %d\nPrice: $%d (/buyhouse to  buy)",NoUnderscore(hData[hid][hOwner]),zone,hidhData[hid][hSell]);
            
hData[hid][hLabel] = CreateDynamic3DTextLabel(string, -1,  hData[hid][hX], hData[hid][hY], hData[hid][hZ], 20INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -15);
        }
    }
    else if(
hid == -&& hd != -1)
    {
        
SendClientError(playerid"You cant use this cmd inside a house.");
    }
    return 
1;
}

CMD:house(playeridparams[])
{
    new 
hid IsPlayerOutHouse(playerid);
    new 
hd IsPlayerInHouse(playerid);
    if(
hid == -&& hd == -1// away
    
{
        if(
GetPlayerHouses(playerid) == 0) return SendClientError(playerid"You do not own any house");
        new 
onestr[256], mstr[256], tmpstr[256], zone[20], cnt 0;
        
format(onestr256"%s's Houses"RPName(playerid));
        for(new 
0MAX_HOUSESi++)
        {
            if(
hData[i][hActive] != 1) continue;
            if(!
strcmp(hData[i][hOwner], GetName(playerid), false))
            {
                if(
cnt == 0)
                {
                    
cnt++;
                    
GetZone(hData[i][hX], hData[i][hY], hData[i][hZ], zone);
                    
format(tmpstr256"House ID: %i at %s"izone);
                }
                else
                {
                    
GetZone(hData[i][hX], hData[i][hY], hData[i][hZ], zone);
                    
format(tmpstr256"\nHouse ID: %i at %s"izone);
                }
                
strcat(mstrtmpstr);
            }
        }
        
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSEDIALOG_STYLE_LISTonestrmstr"OK""Exit");
    }
    if(
hid != -&& hd == -1// outside
    
{
        if(
strcmp(hData[hid][hOwner], GetName(playerid), false)) return SendClientError(playerid"You do not own this house.");
        new 
onestr[256], mstr[256], lock[10], alrm[10];
        
format(onestr256"%s's House (ID: %i)"hData[hid][hOwner], hid);
        if(
hData[hid][hLocked] == 1format(lock10"Yes"); else format(lock10"No");
        if(
hData[hid][hAlarm] == 1format(alrm10"Yes"); else format(alrm10"No");
        
format(mstr256"Sell\nUpgrade\nAlarm:\t\t\t%s\nLocked:\t\t%s"alrmlock);
        
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSE_OUTDIALOG_STYLE_LISTonestrmstr"OK""Exit");
    }
    if(
hid == -&& hd != -1// inside
    
{
        new 
onestr[256], mstr[256], lock[10];
        
format(onestr256"%s's House Safe"hData[hd][hOwner]);
        if(
hData[hd][hSafe] == 0format(lock10"Unlocked"); else format(lock10"Locked");
        
format(mstr256"Open Safe\nSafe Status: %s"lock);
        
ShowPlayerDialog(playeridDIALOG_PLAYER_HOUSE_INDIALOG_STYLE_LISTonestrmstr"OK""Exit");
    }
    return 
1;
}

CMD:buyhouse(playeridparams[])
{
    new 
hid IsPlayerOutHouse(playerid);
    if(
hid != -1)
    {
        if(
hData[hid][hSell] == 0) return SendClientError(playerid"House is not on sale.");
        if(
GetPlayerMoneyEx(playerid) < hData[hid][hSell]) return SendClientError(playerid"You do not have enough money.");
        new 
pid GetPlayerID(hData[hid][hOwner]);
        if(
IsPlayerConnected(pid))
        {
            
GivePlayerMoneyEx(playerid, -hData[hid][hSell]);
            
GivePlayerMoneyEx(pidhData[hid][hSell]);
            
SendClientMessage(playerid, -1"House bought");
            
SendClientMessage(pid, -1"someone bought ur house");
        }
        else
        {
            
GiveOfflineMoneyEx(hData[hid][vOwner], hData[hid][hSell]);
            
GivePlayerMoneyEx(playerid, -hData[hid][hSell]);
            
SendClientMessage(playerid, -1"DOne bought");
        }
        
hData[hid][hSell] = 0;
        
format(hData[hid][hOwner], 24GetName(playerid));
        
ReloadHouse(hid);
    }
    else 
SendClientError(playerid"You are not outside any house.");
    return 
1;
}

stock GetPlayerID(const pName[])
{
    new 
playerid INVALID_PLAYER_ID;
    
sscanf(pName,"u",playerid);
    return 
playerid;
}

GiveOfflineMoneyEx(pname[], money)
{
    new 
mQuery[256];
    
mysql_format(MySQLmQuery256"UPDATE `playerdata` SET `Money` = `playerdata`.`Money`+ '%i' WHERE `Username` = '%s'"moneypname);
    
mysql_tquery(MySQLmQuery);
}

EnteringHouse(playerid)
{
    new 
tmps;
    
tmps IsPlayerOutHouse(playerid);
    if(
tmps != -&& !IsPlayerInAnyVehicle(playerid))
    {
        if(
hData[tmps][hLocked] == 1) return GameTextForPlayer(playerid,"~r~Locked"30003);
        new 
intp GetHouseInteriorID(tmps);
        
SetPlayerInterior(playeridHouseInteriors[intp][hinterior]);
        
SetPlayerVirtualWorld(playeridtmps+1);
        
SetPlayerPos(playeridHouseInteriors[intp][hintx], HouseInteriors[intp][hinty], HouseInteriors[intp][hintz]);
        
SetCameraBehindPlayer(playerid);
        
LetItLoadLOL(playerid);
    }
    return 
1;
}

ExitingHouse(playerid)
{
    new 
tmps;
    
tmps IsPlayerInHouse(playerid5.0);
    if(
tmps != -&& !IsPlayerInAnyVehicle(playerid))
    {
        
SetPlayerInterior(playeridhData[tmps][hInt]);
        
SetPlayerVirtualWorld(playeridhData[tmps][hVW]);
        
SetPlayerPos(playeridhData[tmps][hX], hData[tmps][hY], hData[tmps][hZ]);
        
SetCameraBehindPlayer(playerid);
        
LetItLoadLOL(playerid);
    }
    return 
1;
}

LetItLoadLOL(playerid)
{
    
TogglePlayerControllable(playeridfalse);
    
GameTextForPlayer(playerid,"~r~Loading Map"50003);
    
SetTimerEx("LoadedLOL"5000false"i"playerid);
}

PUBLIC:
LoadedLOL(playerid)
{
    
TogglePlayerControllable(playeridtrue);
}

GetPlayerHouses(playerid)
{
    new 
isyes 0;
    for(new 
0MAX_HOUSESi++)
    {
        if(
hData[i][hActive] != 1) continue;
        if(!
strcmp(hData[i][hOwner], GetName(playerid), false))  isyes++;
    }
    return 
isyes;
}

GetUnusedHouseID()
{
    new 
isyes = -1;
    for(new 
0MAX_HOUSESi++)
    {
        if(
hData[i][hActive] == 0)
        {
            
isyes i;
            break;
        }
    }
    return 
isyes;
}

IsPlayerOutHouse(playerid)
{
    new 
isyes = -1;
    for(new 
0MAX_HOUSESi++)
    {
        if(
hData[i][hActive] != 1) continue;
        if(
IsPlayerInRangeOfPoint(playerid5.0hData[i][hX], hData[i][hY], hData[i][hZ]))
        {
            if(
GetPlayerInterior(playerid) == hData[i][hInt] && GetPlayerVirtualWorld(playerid) == hData[i][hVW])
            {
                
isyes i;
                break;
            }
        }
    }
    return 
isyes;
}

IsPlayerInHouse(playeridFloat:range 30.0)
{
    new 
isyes = -1;
    for(new 
0MAX_HOUSESi++)
    {
        if(
hData[i][hActive] != 1) continue;
        new 
intp GetHouseInteriorID(i);
        if(
intp != -1)
        {
            if(
GetPlayerInterior(playerid) == HouseInteriors[intp][hinterior] && GetPlayerVirtualWorld(playerid) == i+1)
            {
                if(
IsPlayerInRangeOfPoint(playeridrangeHouseInteriors[intp][hintx], HouseInteriors[intp][hinty], HouseInteriors[intp][hintz]))
                {
                    
isyes i;
                    break;
                }
            }
        }
    }
    return 
isyes;
}

GetHouseInteriorID(hid)
{
    new 
isyes = -1;
    for(new 
0sizeof(HouseInteriors); i++)
    {
        if(
hData[hid][hInteriorPack] == HouseInteriors[i][hintpack])
        {
            
isyes i;
            break;
        }
    }
    return 
isyes;
}

stock GetWeaponNameByID(wid// By JONNy5
{
    new 
gunname[32];
    switch (
wid)
    {
        case    
.. 17,
                
22 .. 43,
                
46 :        GetWeaponName(wid,gunname,sizeof(gunname));
        case    
0:          format(gunname,32,"%s","None");
        case    
18:         format(gunname,32,"%s","Molotov Cocktail");
        case    
44:         format(gunname,32,"%s","Night Vis Goggles");
        case    
45:         format(gunname,32,"%s","Thermal Goggles");
        default:            
format(gunname,32,"%s","Invalid Weapon Id");

    }
    return 
gunname;
}

stock NoUnderscore(string[]) // by w00t
{
    new 
str[512];
    
strmid(str,string,0,strlen(string), 512);
    for(new 
0512i++)
    {
        if (
str[i] == '_'str[i] = ' ';
    }
    return 
str;
}

stock IsNumeric(const str[])
{
    for(new 
ilen strlen(str); leni++)
    {
        if(!(
'0' <= str[i] <= '9')) return false;
    }
    return 
true;
}

stock SendClientError(playerid, const msg[])
{
    new 
dstr[512];
    
format(dstrsizeof(dstr), "[Error] %s"msg);
    return 
SendClientMessage(playeridCOLOR_REDdstr);
}

stock SendClientSuccess(playerid, const msg[])
{
    new 
dstr[512];
    
format(dstrsizeof(dstr), "[Success] %s"msg);
    return 
SendClientMessage(playeridCOLOR_SUCCESSdstr);
}

stock SendClientUsage(playerid, const msg[])
{
    new 
dstr[512];
    
format(dstrsizeof(dstr), "[Usage] %s"msg);
    return 
SendClientMessage(playeridCOLOR_GREYdstr);
}

stock GetPlayerMoneyEx(playerid)
{
    return 
pData[playerid][Money];
}

stock GivePlayerMoneyEx(playeridamount)
{
    
GivePlayerMoney(playeridamount);
    
pData[playerid][Money] += amount;
}

stock RemovePlayerWeapon(playeridweaponid)
{
    
SetPlayerArmedWeapon(playeridweaponid);
    if (
GetPlayerWeapon(playerid) != 0GivePlayerWeapon(playeridGetPlayerWeapon(playerid), -(GetPlayerAmmo(playerid)));

    return 
1;
}

stock GetName(playerid)
{
    new
        
name[24];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;

__________________
Quote:
Eternal Life Roleplay - An upcoming unique RP server based in Palomino Creek
https://discord.gg/JWzE78r
Quote:
Originally Posted by !damo!spiderman View Post
You're pathetic. Stand for something that's going to help the world rather than fill it with more hate. Give someone a hug, tell someone you care... Do something, do anything but do it with love not hate.

Last edited by StevenLV; 22/05/2020 at 05:40 AM.
StevenLV is offline   Reply With Quote
Old 18/05/2020, 08:47 PM   #2
Shadow_
Gangsta
 
Shadow_'s Avatar
 
Join Date: Nov 2008
Location: Vatican City
Posts: 539
Reputation: 56
Default Re: Steven's Dynamic House System [MySQL]

Looks really good, I'll test it out tonight and let you know anything i find. ++rep
__________________
Shadow_ is offline   Reply With Quote
Old 18/05/2020, 09:37 PM   #3
Hunud
Huge Clucker
 
Hunud's Avatar
 
Join Date: Jun 2016
Location: Right here.
Posts: 484
Reputation: 57
Default Re: Steven's Dynamic House System [MySQL]

Do vehicle ownership, maybe 2 per player.
__________________
Hunud is offline   Reply With Quote
Old 18/05/2020, 11:12 PM   #4
IgorLuiz
Gangsta
 
IgorLuiz's Avatar
 
Join Date: Mar 2015
Location: São Paulo
Posts: 519
Reputation: 33
Default Re: Steven's Dynamic House System [MySQL]

Bom!
IgorLuiz is offline   Reply With Quote
Old 19/05/2020, 04:12 AM   #5
StevenLV
Big Clucker
 
StevenLV's Avatar
 
Join Date: Apr 2017
Location: Pakistan
Posts: 144
Reputation: 11
Default Re: Steven's Dynamic House System [MySQL]

@Shadow, Thanks bro. Check it out and tell me any suggestion, any bug anything .. Thanks.
@Hunud, Uhm Its an standalone House system and it is as a filterscript for users who want to use just house. I see there are alot of House Systems with Garage or CAR, so basically i did this without car / vehicle system so that it can be used as well. Thanks for suggestion tho.
@IgorLuiz, what is bom xd
__________________
Quote:
Eternal Life Roleplay - An upcoming unique RP server based in Palomino Creek
https://discord.gg/JWzE78r
Quote:
Originally Posted by !damo!spiderman View Post
You're pathetic. Stand for something that's going to help the world rather than fill it with more hate. Give someone a hug, tell someone you care... Do something, do anything but do it with love not hate.
StevenLV is offline   Reply With Quote
Old 19/05/2020, 11:18 PM   #6
homelessdrop
Big Clucker
 
homelessdrop's Avatar
 
Join Date: Jan 2016
Posts: 81
Reputation: 17
Default Re: Steven's Dynamic House System [MySQL]

Looks nice one, but can you please post a_zones include? Thanks.
__________________

Veteran designer, mapper and model maker.
Since of 2011

Discord: homelessdrop#2166
homelessdrop is offline   Reply With Quote
Old 20/05/2020, 11:20 AM   #7
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 459
Reputation: 20
Default Re: Steven's Dynamic House System [MySQL]

Quote:
Originally Posted by homelessdrop View Post
Looks nice one, but can you please post a_zones include? Thanks.
https://forum.sa-mp.com/showthread.php?t=27598
__________________
Developer @ Trucknation
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
An upcoming mix of trucking & light roleplay
Proxus is online now   Reply With Quote
Old 20/05/2020, 04:47 PM   #8
homelessdrop
Big Clucker
 
homelessdrop's Avatar
 
Join Date: Jan 2016
Posts: 81
Reputation: 17
Default Re: Steven's Dynamic House System [MySQL]

Quote:
Originally Posted by Proxus View Post
that's doesn't work for me, but here's this, that's work fine mediafire (if anybody need it).

I have a one question, how 'sell' work on this?
__________________

Veteran designer, mapper and model maker.
Since of 2011

Discord: homelessdrop#2166
homelessdrop is offline   Reply With Quote
Old 21/05/2020, 07:46 AM   #9
StevenLV
Big Clucker
 
StevenLV's Avatar
 
Join Date: Apr 2017
Location: Pakistan
Posts: 144
Reputation: 11
Default Re: Steven's Dynamic House System [MySQL]

Oh shit, sorry bro I actually forgot to add a buy house command. It is simple to do it but i just forgot wil ladd.
__________________
Quote:
Eternal Life Roleplay - An upcoming unique RP server based in Palomino Creek
https://discord.gg/JWzE78r
Quote:
Originally Posted by !damo!spiderman View Post
You're pathetic. Stand for something that's going to help the world rather than fill it with more hate. Give someone a hug, tell someone you care... Do something, do anything but do it with love not hate.
StevenLV is offline   Reply With Quote
Old 22/05/2020, 05:42 AM   #10
StevenLV
Big Clucker
 
StevenLV's Avatar
 
Join Date: Apr 2017
Location: Pakistan
Posts: 144
Reputation: 11
Default Re: Steven's Dynamic House System [MySQL]

Added /buyhouse command.
__________________
Quote:
Eternal Life Roleplay - An upcoming unique RP server based in Palomino Creek
https://discord.gg/JWzE78r
Quote:
Originally Posted by !damo!spiderman View Post
You're pathetic. Stand for something that's going to help the world rather than fill it with more hate. Give someone a hug, tell someone you care... Do something, do anything but do it with love not hate.
StevenLV is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] h-House [Dynamic House System] - 0.3z HY Filterscripts 18 06/05/2015 01:29 PM
[FilterScript] Dynamic House System v0.5 (w/Dialog Builder System+Customizable) ABKPot Filterscripts 19 27/01/2015 05:56 PM
Dynamic House System AfikAtashga Scripting Help 4 03/08/2013 12:34 AM
[HELP] Dynamic house system Pooh7 Help Archive 5 01/01/2011 06:32 PM


All times are GMT. The time now is 11:08 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.