Cara eu jб tenho um certo conhecimento em pawn, mais ainda nгo sei como se faz sistemas de casas ! sу queria uma base, sу isso. nem preciso de cуdigos, mais sim de uma explicaзгo
|
format(arquivo, sizeof arquivo,"Exemplo%d.ini",0);
#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;
}
CreateDynamicMapIcon
CreateDynamicPickup
command(criarcasa, playerid, params[])
{
if(sscanf(params,"iii", interior, price, car)) return SendClientMessage(playerid,-1, "/criarcasa interior, preзo, carro");
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
CreatePickup(1273, 1, Pos[0], Pos[1], Pos[2], 0);
hCasaInfo[casaid][hVehModelo] = car;
hCasaInfo[casaid][hPrecoCasa] = price;
hCasaInfo[casaid][hEnterX] = Pos[0];
hCasaInfo[casaid][hEnterY] = Pos[1];
hCasaInfo[casaid][hEnterZ] = Pos[2];
return 1;
}
command(criarcasa, playerid, params[])
{
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Vocк nгo й um admin");
new Float: Pos[3]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
new A, B; A = GetPlayerInterior(playerid); B = GetPlayerVirtualWorld(playerid);
new id, Int, car, price; new Str[120];
if (sscanf(params, "iiii", id, Int, car, price)) return SendClientMessage(playerid, -1, "/criarcasa id, interior, carro, preзo");
hCasaInfo[id][hPrecoCasa] = price;
hCasaInfo[id][hEnterX] = Pos[0];
hCasaInfo[id][hEnterY] = Pos[1];
hCasaInfo[id][hEnterZ] = Pos[2];
hCasaInfo[id][hIntFora] = A;
hCasaInfo[id][hVWFora] = B;
hCasaInfo[id][hIntDentro] = Int;
hCasaInfo[id][hVehModelo] = car;
hCasaInfo[id][hTemDono] = false;
format(Str, sizeof(Str),
"Vocк criou a casa de id %d. Interior: %d Carro: %d, Preзo: %d", id, Int, car, price);
SendClientMessage(playerid, -1, Str);
SalvarCasa(id);
DOF2_SaveFile();
for(new i = 0; i < MAX_CASAS; i++)
{
AtualizarCasas(i, true);
}
return 1;
}