[Ajuda] comando /criar casa ... :\
#1

Entгo galera, o D_Player me passou esse sistema de casas, eu achei ele mt bom, to estudando ele, mais ele nгo tem nenhum comando de criar casas.

Sistema:
pawn Код:
#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;
}
Dai entгo eu resolvi criar um comando para criar casas, e salva-las, mais estou com muita dificuldade.
Comando :

pawn Код:
command(criarcasa, playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Vocк nгo й um admin");
   
    new
        Float: Pos[3],
        A, B, id, Int,
        car, price, cor[2],
        Str[120]
    ;
   
    A = GetPlayerInterior(playerid);
    B = GetPlayerVirtualWorld(playerid);
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   
    if (sscanf(params, "iiiii", id, Int, car, cor, 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][hIntDentro] = Int;
    hCasaInfo[id][hVWFora] =  B;    hCasaInfo[id][hVehModelo] = car;

    hCasaInfo[id][hVecX] = Pos[0];  hCasaInfo[id][hVecor][0] = cor[0];
    hCasaInfo[id][hVecY] = Pos[1];  hCasaInfo[id][hVecor][1] = cor[1];
    hCasaInfo[id][hVecZ] = Pos[2];

    PutPlayerInVehicle(playerid, car, 0);
    hCasaInfo[id][hTemDono] = false;

    format(Str, sizeof(Str),
    "Vocк criou a casa de id %d. Interior: %d Carro: %d cor %d, cor2 %d, Preзo: %d", id, Int, car, cor[0], cor[1], price);
    SendClientMessage(playerid, -1, Str);
   
    for(new i = 0; i < MAX_CASAS; i++)
    {
        AtualizarCasas(i, true);
        SalvarCasa(id);
        DOF2_SaveFile();
    }
    return 1;
}
O Comando compila sem erros, e atй funciona em parte, mais depois n funciona. E a casa nгo й salva !
Aqui a stock de salvamento :

pawn Код:
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_SetInt(fstring, "carroCor1", hCasaInfo[casaid][hVecor][0]);
    DOF2_SetInt(fstring, "carroCor2", hCasaInfo[casaid][hVecor][1]);
   
    DOF2_SaveFile();
    return 1;
}
galera n sei mais oq fazer. ta ai o vнdeo que eu gravei :
https://www.youtube.com/watch?v=9TcI0naxrJY
Reply
#2

Tentar colocar pra executar a CallBack.
Reply
#3

Como ?
Reply
#4

й, desisto.
Reply
#5

Essa coordenada "loucona" que vocк vai й a posiзгo 0, 0, 0.

Nгo desista antes mesmo de comeзar, vocк nгo estб setando a posiзгo/interior da casa em momento algum!

Esse sistema do dPlayer й a base da base, nгo й um sistema pronto nem nada.
Reply
#6

Se esse sistema й a base da base entгo eu tф fudido, nunca vou fazer nada aff.
Reply
#7

Nгo pensa assim broh! Se vocк tiver determinaзгo, vocк irб conseguir fazer muito mais que isso, mбs ouзa o conselho das outras pessoas no seu tуpico anterior: estude programaзгo e depois tente fazer sistemas mais complexo como esse. Pra quem estб comeзando em programaзгo, um sistema desses й um grande desafio, talvez um passo maior do que a perna.
Reply
#8

Dб uma estudada no meu sistemas de casas (retirado do gamemode Moro Logo Alн 6.0)


/casa -> vocк cria uma casa
/comprar -> vocк compra


Ps: Casa casa й possнvel salvar 2 carros pessoais, salvando atй tuning.

Crйditos Eo.



http://pastebin.com/z9Vi13VD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)