Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <sscanf2>
- #include <streamer>
- #define GREY 0xAFAFAFAA
- #define BLUE2 0x4682B4FF
- #define RED 0xFF0000AA
- #define YELLOW 0xE9E312FF
- #define ORANGE 0xFF9900AA
- #define WHITE 0xFFFEFFFF
- #define GREEN 0x33AA33AA
- #define BLUE 0x0000FFFF
- #define LIGHTGREEN 0x90EE90FF
- #define OLIVE 0x808000FF
- #define SALAMON 0xFA8072FF
- #define BLACK 0x000000FF
- #define C_GREY "{AFAFAF}"
- #define C_BLUE2 "{4682B4}"
- #define C_RED "{FF0000}"
- #define C_YELLOW "{E9E312}"
- #define C_ORANGE "{FF9900}"
- #define C_WHITE "{FFFEFF}"
- #define C_GREEN "{33AA33}"
- #define C_BLUE "{0000FF}"
- #define C_LIGHTGREEN "{90EE90}"
- #define C_OLIVE "{808000}"
- #define C_SALAMON "{FA8072}"
- #define C_BLACK "{000000}"
- #define MAX_HOUSE 100
- #define HousePATH "House/%d.ini"
- enum hInfo
- {
- hOwner[24],
- Text3D:hLabel,
- hPickup,
- Float:hEnterX,
- Float:hEnterY,
- Float:hEnterZ,
- Float:hExitX,
- Float:hExitY,
- Float:hExitZ,
- hInterior,
- hCost,
- hSell
- };
- new HouseInfo[MAX_PLAYERS][hInfo];
- new MaDom[MAX_PLAYERS];
- new Float:X, Float:Y, Float:Z;
- new houseid;
- new HouseCount;
- forward LoadHouse_data(playerid, name[], value[]);
- public OnPlayerConnect(playerid)
- {
- HouseInfo[playerid][hOwner] = 0;
- HouseInfo[playerid][hEnterX] = 0;
- HouseInfo[playerid][hEnterY] = 0;
- HouseInfo[playerid][hEnterZ] = 0;
- HouseInfo[playerid][hExitX] = 0;
- HouseInfo[playerid][hExitY] = 0;
- HouseInfo[playerid][hExitZ] = 0;
- HouseInfo[playerid][hInterior] = 0;
- HouseInfo[playerid][hCost] = 0;
- HouseInfo[playerid][hSell] = 0;
- MaDom[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(MaDom[playerid] == 1)
- {
- for(new h = 0; h < sizeof(HouseInfo); h++)
- {
- new INI:File = INI_Open(HousePath());
- INI_WriteString(File, "Owner", HouseInfo[playerid][hOwner]);
- INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
- INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
- INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
- INI_WriteFloat(File, "OutputX", HouseInfo[playerid][hExitX]);
- INI_WriteFloat(File, "OutputY", HouseInfo[playerid][hExitY]);
- INI_WriteFloat(File, "OutputZ", HouseInfo[playerid][hExitZ]);
- INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
- INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
- INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
- }
- }
- return 1;
- }
- public OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- for(new h = 0; h < MAX_HOUSE; h++)
- {
- if(checkpointid == HouseInfo[playerid][hPickup])
- {
- if(fexist(HousePath()))
- {
- INI_ParseFile(HousePath(), "LoadHouse_%d", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_MSGBOX, "Dom", "?æä äáéú ùìê, äàí áøöåðê ìäéëðñ àìéå ", "Yes", "No");
- }
- else
- {
- ShowPlayerDialog(playerid, 5001, DIALOG_STYLE_MSGBOX, "Dom", "?äáéú äæä äåà ìîëéøä, äàí áøöåðê ì÷ðåú àåúå", "Yes", "No");
- }
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 5001)
- {
- if(response)
- {
- if(GetPlayerMoney(playerid) > HouseInfo[playerid][hCost])
- {
- MaDom[playerid] = 1;
- SendClientMessage(playerid, GREEN, "House. ");
- new string[128];
- format(string, sizeof string, ""C_BLUE2"Owner : "C_BLUE2"%s ", PlayerName(playerid));
- Update3DTextLabelText(HouseInfo[playerid][hLabel], RED, string);
- new INI:File = INI_Open(HousePath());
- INI_WriteString(File, "Owner", PlayerName(playerid));
- INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
- INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
- INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
- INI_WriteFloat(File, "OutputX", HouseInfo[playerid][hExitX]);
- INI_WriteFloat(File, "OutputY", HouseInfo[playerid][hExitY]);
- INI_WriteFloat(File, "OutputZ", HouseInfo[playerid][hExitZ]);
- INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
- INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
- INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
- INI_Close(File);
- }
- else SendClientMessage(playerid, LIGHTGREEN, "You can not afford this house! ");
- }
- }
- return 1;
- }
- CMD:createhouse(playerid, params[])
- {
- new cost, Sell, interior;
- if(sscanf(params, "ddd", cost, Sell, interior))
- return SendClientMessage(playerid, SALAMON, "USAGE: /createhouse [cost] [sell] [interior]");
- CreateHouse(playerid, cost, Sell, interior);
- return 1;
- }
- forward CreateHouse(playerid, cost, Sell, interior);
- public CreateHouse(playerid, cost, Sell, interior)
- {
- GetPlayerPos(playerid, X, Y, Z);
- new INI:File = INI_Open(HousePath());
- HouseCount++;
- HouseInfo[playerid][hEnterX] = X;
- HouseInfo[playerid][hEnterY] = Y;
- HouseInfo[playerid][hEnterZ] = Z;
- HouseInfo[playerid][hInterior] = interior;
- HouseInfo[playerid][hCost] = cost;
- HouseInfo[playerid][hSell] = Sell;
- INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
- INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
- INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
- INI_WriteFloat(File, "OutputX", 0);
- INI_WriteFloat(File, "OutputY", 0);
- INI_WriteFloat(File, "OutputZ", 0);
- INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
- INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
- INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
- INI_Close(File);
- new string[128];
- format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"lack \n"C_BLUE2"cost : "C_YELLOW"%d\n", cost);
- HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, X, Y, Z, 7.0, 0);
- HouseInfo[houseid][hPickup] = CreateDynamicCP(X, Y, Z, 2, 0, 0, 0, 20);
- return 1;
- }
- public LoadHouse_data(playerid, name[], value[])
- {
- new Name[24], string[128];
- GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
- INI_String("Owner", Name, 48);
- INI_Float("EntryX", HouseInfo[playerid][hEnterX]);
- INI_Float("EntryY", HouseInfo[playerid][hEnterY]);
- INI_Float("EntryZ", HouseInfo[playerid][hEnterZ]);
- INI_Float("OutputX", HouseInfo[playerid][hExitX]);
- INI_Float("OutputY", HouseInfo[playerid][hExitY]);
- INI_Float("OutputZ", HouseInfo[playerid][hExitZ]);
- INI_Int("Interior", HouseInfo[playerid][hInterior]);
- INI_Int("Cost", HouseInfo[playerid][hCost]);
- INI_Int("Sell", HouseInfo[playerid][hSell]);
- if(HouseInfo[playerid][hOwner] == 1)
- {
- format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"%s \n", Name);
- HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0);
- HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20);
- }
- else
- {
- format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"brak \n"C_BLUE2"cost : "C_YELLOW"%d\n", HouseInfo[playerid][hCost]);
- HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0);
- HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20);
- }
- return 1;
- }
- stock HousePath()
- {
- new string[256];
- format(string, sizeof string, HousePATH, HouseCount);
- return string;
- }
- stock PlayerName(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement