Originally Posted by GSantana
Crie a pasta Casas na scriptfiles e crie a pasta Interiores na pasta Interiores ira conta a localizaзгo x, y, z das casas, faзa exatamente desta maneira senгo nгo ira funcionar
crie o arquivo 1.txt, 2.txt, 3.txt e nesses arquivos adicione isso:
X = 271.884979
y = 306.631988
z = 999.148437
mundo = 2
lembrando, mude x, y, z e interior para interiores que vc quiser adicionar Code:
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dof2>
#define MAX_CASAS 500 //troque pelo maximo de casas que quer que tenha em seu server
#define INFOA 0xFFFF00FF
new Text3D:Ctexto[MAX_CASAS]; //texto com as informaзхes da casa
new piCasa[MAX_CASAS]; //pickup da casa
enum pCasa
{
Float:pCasaX,
Float:pCasaY,
Float:pCasaZ,
pCasaNivel
};
new CasaInfo[MAX_CASAS][pCasa];
public OnGameModeInit()
{
new String[50],
INFOC[80];
for(new i = 0; i < MAX_CASAS; i++)
{
format(String, sizeof(String), "Casas/Casa %d.txt", i);
if(DOF2_FileExists(String))
{
if(DOF2_GetInt(String, "tDono") == 1)
{
format(INFOC, sizeof(INFOC), "{87CEFA}Dono: {FFFF00}%s\n{87CEFA}Nivel: {FFFF00}%d \n Id: %d \n%s", DOF2_GetString(String, "Dono"), DOF2_GetInt(String, "Nivel"), DOF2_GetInt(String, "Id"), DOF2_GetString(String, "Comprar"));
}
else{
format(INFOC, sizeof(INFOC), "{87CEFA}Dono: {FFFF00}%s\n{87CEFA}Preзo: {FFFF00}%d\n{87CEFA}Nivel: {FFFF00}%d\n Id: %d \n\n{87CEFA}Use:{FFFFFF} /comprarcasa", DOF2_GetString(String, "Dono"), DOF2_GetInt(String, "Preco"), DOF2_GetInt(String, "Nivel"), DOF2_GetInt(String, "Id"));
}
Ctexto[i] = Create3DTextLabel(INFOC, -1, DOF2_GetFloat(String, "PX"), DOF2_GetFloat(String, "PY"), DOF2_GetFloat(String, "PZ"), 50.0, 0, 0);
piCasa[i] = CreatePickup(DOF2_GetInt(String, "PickU"), 1, DOF2_GetFloat(String, "PX"), DOF2_GetFloat(String, "PY"), DOF2_GetFloat(String, "PZ"));
}
else { break; }
}
return 1;
}
CMD:criarcasa(playerid, params[])
{
new precoc, interior, Float:pX, Float:pY, Float:pZ, String[40];
if(sscanf(params,"dd",precoc,interior)) return SendClientMessage(playerid, -1, "[ERRO] Comando incorreto! Use: /criarcasa [preзo] [interior]");
GetPlayerPos(playerid, pX, pY, pZ);
format(String, sizeof(String), "Interiores/%d.txt",interior);
CriarCasa(playerid, precoc, DOF2_GetInt(String, "mundo"), Float:pX, Float:pY, Float:pZ, DOF2_GetFloat(String, "x"), DOF2_GetFloat(String, "y"), DOF2_GetFloat(String, "z"));
return 1;
}
stock CriarCasa(playerid, preco, iInt, Float:CX, Float:CY, Float:CZ, Float:ICasaX, Float:ICasaY, Float:ICasaZ)
{
new String[150], INFOC[130];
for(new i = 0; i < MAX_CASAS; i++)
{
format(String, sizeof(String), "Casas/Casa %d.txt", i);
if(!DOF2_FileExists(String))
{
DOF2_CreateFile(String);
DOF2_SetInt(String, "Id", i);
DOF2_SetInt(String, "Preco", preco);
DOF2_SetInt(String, "Nivel", 0);
DOF2_SetInt(String, "Mundo", iInt);
DOF2_SetInt(String, "PickU", 1273);
DOF2_SetInt(String, "tDono", 0);
DOF2_SetInt(String, "Trancada", 0);
DOF2_SetFloat(String, "IX", ICasaX);
DOF2_SetFloat(String, "IY", ICasaY);
DOF2_SetFloat(String, "IZ", ICasaZ);
DOF2_SetFloat(String, "PX", CX);
DOF2_SetFloat(String, "PY", CY);
DOF2_SetFloat(String, "PZ", CZ);
DOF2_SetString(String, "Dono", "Ninguem");
DOF2_SetString(String, "Comprar", "/comprarcasa");
DOF2_SaveFile();
format(INFOC, sizeof(INFOC), "{87CEFA}Dono: {FFFF00}%s\n{87CEFA}Preзo: {FFFF00}%d\n{87CEFA}Nivel: {FFFF00}%d\n\n{87CEFA}Use:{FFFFFF} /comprarcasa", DOF2_GetString(String, "Dono"), DOF2_GetInt(String, "Preco"), DOF2_GetInt(String, "Nivel"));
Ctexto[i] = Create3DTextLabel(INFOC, -1, CX, CY, CZ, 50.0, 0, 0);
piCasa[i] = CreatePickup(DOF2_GetInt(String, "PickU"), 1, CX, CY, CZ);
SendClientMessage(playerid, INFOA, "[SERVER] Vocк criou uma casa!");
break;
}
}
return 1;
}
CMD:comprarcasa(playerid)
{
new String[50], aname[MAX_PLAYER_NAME], INFOC[150];
GetPlayerName(playerid, aname, sizeof(aname));
for(new i = 0; i < MAX_CASAS; i++)
{
format(String, sizeof(String), "Casas/Casa %d.txt", i);
if(DOF2_GetInt(String, "tDono") == 1) { SendClientMessage(playerid, INFOA, "Estб casa jб possui dono!"); } else {
if(DOF2_FileExists(String))
{
CasaInfo[i][pCasaX] = DOF2_GetFloat(String, "PX");
CasaInfo[i][pCasaY] = DOF2_GetFloat(String, "PY");
CasaInfo[i][pCasaZ] = DOF2_GetFloat(String, "PZ");
if(IsPlayerInRangeOfPoint(playerid, 2.0, CasaInfo[i][pCasaX], CasaInfo[i][pCasaY], CasaInfo[i][pCasaZ]))
{
if(GetPlayerMoney(playerid) >= DOF2_GetInt(String, "Preco"))
{
GivePlayerMoney(playerid, -DOF2_GetInt(String, "Preco"));
DOF2_SetString(String, "Dono", aname);
DOF2_SetInt(String, "PickU", 1272);
DOF2_SetInt(String, "tDono", 1);
DOF2_SetString(String, "Comprar", "/entrarcasa");
DOF2_SaveFile();
format(INFOC, sizeof(INFOC), "{87CEFA}Dono: {FFFF00}%s\n{87CEFA}Nivel: {FFFF00}%d \n {87CEFA}Id: {FFFF00}%d \n{FFFF00}%s", DOF2_GetString(String, "Dono"), DOF2_GetInt(String, "Nivel"), DOF2_GetInt(String, "Id"), DOF2_GetString(String, "Comprar"));
Update3DTextLabelText(Ctexto[i], -1, INFOC);
DestroyPickup(piCasa[i]);
piCasa[i] = CreatePickup(DOF2_GetInt(String, "PickU"), 1, DOF2_GetFloat(String, "PX"), DOF2_GetFloat(String, "PY"), DOF2_GetFloat(String, "PZ"));
}
}
}
else { break; }
}
}
return 1;
}
CMD:entrarcasa(playerid)
{
new String[80];
for(new i = 0; i < MAX_CASAS; i++)
{
format(String, sizeof(String), "Casas/Casa %d.txt", i);
if(DOF2_FileExists(String))
{
if(DOF2_GetInt(String, "Tracanda") == 1)
{
SendClientMessage(playerid, INFOA, "[SERVER] Estб casa estб trancada");
}
else
{
SetPlayerPos(playerid, DOF2_GetFloat(String, "IX"), DOF2_GetFloat(String, "IY"), DOF2_GetFloat(String, "IZ"));
SetPlayerInterior(playerid, DOF2_GetInt(String, "Mundo"));
}
}
else
{
break;
}
}
return 1;
}
|