Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Barbouch's Houses //
- // v: 0.1 //
- // Features : //
- // Buyable/Sellable Houses //
- // Dynamic Houses Creating In Game //
- //Current Saving System Version: INI//
- // Next Version v: 0.2 //
- // Features: //
- // MYSQL VERSION : will come with v0.2 //
- // Houses Cars //
- // Players will be building there own houses using ressources that they will gather //
- // Release Date of the V 0.2 : [Coming Very Soon] //
- // Credits: Firecat for his awesome Tutorial//
- // Credits: Naruto_Emilio for coding this FilterScript //
- // Credits: Traduzido por: Diksplay For PT/BR Board
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <SII>
- #include <streamer>
- #define COL_EASY "{FFF1AF}"
- #define COL_WHITE "{FFFFFF}"
- #define COL_BLACK "{0E0101}"
- #define COL_GREY "{C3C3C3}"
- #define COL_GREEN "{6EF83C}"
- #define COL_RED "{F81414}"
- #define COL_YELLOW "{F3FF02}"
- #define COL_ORANGE "{FFAF00}"
- #define COL_LIME "{B7FF00}"
- #define COL_CYAN "{00FFEE}"
- #define COL_LIGHTBLUE "{00C0FF}"
- #define COL_BLUE "{0049FF}"
- #define COL_MAGENTA "{F300FF}"
- #define COL_VIOLET "{B700FF}"
- #define COL_PINK "{FF00EA}"
- #define COL_MARONE "{A90202}"
- #define COL_CMD "{B8FF02}"
- #define COL_PARAM "{3FCD02}"
- #define COL_SERVER "{AFE7FF}"
- #define COL_VALUE "{A3E4FF}"
- #define COL_RULE "{F9E8B7}"
- #define COL_RULE2 "{FBDF89}"
- #define COL_RWHITE "{FFFFFF}"
- #define COL_LGREEN "{C9FFAB}"
- #define COL_LRED "{FFA1A1}"
- #define COL_LRED2 "{C77D87}"
- #pragma tabsize 0
- #define IAD IsPlayerAdmin
- #define MAX_HOUSES_BUILT 1000 // Você Mudar isso, como quiser
- #define HELP_DIALOG 2580
- #define INVALID_HOUSE_ID -255 // Use sempre um valor negativo
- enum HouseInf
- {
- Owner[24],
- Owned,
- Price,
- Float:posX,
- Float:posY,
- Float:posZ,
- VW,
- Text3D:HouseLabel
- }
- new HInfo[MAX_HOUSES_BUILT][HouseInf];
- new Housesnumbers;
- new HousesEntrance[MAX_HOUSES_BUILT];
- new HousesExit[MAX_HOUSES_BUILT];
- new InsideHouse[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Barbouch's House System Ligado!");
- print("--------------------------------------\n");
- LoadHouses();
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Barbouch's House System Desligado!");
- print("--------------------------------------\n");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- DeletePlayer3DTextLabel(i, PlayerText3D:HouseLabel);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- CMD:makehouse(playerid, params[])
- {
- if(!IAD(playerid)) return GameTextForPlayer(playerid, "~r~Acesso Negado", 3000, 5);
- new
- Float:X,
- Float:Y,
- Float:Z,
- hPrice,
- virtualw,
- string[60],
- HID = Housesnumbers;
- if(sscanf(params,"ii", hPrice, virtualw)) return SendClientMessage(playerid,-1,"{ Uso Correto } "#COL_GREEN#" /makehouse "#COL_YELLOW#" (preço) "#COL_VIOLET#" (Virtual World)");
- if(hPrice < 10000)
- {
- SendClientMessage(playerid, -1, "O Preço da casa Deve começar em RS 10000");
- return 0;
- }
- if(virtualw <= -1)
- {
- SendClientMessage(playerid, -1, ""#COL_RED#"Virutal World Não deve ser um "#COL_YELLOW#"minus "#COL_RED#"Número.");
- return 0;
- }
- GetPlayerPos(playerid, X, Y, Z);
- HInfo[HID][Price] = hPrice;
- HInfo[HID][Owned] = 0;
- HInfo[HID][posX] = X;
- HInfo[HID][posY] = Y;
- HInfo[HID][posZ] = Z;
- HInfo[HID][VW] = virtualw;
- format(HInfo[HID][Owner], 20, "No_Owner");
- GameTextForPlayer(playerid, "~g~Casa Criada", 1500, 5);
- format(string, sizeof(string), "Preço da Casa: "#COL_GREEN#"%i "#COL_MARONE#"||"#COL_WHITE#" Virtual World: "#COL_GREEN#"%i", HInfo[HID][Price], HInfo[HID][VW]);
- SendClientMessage(playerid, -1, string);
- HousesEntrance[HID] = CreateDynamicCP(X , Y , Z , 1.0, virtualw);
- HousesExit[HID] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5, virtualw);
- new file[40], labelstring[100];
- format(file, sizeof(file), "Houses/%i.ini", HID);
- INI_Open(file);
- INI_WriteInt("Price", hPrice);
- INI_WriteInt("Owned",0);
- INI_WriteInt("VirtualWorld", virtualw);
- INI_WriteFloat("posX", X);
- INI_WriteFloat("posY", Y);
- INI_WriteFloat("posZ", Z);
- INI_WriteString("Owner","No_Owner");
- INI_Save();
- INI_Close();
- format(labelstring,sizeof(labelstring),""#COL_GREEN#"[ DONO ]: "#COL_WHITE#"Sem Dono \n"#COL_GREEN#"[ Preço ]: "#COL_RED#"%i", hPrice);
- HInfo[HID][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, X, Y, Z, 25.0 , virtualw);
- Housesnumbers++;
- return 1;
- }
- forward LoadPos(playerid);
- public LoadPos(playerid)
- {
- SetPlayerPos(playerid, GetPVarFloat(playerid,"xpos"), GetPVarFloat(playerid,"ypos"), GetPVarFloat(playerid,"zpos"));
- SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "pvirtual"));
- SetPlayerInterior(playerid, 0);
- return 1;
- }
- forward SavePos(playerid);
- public SavePos(playerid)
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- SetPVarFloat(playerid,"xpos",x);
- SetPVarFloat(playerid,"ypos",y);
- SetPVarFloat(playerid,"zpos",z);
- SetPVarInt(playerid,"pvirtual", GetPlayerVirtualWorld(playerid));
- return 1;
- }
- public OnPlayerEnterDynamicCP(playerid,checkpointid)
- {
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)
- {
- new pName[24];
- GetPlayerName(playerid, pName, sizeof(pName));
- if(checkpointid == HousesEntrance[i])
- {
- if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner]) != 0) return SendClientMessage(playerid,-1,""#COL_RED#"You aren't the "#COL_YELLOW#"owner "#COL_GREEN#"of this house!");
- if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)
- {
- ShowPlayerDialog(playerid, 2002, DIALOG_STYLE_LIST, "Opções da Casa", ""#COL_BLUE#"Entrar na Casa\n"#COL_RED#"Vender Casa", "Escolher", "Cancelar");
- SavePos(playerid);
- }
- if(HInfo[i][Owned] == 0)
- {
- ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_MSGBOX, "Opções da Casa", "Você tem certeza, que quer comprar está casa?", "Comprar", "Cancelar");
- }
- }
- if(checkpointid == HousesExit[i])
- {
- ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_MSGBOX, "Opções da Casa", "Você quer deixar está casa?", "Sim", "Não");
- }
- }
- return 1;
- }
- public OnPlayerLeaveDynamicCP(playerid, checkpointid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 2000)
- {
- if(response)
- {
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)
- {
- LoadPos(playerid);
- }
- SendClientMessage(playerid, -1, ""#COL_RED#"Você saiu Da casa de: "#COL_GREEN#"");
- }
- else
- {
- SendClientMessage(playerid, -1, ""#COL_RED#"Você cancelou a saida da casa de: "#COL_GREEN#"");
- }
- return 1;
- }
- if(dialogid == 2001)
- {
- if(response)
- {
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)
- {
- if(!IsPlayerInRangeOfPoint(playerid, 8.0, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ])) continue;
- if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid, -1, ""#COL_RED#"Você Não tem dinheiro suficiente!");
- if(HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,""#COL_RED#"Está casa já tem "#COL_GREEN#"Dono!");
- HInfo[i][Owned] = 1;
- new file[60], pName[24], string[100];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(HInfo[i][Owner], 24, "%s", pName);
- format(file,sizeof(file),"Houses/%i.ini", i);
- INI_Open(file);
- INI_WriteInt("Owned",1);
- INI_WriteString("Owner",pName);
- INI_Save();
- INI_Close();
- format(string,sizeof(string),""#COL_GREEN#"Comprada: "#COL_WHITE#"Sim \n"#COL_GREEN#"Preço: "#COL_RED#"%i \n"#COL_GREEN#"Dono: "#COL_WHITE#"%s", HInfo[i][Price], pName);
- Update3DTextLabelText(HInfo[i][HouseLabel], 0xFF0000FF, string);
- GivePlayerMoney(playerid, -HInfo[i][Price]);
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, -1, ""#COL_RED#"Você cancelou a compra desta "#COL_GREEN#"casa");
- }
- return 1;
- }
- if(dialogid == 2002)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)
- {
- new pName[24];
- GetPlayerName(playerid,pName,24);
- if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner], pName) == 0)
- {
- SetPVarInt(playerid,"PlayersInteriorHouse", GetPlayerInterior(playerid));
- SetPVarInt(playerid,"PlayerVirtualWorldHouse", GetPlayerVirtualWorld(playerid));
- SetPlayerInterior(playerid,12);
- SetPlayerPos(playerid,446.7281,507.0475,1001.4195) ;
- SetPlayerVirtualWorld(playerid,HInfo[i][VW]);
- InsideHouse[playerid] = i;
- }
- else
- {
- SendClientMessage(playerid, -1, ""#COL_RED#"Você não pode entrar nesta "#COL_GREEN#"pois ela já tem um "#COL_YELLOW#"Dono");
- }
- }
- }
- case 1:
- {
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)//Loop threw all houses.
- {
- new pName[24];
- GetPlayerName(playerid,pName,24);
- new file[60],string[100];
- format(HInfo[i][Owner], 24, "No_Owner");
- format(file,sizeof(file),"Houses/%i.ini",i);
- INI_Open(file);
- INI_WriteInt("Owned",0);
- INI_WriteString("Owner","No_Owner");
- INI_Save();
- INI_Close();
- format(string, sizeof(string), ""#COL_GREEN#"Owned: "#COL_MAGENTA#"No \n"#COL_GREEN#"Price: "#COL_RED#"%i \n"#COL_GREEN#"Owner: "#COL_WHITE#"None", HInfo[i][Price],pName);
- Update3DTextLabelText(HInfo[i][HouseLabel], 0xFF0000FF, string);
- format(string, 80, "Você vendeu sua casa para:"#COL_GREEN#" %d", HInfo[i][Price]/=2);
- GivePlayerMoney(playerid, HInfo[i][Price]/=2);
- SendClientMessage(playerid, -1, string);
- HInfo[i][Owned] = 0;
- return 1;
- }
- }
- }
- }
- }
- return 1;
- }
- stock LoadHouses()
- {
- new file[60],houseowner[24];
- for(new i = 0; i < MAX_HOUSES_BUILT;i++)
- {
- format(file,sizeof(file),"Houses/%i.ini",i);
- if(!INI_Exist(file)) continue;
- INI_Open(file);
- HInfo[i][Price] = INI_ReadInt("Price");
- HInfo[i][Owned] = INI_ReadInt("Owned");
- HInfo[i][posX] = INI_ReadInt("posX");
- HInfo[i][posY] = INI_ReadInt("posY");
- HInfo[i][posZ] = INI_ReadInt("posZ");
- HInfo[i][VW] = INI_ReadInt("VirtualWorld");
- INI_ReadString(houseowner, "Owner");
- format(HInfo[i][Owner], 24, "%s", houseowner);
- HousesEntrance[i] = CreateDynamicCP(HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ], 1.5, HInfo[i][VW]);
- HousesExit[i] = CreateDynamicCP(443.9237, 509.4609, 1001.4195, 1.5, HInfo[i][VW]);
- new labelstring[100];
- switch(HInfo[i][Owned])
- {
- case 0:{format(labelstring, sizeof(labelstring), ""#COL_GREEN#"Dono: "#COL_RED#"Não \n"#COL_GREEN#"Preço: "#COL_YELLOW#"%i", HInfo[i][Price]);}
- case 1:{format(labelstring, sizeof(labelstring), ""#COL_GREEN#"Dono: "#COL_BLUE#"Sim \n"#COL_GREEN#"Preço: "#COL_YELLOW#"%i \n"#COL_GREEN#"Dono: "#COL_VIOLET#"%s", HInfo[i][Price], HInfo[i][Owner]);}
- }
- HInfo[i][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ], 25.0, HInfo[i][VW]);
- Housesnumbers++;
- INI_Close();
- }
- return 1;
- }
- stock GetHouseID(playerid)
- {
- for(new i=0; i<MAX_HOUSES_BUILT; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ]))
- {
- return i;
- }
- }
- return INVALID_HOUSE_ID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement