[Ajuda] Dб pra comprar casa jб comprada
#1

O que tem de errado aqui que quando um player compra aparece ele como dono e tudo,mais mesmo assim outra pessoa pode chegar e comprar

Quote:

case 1:
{
format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
new hprice; hprice = dini_Int(hfile, "Price");
new howner[256]; howner = dini_Get(hfile, "Owner");
new hname[256]; hname = dini_Get(hfile, "Name");
if(GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You do not have enough money to purchase\nthis house!", "Ok", "");
if(strfind(howner, nigname, true) != -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You already own this house!", "Ok", "");
dini_Set(hfile, "Owner", pName(playerid));
GivePlayerMoney(playerid, -hprice);
PlayerPlaySound(playerid, 1058, 0, 0, 0);
PlayerPlaySound(playerid, 1149, 0, 0, 0);
ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You have successfully purchased this house!", "", "Exit");
#if HMESSAGES == 1
new str[128];
format(str, sizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!", pName(playerid), hname, GetEntID(playerid), hprice);
SendClientMessageToAll(COLOR_BLUE, str);
#endif

Reply
#2

Adicione uma variбvel ao salvamento das casa exemplo

pawn Код:
new bool: CasaComprada[MAX_CASAS];


CMD:comprarcasa(playerid, params[])
{
    //blablabla do codigo
    CasaComprada[casaid] = true;
    return 1;
}
CMD:vendercasa(playerid)
{
    //blablabla do codigo
    CasaComprada[casaid] = false;
    return 1;
}
CMD:comprarcasa(playerid)
{
    //blablabla do codigo
    if(CasaComprada[casaid] == true) return SendClientMessage(playerid, -1, "Vocк nгo pode comprar uma casa jб comprada!");
    return 1;
}
Reply
#3

Desculpa minha lerdeza .-.
Se tiver algo errado me explique plz.

Seria assim entгo que ia ficar
Porque se for ta dando errado,fala vocк nгo pode comprar casa jб comprada mais mesmo assim ainda compra.

new bool: CasaComprada[MAX_HOUSES];

/comprarcasa
Quote:

new casaid;
format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
new hprice; hprice = dini_Int(hfile, "Price");
new howner[256]; howner = dini_Get(hfile, "Owner");
new hname[256]; hname = dini_Get(hfile, "Name");

if(GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You do not have enough money to purchase\nthis house!", "Ok", "");
if(strfind(howner, nigname, true) != -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You already own this house!", "Ok", "");
dini_Set(hfile, "Owner", pName(playerid));
GivePlayerMoney(playerid, -hprice);
PlayerPlaySound(playerid, 1058, 0, 0, 0);
PlayerPlaySound(playerid, 1149, 0, 0, 0);
ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You have successfully purchased this house!", "", "Exit");
#if HMESSAGES == 1
new str[128];
format(str, sizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!", pName(playerid), hname, GetEntID(playerid), hprice);

CasaComprada[casaid] = true;

SendClientMessageToAll(COLOR_BLUE, str);
if(CasaComprada[casaid] == true) return SendClientMessage(playerid, -1, "Vocк nгo pode comprar uma casa jб comprada!");
#endif

/vendercasa
Quote:

new casaid;
format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
new howner[256]; howner = dini_Get(hfile, "Owner");
new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
if(strfind(howner, nigname, true) == -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Options", "You are not the owner of this house!", "Ok", "");
if(strfind(inputtext,"Yes",true) == 0)
{
new hprice; hprice = dini_Int(hfile, "Price");
new hname[256]; hname = dini_Get(hfile, "Name");
dini_Set(hfile, "Owner", "None");
GivePlayerMoney(playerid, hprice);
#if HMESSAGES == 1
new str[128];
format(str, sizeof(str), "%s sold the House '%s' [ID:%d] [Price: %d]!", pName(playerid), hname, GetEntID(playerid), hprice);
SendClientMessageToAll(COLOR_BLUE, str);
CasaComprada[casaid] = false;
return 1;
#endif
}
else if(strfind(inputtext,"No",true) == 0)
{
SendClientMessage(playerid, COLOR_RED, "You decided not to sell your house...");
}
}
return 1;
}

Reply
#4

Quote:

if(GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You do not have enough money to purchase\nthis house!", "Ok", "");
if(strfind(howner, nigname, true) != -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You already own this house!", "Ok", "");
dini_Set(hfile, "Owner", pName(playerid));
GivePlayerMoney(playerid, -hprice);
PlayerPlaySound(playerid, 1058, 0, 0, 0);
PlayerPlaySound(playerid, 1149, 0, 0, 0);
ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You have successfully purchased this house!", "", "Exit");
#if HMESSAGES == 1
new str[128];
format(str, sizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!", pName(playerid), hname, GetEntID(playerid), hprice);

CasaComprada[casaid] = true;

SendClientMessageToAll(COLOR_BLUE, str);
if(CasaComprada[GetEntID(playerid)] == true) return SendClientMessage(playerid, -1, "Vocк nгo pode comprar uma casa jб comprada!");
#endif

Voce esta verificando se a casa ja esta comprada depois de setar o nome do player como dono da casa

PHP код:
if(GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You do not have enough money to purchase\nthis house!""Ok""");
if(
strfind(hownernignametrue) != -1) return ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You already own this house!""Ok""");
if(
CasaComprada[GetEntID(playerid)] == true) return SendClientMessage(playerid, -1"Vocк nгo pode comprar uma casa jб comprada!");
dini_Set(hfile"Owner"pName(playerid));
GivePlayerMoney(playerid, -hprice);
PlayerPlaySound(playerid1058000);
PlayerPlaySound(playerid1149000);
CasaComprada[GetEntID(playerid)] = true;
ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You have successfully purchased this house!""""Exit");
#if HMESSAGES == 1
new str[128];
format(strsizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!"pName(playerid), hnameGetEntID(playerid), hprice);
SendClientMessageToAll(COLOR_BLUEstr);
#endif 
Reply
#5

Nгo deu,ainda ta do mesmo jeito
Reply
#6

PHP код:
#define MAX_CASAS 10
new bool:CasaComprada[MAX_CASAS]; 
comprar casa
PHP код:
case 1:
{
    
format(hfilesizeof(hfile), "/Houses/%d.ini"GetEntID(playerid));
    new 
nigname[MAX_PLAYER_NAME]; nigname pName(playerid);
    new 
hpricehprice dini_Int(hfile"Price");
    new 
howner[256]; howner dini_Get(hfile"Owner");
    new 
hname[256]; hname dini_Get(hfile"Name");
    if(
GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You do not have enough money to purchase\nthis house!""Ok""");
    if(
strcmp(hownernignametrue) == 0) return ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You already own this house!""Ok""");
    if(
CasaComprada[GetEntID(playerid)] == true)
    {
        
SendClientMessage(playerid, -1"Vocк nгo pode comprar uma casa jб comprada!");
        return 
true;
    }
    else
    {
        
dini_Set(hfile"Owner"pName(playerid));
        
CasaComprada[GetEntID(playerid)] = true;
        
GivePlayerMoney(playerid, -hprice);
        
PlayerPlaySound(playerid1058000);
        
PlayerPlaySound(playerid1149000);
        
ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Purchase""You have successfully purchased this house!""""Exit");
        if(
HMESSAGES == 1){
            new 
str[128];
            
format(strsizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!"pName(playerid), hnameGetEntID(playerid), hprice);
            
SendClientMessageToAll(COLOR_BLUEstr);
        }
    }
    return 
true;

vendercasa
PHP код:
 format(hfilesizeof(hfile), "/Houses/%d.ini"GetEntID(playerid));
new 
howner[MAX_PLAYER_NAME]; howner dini_Get(hfile"Owner");
new 
nigname[MAX_PLAYER_NAME]; nigname pName(playerid);
if(
strcmp(hownernignametrue) != 0) return ShowPlayerDialog(playeridDABOX-1DIALOG_STYLE_MSGBOX"House - Options""You are not the owner of this house!""Ok""");
if(
strcmp(inputtext,"Yes"true) == 0)
{
    new 
hpricehprice dini_Int(hfile"Price");
    new 
hname[256]; hname dini_Get(hfile"Name");
    
dini_Set(hfile"Owner""None");
    
GivePlayerMoney(playeridhprice);
    
CasaComprada[GetEntID(playerid)] = false;
    if(
HMESSAGES == 1){
        new 
str[128];
        
format(strsizeof(str), "%s sold the House '%s' [ID:%d] [Price: %d]!"pName(playerid), hnameGetEntID(playerid), hprice);
        
SendClientMessageToAll(COLOR_BLUEstr);
    }
    return 
1;
}
else if(
strcmp(inputtext,"No"true) == 0)
{
    
SendClientMessage(playeridCOLOR_RED"You decided not to sell your house...");

se continuar o erro posta o GetEntID(playerid)
Reply
#7

Quote:

C:\Users\AL-K-WK\Documents\x\Samp\BDL\filterscripts\casas.pwn(61 6) : warning 217: loose indentation
C:\Users\AL-K-WK\Documents\x\Samp\BDL\filterscripts\casas.pwn(63 5) : warning 206: redundant test: constant expression is non-zero
C:\Users\AL-K-WK\Documents\x\Samp\BDL\filterscripts\casas.pwn(80 6) : warning 217: loose indentation
C:\Users\AL-K-WK\Documents\x\Samp\BDL\filterscripts\casas.pwn(80 6) : error 047: array sizes do not match, or destination array is too small
C:\Users\AL-K-WK\Documents\x\Samp\BDL\filterscripts\casas.pwn(81 6) : warning 206: redundant test: constant expression is non-zero
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

.
.
Reply
#8

modifica o MAX_CASAS para o valor de casas que tem no teu servidor e o loose identation eh so ver o q n ta alinhado tipo o format do vendercasa ta com um espaзo antes й sу tirar '-'
e mostra quais as linhas do erro senгo nгo tem como saber quais sгo
Reply
#9

Sim jб fiz,o erro da nessa linha:
Quote:

new howner[MAX_PLAYER_NAME]; howner = dini_Get(hfile, "Owner");

Reply
#10

osh mas Owner era pra ser o nome do dono da casa nгo era?? logo o valor mбximo de armazenamento seria 24 q eh o MAX_PLAYER_NAME O.o
mas entгo sу trocar pelo q jб tava antes
PHP код:
new howner[MAX_PLAYER_NAME]; 
troca por
PHP код:
new howner[256]; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)