22.06.2011, 17:55
(
Последний раз редактировалось Cobertozinho; 22.06.2011 в 18:34.
)
Ola Galera eu Estou aqui de Volta para Postar uma sistema de casa do [HiC] TheKiller ele e Americano mais ele fez um otimo sistema de casa que estou usando no meu server que estou acabando
vou postar o Codigo Abaixo
No Inicio do gm vamos colocar os includes
abaixo dos includes vamos postar os #Defines
Nao se Esqueзa de Criar uma Pasta dentro da pasta scriptfiles e cria a pasta chamada de houses
Agora vamos por o enum e os News
Agora vamos colocar os Icones das Casas e as informaзoes da casas
depois de criar os Scripts de infos das casas agente vai criar os Comandos de Comprarcasa , Vendercasa , entrarcasa e de saircasa
Agora vamos criar a strtok de Comando
e por utimo vamos criar a stock de salvar casas
jah ia esqueзendo ja de Ensinar como criar casa
Fim do Fs Traduzido Por Mim ( Cobertozinho ) e Feito Por: [HiC] TheKiller
Download
pastebin
Multiupload
vou postar o Codigo Abaixo
No Inicio do gm vamos colocar os includes
pawn Код:
#include <a_samp>
#include <dini>
pawn Код:
#define MAX_HOUSES 200
#define house "/houses/Owners.ini"
Agora vamos por o enum e os News
pawn Код:
enum houseinfo
{
HouseNames[60],
HouseCost,
HouseOwner[24],
Float:PickupX,
Float:PickupY,
Float:PickupZ,
Float:TeleX,
Float:TeleY,
Float:TeleZ,
Interior,
HouseSell,
Owned,
Virtual
}
new HouseInfo[MAX_HOUSES][houseinfo];
new HouseCount = -1;
new PickupID[MAX_HOUSES];
new InHouse[MAX_PLAYERS] = -1;
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid) //Pickup callback
{
for(new J; J<MAX_HOUSES; J++) //Loops through all houses
{
if(pickupid == PickupID[J]) //If the pickupid is one of our house ones
{
new str[75];
if(HouseInfo[J][Owned] == 1)
{
format(str, sizeof(str), "~r~Casa Info~n~~g~Dono: ~w~%s", HouseInfo[J][HouseOwner]);
}
if(HouseInfo[J][Owned] == 0)
{
format(str, sizeof(str), "~r~Casa Info~n~~g~Dono: ~w~Sem dono");
SendClientMessage(playerid, 0x67F6F6AA, "Esta casa estб а venda! Use /comprar para comprб-la");
}
new str2[100];
format(str2, sizeof(str2), "~g~Preзo de Compra:~w~ %d ~n~~g~Preзo de Venda:~w~ %d", HouseInfo[J][HouseCost], HouseInfo[J][HouseSell]);
new str3[175];
format(str3, sizeof(str3), "%s~n~%s", str, str2);
GameTextForPlayer(playerid, str3, 3500, 3);
return 1;
}
}
return 1;
}
pawn Код:
if (strcmp("/comprarcasa", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;
new Pname[24]; GetPlayerName(playerid, Pname, 24);
for(new S; S<MAX_HOUSES; S++)
{
if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "Vocк jб tem uma casa!");
}
if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "Vocк nгo tem dinheiro suficiente para comprar esta casa");
if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "Esta casa jб Tem Proprietario");
GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
GameTextForPlayer(playerid, "~r~Casa Comprada", 2000, 3);
HouseInfo[i][Owned] = 1;
GetPlayerName(playerid, Pname, 24);
format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
dini_Set(house, HouseInfo[i][HouseNames], Pname);
return 1;
}
SendClientMessage(playerid, 0xF60000AA, "Vocк nгo estб perto o suficiente de uma casa");
return 1;
}
if (strcmp("/vendercasa", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
new Pname[24]; GetPlayerName(playerid, Pname, 24);
if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "Vocк nгo possui esta casa!");
GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
GameTextForPlayer(playerid, "~r~Casa Vendida!", 2000, 3);
HouseInfo[i][Owned] = 0;
format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
dini_Unset(house, HouseInfo[i][HouseNames]);
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "Vocк nгo estб perto o suficiente de uma casa");
return 1;
}
if (strcmp("/entrarcasa", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
new Pname[24]; GetPlayerName(playerid, Pname, 24);
if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "Vocк nгo possui esta casa!");
SetPlayerPos(playerid, HouseInfo[i][TeleX], HouseInfo[i][TeleY], HouseInfo[i][TeleZ]);
SetPlayerInterior(playerid, HouseInfo[i][Interior]);
InHouse[playerid] = i;
SetPlayerVirtualWorld(playerid, HouseInfo[i][Virtual]);
SendClientMessage(playerid, 0x00C4F6AA, "Vocк Entrou na sua casa");
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "Vocк nгo estб perto o suficiente de uma casa");
return 1;
}
if (strcmp("/saircasa", cmdtext, true, 10) == 0)
{
if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xF60000AA, "Vocк nгo estб em uma casa");
SetPlayerPos(playerid, HouseInfo[InHouse[playerid]][PickupX], HouseInfo[InHouse[playerid]][PickupY], HouseInfo[InHouse[playerid]][PickupZ]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, 0x00C4F6AA, "Voзк saiu da sua casa");
InHouse[playerid] = -1;
return 1;
}
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
pawn Код:
stock CreateHouse(Filename[], Cost, Float:Pickupx, Float:Pickupy, Float:Pickupz, Float:Telex, Float:Teley, Float:Telez, interior, sell)
{
if(!dini_Exists(house))
{
dini_Create(house);
}
HouseCount ++;
new ID = HouseCount; //HouseID
format(HouseInfo[ID][HouseNames], 60, "%s", Filename); //Saves the HouseName into a variable
HouseInfo[ID][HouseCost] = Cost;
HouseInfo[ID][PickupX] = Pickupx;
HouseInfo[ID][Virtual] = 2000000 + ID;
HouseInfo[ID][PickupY] = Pickupy;
HouseInfo[ID][PickupZ] = Pickupz;
HouseInfo[ID][TeleX] = Telex;
HouseInfo[ID][TeleY] = Teley;
HouseInfo[ID][TeleZ] = Telez;
HouseInfo[ID][Interior] = interior;
HouseInfo[ID][HouseSell] = sell;
format(HouseInfo[ID][HouseOwner], 24, "gj9043jg-er((23");
if(strlen(dini_Get(house, Filename))) //This is to see if there is any owner.
{
format(HouseInfo[ID][HouseOwner], 24, "%s", dini_Get(house, Filename));
HouseInfo[ID][Owned] = 1;
}
PickupID[ID] = CreatePickup(1273, 23, Pickupx, Pickupy, Pickupz, -1); //Creates the pickup :).
Create3DTextLabel("House", 0x00A0F6AA, Pickupx, Pickupy, Pickupz + 0.75, 15.0, 0, 1);
}
pawn Код:
CreateHouse("CriandoCasaTeste", 1, 2317.130615, 692.398498, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
Download
pastebin
Multiupload