Daqui a pouco eu dou edit aqui de uma base q eu e um colega fizemos anos atrбs.
pawn Code:
#include <a_samp>
#include <DOF2>
#include <zcmd>
#include <sscanf>
#include <streamer>
#define MAX_CASAS 200
#define PASTA_CASA "Casas/%d.ini"
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_RED 0xFF0000AA
#define COLOR_GREEN 0x00FF00AA
enum hInfo
{
Float:hEnterX,
Float:hEnterY,
Float:hEnterZ,
Float:hExitX,
Float:hExitY,
Float:hExitZ,
hIntDentro,
hVWDentro,
hIntFora,
hVWFora,
bool:hTemDono,
hDonoCasa[MAX_PLAYER_NAME],
hPrecoCasa,
hPickup,
hIconeC,
hVehModelo,
Float:hVecX,
Float:hVecY,
Float:hVecZ,
Float:hVecA
};
new hCasaInfo[MAX_CASAS][hInfo];
new hCasaCarro[MAX_CASAS];
public OnFilterScriptInit()
{
SetTimer("AtaulizarStatusCasa", 1000, true);
return 1;
}
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
CMD:comprarcasa(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
for(new i = 0; i < MAX_CASAS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, hCasaInfo[i][hEnterX], hCasaInfo[i][hEnterY], hCasaInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == hCasaInfo[i][hIntFora] && GetPlayerVirtualWorld(playerid) == hCasaInfo[i][hVWFora]) //Is player near house entrance, and if player is in interior of that house + virtual world (Last time I said this too!)
{
if(hCasaInfo[i][hTemDono]) return SendClientMessage(playerid, COLOR_RED, "( Info ) Esta casa jб possui um propietбrio.");
if(GetPlayerMoney(playerid) < hCasaInfo[i][hPrecoCasa]) return SendClientMessage(playerid, COLOR_RED, "( Info ) Vocк nгo tem dinheiro suficiente para comprar esta casa.");
hCasaInfo[i][hTemDono] = true;
strmid(hCasaInfo[i][hDonoCasa], pName, 0, false, strlen(pName));
GivePlayerMoney(playerid, -hCasaInfo[i][hPrecoCasa]);
SendClientMessage(playerid, COLOR_GREEN, "( Info ) Esta casa agora pertence a vocк.");
SalvarCasa(i);
AtualizarCasas(i, true);
DOF2_SaveFile();
return 1;
}
}
return 1;
}
CMD:vendercasa(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
for(new i = 0; i < MAX_CASAS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, hCasaInfo[i][hEnterX], hCasaInfo[i][hEnterY], hCasaInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == hCasaInfo[i][hIntFora] && GetPlayerVirtualWorld(playerid) == hCasaInfo[i][hVWFora])
{
if(!strcmp(hCasaInfo[i][hDonoCasa], pName, false))
{
strmid(hCasaInfo[i][hDonoCasa], "SemDono", 0, false, 8);
hCasaInfo[i][hTemDono] = false;
GivePlayerMoney(playerid, hCasaInfo[i][hPrecoCasa] / 2);
SendClientMessage(playerid, COLOR_GREEN, "( Info ) Casa vendida com sucesso!");
SalvarCasa(i);
AtualizarCasas(i, true);
DOF2_SaveFile();
return 1;
}
}
}
return 1;
}
stock CarregarCasa(casaid)
{
new fstring[10];
format(fstring, 10, PASTA_CASA, casaid);
if(!DOF2_FileExists(fstring)) return 0;
hCasaInfo[casaid][hEnterX] = DOF2_GetFloat(fstring, "EntradaX");
hCasaInfo[casaid][hEnterY] = DOF2_GetFloat(fstring, "EntradaY");
hCasaInfo[casaid][hEnterZ] = DOF2_GetFloat(fstring, "EntradaZ");
hCasaInfo[casaid][hExitX] = DOF2_GetFloat(fstring, "SaidaX");
hCasaInfo[casaid][hExitY] = DOF2_GetFloat(fstring, "SaidaY");
hCasaInfo[casaid][hExitZ] = DOF2_GetFloat(fstring, "SaidaZ");
hCasaInfo[casaid][hIntDentro] = DOF2_GetInt(fstring, "InteriorDentro");
hCasaInfo[casaid][hVWDentro] = DOF2_GetInt(fstring, "InteriorDentro2");
hCasaInfo[casaid][hIntFora] = DOF2_GetInt(fstring, "InteirorForar");
hCasaInfo[casaid][hVWFora] = DOF2_GetInt(fstring, "InteriorFora2");
hCasaInfo[casaid][hTemDono] = DOF2_GetBool(fstring, "TemDono") ? true : false;
strmid(hCasaInfo[casaid][hDonoCasa], DOF2_GetString(fstring, "Propietario"), 0, false, strlen(DOF2_GetString("Propietario")));
hCasaInfo[casaid][hPrecoCasa] = DOF2_GetInt(fstring, "ValorCasa");
hCasaInfo[casaid][hVehModelo] = DOF2_GetInt(fstring, "VeiculoModelo");
hCasaInfo[casaid][hVecX] = DOF2_GetFloat(fstring, "HV_PosX");
hCasaInfo[casaid][hVecY] = DOF2_GetFloat(fstring, "HV_PosZ");
hCasaInfo[casaid][hVecZ] = DOF2_GetFloat(fstring, "HV_PosZ");
hCasaInfo[casaid][hVecA] = DOF2_GetFloat(fstring, "HV_PosA");
DOF2_SaveFile();
return 1;
}
stock AtualizarCasas(casaid, bool:reload = false)
{
if(reload)
{
DestroyDynamicMapIcon(hCasaInfo[casaid][hIconeC]);
DestroyDynamicPickup(hCasaInfo[casaid][hPickup]);
DestroyVehicle(hCasaCarro[casaid]);
}
if(!hCasaInfo[casaid][hTemDono])
{
hCasaInfo[casaid][hIconeC] = CreateDynamicMapIcon(hCasaInfo[casaid][hEnterX], hCasaInfo[casaid][hEnterY], hCasaInfo[casaid][hEnterZ], 31, 0, hCasaInfo[casaid][hVWFora], hCasaInfo[casaid][hIntFora]);
hCasaInfo[casaid][hPickup] = CreateDynamicPickup(1273, 1, hCasaInfo[casaid][hEnterX], hCasaInfo[casaid][hEnterY], hCasaInfo[casaid][hEnterZ], hCasaInfo[casaid][hVWFora], hCasaInfo[casaid][hIntFora]);
}
else
{
hCasaInfo[casaid][hIconeC] = CreateDynamicMapIcon(hCasaInfo[casaid][hEnterX], hCasaInfo[casaid][hEnterY], hCasaInfo[casaid][hEnterZ], 31, 0, hCasaInfo[casaid][hVWFora], hCasaInfo[casaid][hIntFora]);
hCasaInfo[casaid][hPickup] = CreateDynamicPickup(1273, 1, hCasaInfo[casaid][hEnterX], hCasaInfo[casaid][hEnterY], hCasaInfo[casaid][hEnterZ], hCasaInfo[casaid][hVWFora], hCasaInfo[casaid][hIntFora]);
}
if(IsValidVehicleModel(hCasaInfo[casaid][hVehModelo]))
hCasaCarro[casaid] = CreateVehicle(hCasaInfo[casaid][hVehModelo], hCasaInfo[casaid][hVecX], hCasaInfo[casaid][hVecY], hCasaInfo[casaid][hVecZ], hCasaInfo[casaid][hVecA], -1, -1, -1);
return 0;
}
stock IsValidVehicleModel(vehiclemodel)
{
if(vehiclemodel >= 400 && vehiclemodel <= 611)
return true;
return false;
}
stock SalvarCasa(casaid)
{
new fstring[10];
format(fstring, 10, PASTA_CASA, casaid);
DOF2_SetFloat(fstring, "EntradaX", hCasaInfo[casaid][hEnterX]);
DOF2_SetFloat(fstring, "EntradaY", hCasaInfo[casaid][hEnterY]);
DOF2_SetFloat(fstring, "EntradaZ", hCasaInfo[casaid][hEnterZ]);
DOF2_SetFloat(fstring, "SaidaX", hCasaInfo[casaid][hExitX]);
DOF2_SetFloat(fstring, "SaidaY", hCasaInfo[casaid][hExitY]);
DOF2_SetFloat(fstring, "SaidaZ", hCasaInfo[casaid][hExitZ]);
DOF2_SetInt(fstring, "InteriorDentro", hCasaInfo[casaid][hIntDentro]);
DOF2_SetInt(fstring, "InteriorDentro2", hCasaInfo[casaid][hVWDentro]);
DOF2_SetInt(fstring, "InteriorFora", hCasaInfo[casaid][hIntFora]);
DOF2_SetInt(fstring, "InteriorFora2", hCasaInfo[casaid][hVWFora]);
DOF2_SetBool(fstring, "TemDono", hCasaInfo[casaid][hTemDono]);
DOF2_SetInt(fstring, "Propietario", hCasaInfo[casaid][hDonoCasa]);
DOF2_SetInt(fstring, "ValorCasa", hCasaInfo[casaid][hPrecoCasa]);
DOF2_SetInt(fstring, "VeiculoModelo", hCasaInfo[casaid][hVehModelo]);
DOF2_SetFloat(fstring, "HV_PosX", hCasaInfo[casaid][hVecX]);
DOF2_SetFloat(fstring, "HV_PosY", hCasaInfo[casaid][hVecY]);
DOF2_SetFloat(fstring, "HV_PosZ", hCasaInfo[casaid][hVecZ]);
DOF2_SetFloat(fstring, "HV_PosA", hCasaInfo[casaid][hVecA]);
DOF2_SaveFile();
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & 16 && !IsPlayerInAnyVehicle(playerid))
{
for(new i = 0; i < MAX_CASAS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, hCasaInfo[i][hEnterX], hCasaInfo[i][hEnterY], hCasaInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == hCasaInfo[i][hIntFora] && GetPlayerVirtualWorld(playerid) == hCasaInfo[i][hVWFora])
{
SetPlayerPos(playerid, hCasaInfo[i][hExitX], hCasaInfo[i][hExitY], hCasaInfo[i][hExitZ]);
SetPlayerInterior(playerid, hCasaInfo[i][hIntDentro]);
SetPlayerVirtualWorld(playerid, hCasaInfo[i][hVWDentro]);
}
else if(IsPlayerInRangeOfPoint(playerid, 1.5, hCasaInfo[i][hExitX], hCasaInfo[i][hExitY], hCasaInfo[i][hExitZ]) && GetPlayerInterior(playerid) == hCasaInfo[i][hIntDentro] && GetPlayerVirtualWorld(playerid) == hCasaInfo[i][hVWDentro])
{
SetPlayerPos(playerid, hCasaInfo[i][hEnterX], hCasaInfo[i][hEnterY], hCasaInfo[i][hEnterZ]);
SetPlayerInterior(playerid, hCasaInfo[i][hIntFora]);
SetPlayerVirtualWorld(playerid, hCasaInfo[i][hVWFora]);
}
}
}
return 1;
}
forward AtaulizarStatusCasa();
public AtaulizarStatusCasa()
{
new str[100];
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new j = 0; j < MAX_CASAS; j++)
{
//if(IsPlayerInRangeOfPoint(j, hCasaInfo[j][hEnterX], hCasaInfo[j][hEnterY], hCasaInfo[j][hEnterZ]) && GetPlayerInterior(i) == hCasaInfo[j][hIntFora] && GetPlayerVirtualWorld(i) == hCasaInfo[j][hVWFora])
if(IsPlayerInRangeOfPoint(j, 1.5, hCasaInfo[j][hEnterX], hCasaInfo[j][hEnterY], hCasaInfo[j][hEnterZ]) && GetPlayerInterior(i) == hCasaInfo[j][hIntFora] && GetPlayerVirtualWorld(i) == hCasaInfo[j][hVWFora])
{
if(hCasaInfo[j][hTemDono])
format(str, 100, "~w~Propietario ~w~: ~r~%s", hCasaInfo[j][hDonoCasa]);
else
format(str, 100, "~w~Casa a venda ~n~ Preco: ~g~$%d,-", hCasaInfo[j][hPrecoCasa]);
GameTextForPlayer(i, str, 2000, 3);
}
}
}
return 1;
}