Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- | Walker's Dynamic Housing System - ENG - 0.3Z |
- | Copyright |
- */
- #include <a_samp>
- #include <sscanf2>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <streamer>
- // ===============[COLORS]===================
- #define COLOR_GREEN 0x008000FF
- #define COLOR_YELLOW 0xECD400F6
- #define COLOR_WHITE 0xFFFFFFFF
- //===============[DEFINES]===================
- #define MAX_HOUSES 300
- #define SCM SendClientMessage // Just for easy,not too important.
- #define HOUSE_PATH "/Houses/House %d.ini"
- #define USER_PATH "/Users/%s.ini"
- #define DIALOG_HOUSE 1
- #define SELLPERCENT 50 // This is the Total Percent of Money that you will get back on selling the House.
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- // ==============[TEXTDRAWS]==================
- new PlayerText:Statement[MAX_PLAYERS];
- new PlayerText:Box[MAX_PLAYERS];
- new PlayerText:boxtext[MAX_PLAYERS];
- // Player Info (We're using only 1 Variable right now)
- enum pInfo
- {
- HouseKey,
- HouseID
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- // House Info (There are 19 Variables here)
- enum hInfo
- {
- Owner[32],
- Owned,
- Price,
- Float: EnterX,
- Float: EnterY,
- Float: EnterZ,
- Float: EnterA,
- Float: ExitX,
- Float: ExitY,
- Float: ExitZ,
- Float: ExitA,
- EnterInt,
- EnterVW,
- ExitInt,
- ExitVW,
- Money,
- Text3D: Label,
- PickupID,
- Locked
- }
- new HouseInfo[MAX_HOUSES][hInfo];
- new HouseTaken[MAX_HOUSES];
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n-----------------------------------------");
- print("-Dynamic Housing System - ENG - JonathanW-");
- print("------------------------------------------\n");
- // Loading Houses
- for(new i = 1; i < MAX_HOUSES; i++)
- {
- new gFile[35];
- format(gFile, 35, HOUSE_PATH ,i);
- if(fexist(gFile))
- {
- INI_ParseFile(gFile, "LoadHouse", .bExtra = true, .extra = i);
- ReadHouse(i);
- }
- }
- return 1;
- }
- //=============================[HOUSE FUNCTIONS]=============================
- // This is for Setting a House's Information
- stock ReadHouse(houseid)
- {
- new string[512];
- if(HouseInfo[houseid][Owned]) format(string, sizeof(string), "[House] {2F70D0}%d\n{FFFFFF}Owner: {2F70D0}%s\n{FFFFFF}Status: {2F70D0}%s", houseid,HouseInfo[houseid][Owner],HL(houseid));
- else format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Status: {2F70D0}For sale\n{FFFFFF}Price: {2F70D0}%d", houseid,HouseInfo[houseid][Price]);
- HouseInfo[houseid][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 15);
- HouseInfo[houseid][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 0, 0, -1, 40.0);
- }
- stock GetAvailableID()
- {
- for(new i = 1; i<MAX_HOUSES; i++)
- {
- if(HouseTaken[i] == 0) return i;
- }
- return -1;
- }
- stock Showlock(playerid)
- {
- PlayerTextDrawSetString(playerid, boxtext[playerid], "Locked");
- PlayerTextDrawShow(playerid, Box[playerid]);
- PlayerTextDrawShow(playerid, boxtext[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- return 1;
- }
- stock HL(houseid)
- {
- new string[16];
- if(HouseInfo[houseid][Locked] == 1) format(string, sizeof(string), "Locked");
- else if(HouseInfo[houseid][Locked] == 0) format(string, sizeof(string), "Unlocked");
- return string;
- }
- stock GetName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- for(new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if(name[i] == '_') name[i] = ' ';
- }
- return name;
- }
- stock CreateTextdraws(playerid)
- {
- Statement[playerid] = CreatePlayerTextDraw(playerid, 172.000000, 398.125000, "You have successfully ~g~purchased~w~ a house");
- PlayerTextDrawLetterSize(playerid, Statement[playerid], 0.377500, 1.337500);
- PlayerTextDrawAlignment(playerid, Statement[playerid], 1);
- PlayerTextDrawColor(playerid, Statement[playerid], -1);
- PlayerTextDrawSetShadow(playerid, Statement[playerid], 0);
- PlayerTextDrawSetOutline(playerid, Statement[playerid], 1);
- PlayerTextDrawBackgroundColor(playerid, Statement[playerid], 51);
- PlayerTextDrawFont(playerid, Statement[playerid], 1);
- PlayerTextDrawSetProportional(playerid, Statement[playerid], 1);
- Box[playerid] = CreatePlayerTextDraw(playerid, 100.500000, 210.187500, "usebox");
- PlayerTextDrawLetterSize(playerid, Box[playerid], 0.000000, 2.034723);
- PlayerTextDrawTextSize(playerid, Box[playerid], 19.000000, 0.000000);
- PlayerTextDrawAlignment(playerid, Box[playerid], 1);
- PlayerTextDrawColor(playerid, Box[playerid], 0);
- PlayerTextDrawUseBox(playerid, Box[playerid], true);
- PlayerTextDrawBoxColor(playerid, Box[playerid], -226);
- PlayerTextDrawSetShadow(playerid, Box[playerid], 0);
- PlayerTextDrawSetOutline(playerid, Box[playerid], 0);
- PlayerTextDrawFont(playerid, Box[playerid], 0);
- boxtext[playerid] = CreatePlayerTextDraw(playerid, 35.500000, 212.625000, "~g~UNLOCKED");
- PlayerTextDrawLetterSize(playerid, boxtext[playerid], 0.285499, 1.250000);
- PlayerTextDrawAlignment(playerid, boxtext[playerid], 1);
- PlayerTextDrawColor(playerid, boxtext[playerid], -1523963137);
- PlayerTextDrawSetShadow(playerid, boxtext[playerid], 0);
- PlayerTextDrawSetOutline(playerid, boxtext[playerid], 1);
- PlayerTextDrawBackgroundColor(playerid, boxtext[playerid], 51);
- PlayerTextDrawFont(playerid, boxtext[playerid], 1);
- PlayerTextDrawSetProportional(playerid, boxtext[playerid], 1);
- return 1;
- }
- stock SaveHouses()
- {
- for(new i=1;i < MAX_HOUSES;i++)
- {
- if(HouseTaken[i] == 0) continue;
- new hFile[35];
- format(hFile, 35, HOUSE_PATH, i);
- new INI:File = INI_Open(hFile);
- INI_SetTag(File, "House Data");
- INI_WriteString(File, "Owner", HouseInfo[i][Owner]);
- INI_WriteInt(File, "Owned", HouseInfo[i][Owned]);
- INI_WriteInt(File, "Price", HouseInfo[i][Price]);
- INI_WriteFloat(File, "EnterX", HouseInfo[i][EnterX]);
- INI_WriteFloat(File, "EnterY", HouseInfo[i][EnterY]);
- INI_WriteFloat(File, "EnterZ", HouseInfo[i][EnterZ]);
- INI_WriteFloat(File, "EnterA", HouseInfo[i][EnterA]);
- INI_WriteFloat(File, "ExitX", HouseInfo[i][ExitX]);
- INI_WriteFloat(File, "ExitY", HouseInfo[i][ExitY]);
- INI_WriteFloat(File, "ExitZ", HouseInfo[i][ExitZ]);
- INI_WriteFloat(File, "ExitA", HouseInfo[i][ExitA]);
- INI_WriteInt(File, "EnterInt", HouseInfo[i][EnterInt]);
- INI_WriteInt(File, "EnterVW", HouseInfo[i][EnterVW]);
- INI_WriteInt(File, "ExitInt", HouseInfo[i][ExitInt]);
- INI_WriteInt(File, "ExitVW", HouseInfo[i][ExitVW]);
- INI_WriteInt(File, "Money", HouseInfo[i][Money]);
- INI_WriteInt(File, "PickupID", HouseInfo[i][PickupID]);
- INI_WriteInt(File, "Locked", HouseInfo[i][Locked]);
- INI_Close(File);
- }
- }
- forward LoadHouse(id, name[], value[]);
- public LoadHouse(id, name[], value[])
- {
- INI_String("Owner", HouseInfo[id][Owner],32);
- INI_Int("Owned", HouseInfo[id][Owned]);
- INI_Int("Price", HouseInfo[id][Price]);
- INI_Float("EnterX", HouseInfo[id][EnterX]);
- INI_Float("EnterY", HouseInfo[id][EnterY]);
- INI_Float("EnterZ", HouseInfo[id][EnterZ]);
- INI_Float("EnterA", HouseInfo[id][EnterA]);
- INI_Float("ExitX", HouseInfo[id][ExitX]);
- INI_Float("ExitY", HouseInfo[id][ExitY]);
- INI_Float("ExitZ", HouseInfo[id][ExitZ]);
- INI_Float("ExitA", HouseInfo[id][ExitA]);
- INI_Int("EnterInt", HouseInfo[id][EnterInt]);
- INI_Int("EnterVW", HouseInfo[id][EnterVW]);
- INI_Int("ExitInt", HouseInfo[id][ExitInt]);
- INI_Int("ExitVW", HouseInfo[id][ExitVW]);
- INI_Int("Money", HouseInfo[id][Money]);
- INI_Int("PickupID", HouseInfo[id][PickupID]);
- INI_Int("Locked", HouseInfo[id][Locked]);
- HouseTaken[id] = 1;
- return 1;
- }
- stock SaveUser(playerid)
- {
- new File[35];
- format(File, 35, USER_PATH, GetName(playerid));
- new INI:f = INI_Open(File);
- INI_SetTag(f, "Player Data");
- INI_WriteInt(f, "HouseID", PlayerInfo[playerid][HouseID]);
- INI_WriteInt(f, "HouseKey", PlayerInfo[playerid][HouseKey]);
- INI_Close(f);
- }
- forward LoadUser(playerid, name[], value[]);
- public LoadUser(playerid, name[], value[])
- {
- INI_Int("HouseID",PlayerInfo[playerid][HouseID]);
- INI_Int("HouseKey",PlayerInfo[playerid][HouseKey]);
- return 1;
- }
- // ====================================[COMMANDS]=================================
- CMD:hhelp(playerid, params[]) return cmd_househelp(playerid, params);
- CMD:help(playerid, params[]) return cmd_househelp(playerid, params);
- CMD:househelp(playerid, params[])
- {
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}==================[HOUSE COMMANDS]===============");
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ADMIN]: {FFFFFF}/createhouse /deletehouse /edithloc /edithprice");
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[PLAYER] {FFFFFF}/buy /sell /lock /putmoney /takemoney");
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[EXTRA]: {FFFFFF}/saveme /loadme");
- return 1;
- }
- CMD:createhouse(playerid, params[])
- {
- new type[128], string[256];
- new id = GetAvailableID();
- if(sscanf(params, "s[128]",type))
- {
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX] {FFFFFF}/createhouse [Level]");
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[OPTIONS]{FFFFFF}|| L1 - L2 - L3 - L4 ||");
- return 1;
- }
- if(!strcmp(type, "l1", true, 2))
- {
- HouseInfo[id][EnterX] = 2308.8;
- HouseInfo[id][EnterY] = -1212.8;
- HouseInfo[id][EnterZ] = 1049.0;
- HouseInfo[id][EnterInt] = 6;
- }
- if(!strcmp(type, "l2", true, 2))
- {
- HouseInfo[id][EnterX] = 260.7;
- HouseInfo[id][EnterY] = 1237.5;
- HouseInfo[id][EnterZ] = 1084.2;
- HouseInfo[id][EnterInt] = 9;
- }
- if(!strcmp(type, "l3", true, 2))
- {
- HouseInfo[id][EnterX] = 2365.2;
- HouseInfo[id][EnterY] = -1135.4;
- HouseInfo[id][EnterZ] = 1050.8;
- HouseInfo[id][EnterInt] = 8;
- }
- if(!strcmp(type, "l4", true, 2))
- {
- HouseInfo[id][EnterX] = 2270.1;
- HouseInfo[id][EnterY] = -1210.4;
- HouseInfo[id][EnterZ] = 1047.5;
- HouseInfo[id][EnterInt] = 10;
- }
- // Setting House Information
- new Float: Pos[3];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- HouseTaken[id] = 1;
- HouseInfo[id][Owned] = 0;
- HouseInfo[id][ExitX] = Pos[0];
- HouseInfo[id][ExitY] = Pos[1];
- HouseInfo[id][ExitZ] = Pos[2];
- HouseInfo[id][ExitInt] = GetPlayerInterior(playerid);
- HouseInfo[id][ExitVW] = GetPlayerVirtualWorld(playerid);
- HouseInfo[id][EnterVW] = GetPlayerVirtualWorld(playerid)+250;
- HouseInfo[id][Price] = 9999999;
- // Visually,creating the House
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Status: {2F70D0}For sale\n{FFFFFF}Price: {2F70D0}%d", id,HouseInfo[id][Price]);
- HouseInfo[id][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[id][ExitX], HouseInfo[id][ExitY], HouseInfo[id][ExitZ], 15);
- HouseInfo[id][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[id][ExitX], HouseInfo[id][ExitY], HouseInfo[id][ExitZ], 0, 0, -1, 40.0);
- // Saving
- SaveHouses();
- return 1;
- }
- CMD:deletehouse(playerid, params[])
- {
- new houseid,string[128];
- if(sscanf(params, "d", houseid))
- {
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX] {FFFFFF}/deletehouse [houseid]");
- return 1;
- }
- if(houseid < 1 || houseid > MAX_HOUSES)
- {
- format(string, sizeof(string), "{2F70D0}[ERROR]:{FFFFFF}House ID cannot be below 0 and above %d.", MAX_HOUSES);
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- DestroyDynamic3DTextLabel(HouseInfo[houseid][Label]);
- DestroyDynamicPickup(HouseInfo[houseid][PickupID]);
- new file[128];
- // House Information
- HouseInfo[houseid][Owned] = 0;
- HouseInfo[houseid][Price] = 0;
- HouseInfo[houseid][EnterX] = 0.0;
- HouseInfo[houseid][EnterY] = 0.0;
- HouseInfo[houseid][EnterZ] = 0.0;
- HouseInfo[houseid][EnterA] = 0.0;
- HouseInfo[houseid][ExitX] = 0.0;
- HouseInfo[houseid][ExitY] = 0.0;
- HouseInfo[houseid][ExitZ] = 0.0;
- HouseInfo[houseid][ExitA] = 0.0;
- HouseInfo[houseid][PickupID] = 0;
- HouseInfo[houseid][Locked] = 0;
- HouseTaken[houseid] = 0;
- // Deleting the House From ScriptFiles.
- format(file, sizeof(file), HOUSE_PATH, houseid);
- if(fexist(file)) fremove(file);
- return 1;
- }
- CMD:edithloc(playerid, params[])
- {
- new string[128],houseid;
- if(sscanf(params, "d", houseid)) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX] {FFFFFF}/edithloc [houseid]");
- // Setting House Information
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- HouseInfo[houseid][ExitX] = X;
- HouseInfo[houseid][ExitY] = Y;
- HouseInfo[houseid][ExitZ] = Z;
- HouseInfo[houseid][ExitInt] = GetPlayerInterior(playerid);
- HouseInfo[houseid][ExitVW] = GetPlayerVirtualWorld(playerid);
- DestroyDynamicPickup(HouseInfo[houseid][PickupID]);
- DestroyDynamic3DTextLabel(HouseInfo[houseid][Label]);
- HouseInfo[houseid][PickupID] = 0;
- // Updating the Pickup
- if(HouseInfo[houseid][Owned])
- {
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Owner: {2F70D0}%s\n{FFFFFF}Status: {2F70D0}%s", houseid,HouseInfo[houseid][Owner],HL(houseid));
- }
- else
- {
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Status: {2F70D0}For sale\n{FFFFFF}Price: {2F70D0}%d", houseid,HouseInfo[houseid][Price]);
- }
- HouseInfo[houseid][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 15);
- HouseInfo[houseid][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 0, 0, -1, 40.0);
- // Saving
- SaveHouses();
- return 1;
- }
- CMD:edithprice(playerid, params[])
- {
- new string[128],houseid,price;
- if(sscanf(params, "dd", houseid,price)) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX] {FFFFFF}/edithprice [houseid] [price]");
- // Setting House Information
- HouseInfo[houseid][Price] = price;
- DestroyDynamicPickup(HouseInfo[houseid][PickupID]);
- HouseInfo[houseid][PickupID] = 0;
- DestroyDynamic3DTextLabel(HouseInfo[houseid][Label]);
- // Updating the Pickup
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Status: {2F70D0}For sale\n{FFFFFF}Price: {2F70D0}%d", houseid,HouseInfo[houseid][Price]);
- HouseInfo[houseid][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 15);
- HouseInfo[houseid][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 0, 0, -1, 40.0);
- // Saving
- SaveHouses();
- return 1;
- }
- CMD:lock(playerid, params[])
- {
- new id;
- new txdstring[128];
- if(!PlayerInfo[playerid][HouseKey]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]: {FFFFFF}You don't own a House that you can lock.");
- // Getting the House ID
- if(PlayerInfo[playerid][HouseID])
- {
- id = PlayerInfo[playerid][HouseID];
- }
- // Locking/Unlocking
- if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[id][ExitX],HouseInfo[id][ExitY],HouseInfo[id][ExitZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[id][EnterX],HouseInfo[id][EnterY],HouseInfo[id][EnterY]))
- {
- if(HouseInfo[id][Locked] == 0)
- {
- new string[128];
- HouseInfo[id][Locked] = 1;
- // Textdraw
- format(txdstring, sizeof(txdstring), "Locked");
- PlayerTextDrawSetString(playerid, boxtext[playerid], txdstring);
- PlayerTextDrawShow(playerid, Box[playerid]);
- PlayerTextDrawShow(playerid, boxtext[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- // Pickup
- DestroyDynamic3DTextLabel(HouseInfo[id][Label]);
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Owner: {2F70D0}%s\n{FFFFFF}Status: {2F70D0}%s", id,HouseInfo[id][Owner],HL(id));
- HouseInfo[id][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[id][ExitX], HouseInfo[id][ExitY], HouseInfo[id][ExitZ], 15);
- return 1;
- }
- else
- {
- new string[128];
- HouseInfo[id][Locked] = 0;
- // Textdraw
- format(txdstring, sizeof(txdstring), "Unlocked");
- PlayerTextDrawSetString(playerid, boxtext[playerid], txdstring);
- PlayerTextDrawShow(playerid, Box[playerid]);
- PlayerTextDrawShow(playerid, boxtext[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- // Pickup
- DestroyDynamic3DTextLabel(HouseInfo[id][Label]);
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Owner: {2F70D0}%s\n{FFFFFF}Status: {2F70D0}%s", id,HouseInfo[id][Owner],HL(id));
- HouseInfo[id][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[id][ExitX], HouseInfo[id][ExitY], HouseInfo[id][ExitZ], 15);
- return 1;
- }
- }
- return 1;
- }
- CMD:buy(playerid, params[])
- {
- new string[256],buy;
- if(PlayerInfo[playerid][HouseKey]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF}You already own a House.");
- for(new idx=1; idx < MAX_HOUSES; idx++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[idx][ExitX], HouseInfo[idx][ExitY], HouseInfo[idx][ExitZ]))
- {
- if(!HouseInfo[idx][Owned])
- {
- if(GetPlayerMoney(playerid) < HouseInfo[idx][Price]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF} You cannot afford to purchase this house.");
- GivePlayerMoney(playerid, -HouseInfo[idx][Price]);
- PlayerInfo[playerid][HouseKey] = 1;
- PlayerInfo[playerid][HouseID] = idx;
- HouseInfo[idx][Owned] = 1;
- format(HouseInfo[idx][Owner], 32, "%s", GetName(playerid));
- SendClientMessage(playerid, COLOR_GREEN, "{2F70D0}[INFO]:{FFFFFF} Welcome to your new Home.For more Information,use /househelp.");
- // Textdraw
- PlayerTextDrawSetString(playerid, Statement[playerid], "You have successfully ~g~purchased~w~ a house");
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- // Pickup
- DestroyDynamic3DTextLabel(HouseInfo[idx][Label]);
- HouseInfo[idx][PickupID] = 0;
- format(string, sizeof(string), "House {2F70D0}%d\n{FFFFFF}Owner: {2F70D0}%s\n{FFFFFF}Status: {2F70D0}%s", idx,HouseInfo[idx][Owner],HL(idx));
- HouseInfo[idx][Label] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][ExitX], HouseInfo[idx][ExitY], HouseInfo[idx][ExitZ], 15);
- HouseInfo[idx][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[idx][ExitX], HouseInfo[idx][ExitY], HouseInfo[idx][ExitZ], 0, 0, -1, 40.0);
- idx = MAX_HOUSES;
- // Saving
- SaveHouses();
- buy = 1;
- }
- if(idx == MAX_HOUSES-1 && !buy)
- {
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF} This house is owned by someone else.");
- }
- }
- if(idx == MAX_HOUSES-1 && !buy)
- {
- SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF} You are not near a House you can buy.");
- return 1;
- }
- }
- return 1;
- }
- CMD:sell(playerid, params[])
- {
- new string[128],txdstring[128];
- if(!PlayerInfo[playerid][HouseKey]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF}You do not own a House that you can sell.");
- {
- new id = PlayerInfo[playerid][HouseID];
- if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[PlayerInfo[playerid][HouseID]][ExitX], HouseInfo[PlayerInfo[playerid][HouseID]][ExitY], HouseInfo[PlayerInfo[playerid][HouseID]][ExitZ])) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF}You are not near your House.");
- new string2[128];
- new price = HouseInfo[id][Price];
- new percent = SELLPERCENT*price/100;
- GivePlayerMoney(playerid, percent);
- // Textdraw
- format(txdstring, sizeof(txdstring), "You have successfully ~g~sold~w~ your house for $%d.",percent);
- PlayerTextDrawSetString(playerid, Statement[playerid], txdstring);
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- // Setting the Information
- HouseInfo[id][Owned] = 0;
- HouseInfo[id][Locked] = 0;
- format(HouseInfo[PlayerInfo[playerid][HouseID]][Owner], 32, "Government");
- format(string, sizeof(string), "{2F70D0}[INFO]: {FFFFFF}You have sold your House for $%d.", percent);
- SendClientMessage(playerid, COLOR_WHITE, string);
- DestroyDynamic3DTextLabel(HouseInfo[id][Label]);
- format(string2, sizeof(string2), "House {2F70D0}%d\n{FFFFFF}Status: {2F70D0}For sale\n{FFFFFF}Price: {2F70D0}%d", id,HouseInfo[id][Price]);
- HouseInfo[id][Label] = CreateDynamic3DTextLabel(string2, COLOR_WHITE, HouseInfo[id][ExitX], HouseInfo[id][ExitY], HouseInfo[id][ExitZ], 15);
- PlayerInfo[playerid][HouseKey] = 0;
- PlayerInfo[playerid][HouseID] = 0;
- }
- return 1;
- }
- CMD:putmoney(playerid, params[])
- {
- new txdstring[128];
- new amount;
- new i = PlayerInfo[playerid][HouseID];
- if(!PlayerInfo[playerid][HouseKey]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF}You do not own a House.");
- {
- if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX]:{FFFFFF} /putmoney [amount]");
- if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF} You don't have that much money on you right now.");
- // Adding the money to the House's Vault.
- HouseInfo[i][Money] += amount;
- // Deducting the Money from the Player
- GivePlayerMoney(playerid, -amount);
- // Textdraw
- format(txdstring, sizeof(txdstring), "You have ~g~deposited~w~ $%d in your house's vault",amount);
- PlayerTextDrawSetString(playerid, Statement[playerid], txdstring);
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- }
- return 1;
- }
- CMD:takemoney(playerid, params[])
- {
- new txdstring[128];
- new amount;
- new i = PlayerInfo[playerid][HouseID];
- if(!PlayerInfo[playerid][HouseKey]) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF}You do not own a House.");
- {
- if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX]:{FFFFFF} /takemoney [amount]");
- if(HouseInfo[i][Money] < amount) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[ERROR]:{FFFFFF} You don't have that much money in your House's Vault right now.");
- // Adding the money to the House's Vault.
- HouseInfo[i][Money] -= amount;
- // Deducting the Money from the Player
- GivePlayerMoney(playerid, amount);
- // Textdraw
- format(txdstring, sizeof(txdstring), "You have ~g~taken~w~ $%d from your house's vault",amount);
- PlayerTextDrawSetString(playerid, Statement[playerid], txdstring);
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- }
- return 1;
- }
- CMD:sethmoney(playerid, params[])
- {
- new amount,houseid;
- new txdstring[128];
- if(sscanf(params, "ii", houseid,amount)) return SendClientMessage(playerid, COLOR_WHITE, "{2F70D0}[SYNTAX]:{FFFFFF} /sethmoney [houseid] [amount]");
- HouseInfo[houseid][Money] = amount;
- // Textdraw
- format(txdstring, sizeof(txdstring), "You have set ~g~House(%d)'s money~w~ to $%d.",houseid,amount);
- PlayerTextDrawSetString(playerid, Statement[playerid], txdstring);
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- return 1;
- }
- // VERSION 2
- CMD:knock(playerid, params[])
- {
- for(new i=1; i < (MAX_HOUSES); i++) if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][ExitX], HouseInfo[i][ExitY], HouseInfo[i][ExitZ]))
- {
- for(new id = 0; id < MAX_PLAYERS; id++)
- {
- if(IsPlayerInRangeOfPoint(id, 8.0, HouseInfo[i][EnterX], HouseInfo[i][EnterY], HouseInfo[i][EnterZ]))
- {
- SendClientMessage(id, COLOR_WHITE, "(INFO): {FFFFFF}Someone has knocked the Door.");
- }
- }
- PlayerTextDrawSetString(playerid, Statement[playerid], "You have ~g~knocked~w~ the house door");
- PlayerTextDrawShow(playerid, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", playerid);
- }
- return 1;
- }
- CMD:shout(playerid, params[])
- {
- new string[1300];
- new msg[128];
- if(sscanf(params, "s[128]", msg)) return SendClientMessage(playerid, COLOR_WHITE, "(INFO): /shout [text]");
- for(new i=1; i < (MAX_HOUSES); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][ExitX], HouseInfo[i][ExitY], HouseInfo[i][ExitZ]))
- for(new id = 0; id < MAX_PLAYERS; id++)
- {
- if(IsPlayerInRangeOfPoint(id, 8.0, HouseInfo[i][EnterX], HouseInfo[i][EnterY], HouseInfo[i][EnterZ]))
- {
- format(string, sizeof(string), "~g~(Outside)~w~: %s", msg);
- PlayerTextDrawSetString(id, Statement[playerid], string);
- PlayerTextDrawShow(id, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i", id);
- }
- }
- if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][EnterX], HouseInfo[i][EnterY], HouseInfo[i][EnterZ]))
- for(new p = 0; p < MAX_PLAYERS; p++)
- {
- if(IsPlayerInRangeOfPoint(p, 8.0, HouseInfo[i][ExitX], HouseInfo[i][ExitY], HouseInfo[i][ExitZ]))
- {
- format(string, sizeof(string), "~g~(Inside)~w~: %s", msg);
- PlayerTextDrawSetString(p, Statement[playerid], string);
- PlayerTextDrawShow(p, Statement[playerid]);
- SetTimerEx("HideTextdraws", 4000, false, "i",p);
- }
- }
- }
- return 1;
- }
- CMD:house(playerid, params[])
- {
- SetPlayerPos(playerid, 10.0, 10.0, 10.0);
- return 1;
- }
- //
- // Extra
- CMD:saveme(playerid, params[])
- {
- SaveUser(playerid);
- SaveHouses();
- return 1;
- }
- CMD:loadme(playerid, params[])
- {
- new File[35];
- format(File, 35, USER_PATH, GetName(playerid));
- {
- INI_ParseFile(File, "LoadUser", .bExtra = true, .extra = playerid);
- }
- CreateTextdraws(playerid);
- return 1;
- }
- // ====================================[END OF COMMANDS]=================================
- forward HideTextdraws(playerid);
- public HideTextdraws(playerid)
- {
- PlayerTextDrawHide(playerid, Statement[playerid]);
- PlayerTextDrawHide(playerid, Box[playerid]);
- PlayerTextDrawHide(playerid, boxtext[playerid]);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (PRESSED( KEY_SECONDARY_ATTACK ))
- {
- for(new i = 1; i < sizeof(HouseInfo); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid,4.0,HouseInfo[i][ExitX],HouseInfo[i][ExitY],HouseInfo[i][ExitZ]))
- {
- if(HouseInfo[i][Locked] == 1) return Showlock(playerid);
- if(HouseInfo[i][EnterX] == 0) return SendClientMessage(playerid, COLOR_WHITE, "[WARNING] This house has no Interior set up yet.");
- SetPlayerPos(playerid, HouseInfo[i][EnterX],HouseInfo[i][EnterY],HouseInfo[i][EnterZ]);
- SetPlayerInterior(playerid, HouseInfo[i][EnterInt]);
- SetPlayerVirtualWorld(playerid, HouseInfo[i][EnterVW]);
- }
- else if(IsPlayerInRangeOfPoint(playerid,4.0,HouseInfo[i][EnterX],HouseInfo[i][EnterY],HouseInfo[i][EnterZ]))
- {
- SetPlayerPos(playerid, HouseInfo[i][ExitX],HouseInfo[i][ExitY],HouseInfo[i][ExitZ]);
- SetPlayerInterior(playerid, HouseInfo[i][ExitInt]);
- SetPlayerVirtualWorld(playerid, HouseInfo[i][ExitVW]);
- }
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new File[35];
- format(File, 35, USER_PATH, GetName(playerid));
- {
- INI_ParseFile(File, "LoadUser", .bExtra = true, .extra = playerid);
- }
- CreateTextdraws(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SaveUser(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement