Problema. -
arturo clark - 31.05.2011
Estoy haciendo un sistema de casas, pero hay problema:
http://s3.subirimagenes.com:81/priva...088samp020.png
Sale ese mensaje en rojo como error al comprar la casa (como pueden ya habнa comprado la casa).
Tambiйn cuando la vendo.
Edit: Mm, veo que la imagen esta un poco pequeсa, asн que aquн les dejo el mensaje:
"
You have successfully purchased a new house"
"
PCash: -10000"
"
You already own a house"
pawn Код:
dcmd_buyhouse(playerid, params[])
{
#pragma unused params
for(new houseid = 0; houseid < MAX_HOUSES; houseid++)
{
new str[128], pName[20], file[128];
GetPlayerName(playerid, pName, 20);
format(file, sizeof(file), "/Users/%s.ini", pName);
if(dini_Int(file, "HouseOwner") == 1) return SendClientMessage(playerid, COLOR_RED," » You aleady own a house");
else if(dini_Int(HFile(houseid), "Owned") == 1) return SendClientMessage(playerid, COLOR_RED," » This house is already owned");
else if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ])) return SendClientMessage(playerid, COLOR_RED," » You are not near a house icon");
else if(PlayerInfo[playerid][PCash] < dini_Int(HFile(houseid), "Price")) return SendClientMessage(playerid, COLOR_RED," » You don't have enough money");
else
{
dini_IntSet(file, "HouseOwnedID", houseid);
dini_IntSet(file, "HouseOwner", 1);
dini_FloatSet(file, "HouseX", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterX]);
dini_FloatSet(file, "HouseY", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterY]);
dini_FloatSet(file, "HouseZ", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterZ]);
dini_IntSet(HFile(houseid), "Owned", 1);
dini_Set(HFile(houseid), "Owner", pName);
PlayerInfo[playerid][PCash] -= dini_Int(HFile(houseid), "Price");
SendClientMessage(playerid, COLOR_GREEN," » You have successfully purchased a new house");
format(str, 128," » PCash: -%i", dini_Int(HFile(houseid), "Price"));
SendClientMessage(playerid, COLOR_YELLOW, str);
format(str, 128,"House\r\nOwned by: %s", pName);
Update3DTextLabelText(House3D, -1, str);
}
}
return 1;
}
dcmd_sellhouse(playerid, params[])
{
#pragma unused params
for(new houseid = 0; houseid < MAX_HOUSES; houseid++)
{
new str[128], pName[20], file[128];
GetPlayerName(playerid, pName, 20);
format(file, sizeof(file), "/Users/%s.ini", pName);
if(dini_Int(file, "HouseOwner") != 1) return SendClientMessage(playerid, COLOR_RED," » You don't own a house");
else if(!IsPlayerInRangeOfPoint(playerid, 2.0, dini_Float(file, "HouseX"), dini_Float(file, "HouseY"), dini_Float(file, "HouseZ"))) return SendClientMessage(playerid, COLOR_RED," » You are not near your house");
else
{
dini_IntSet(file, "HouseOwnedID", -1);
dini_IntSet(file, "HouseOwner", 0);
dini_FloatSet(file, "HouseX", 0.0);
dini_FloatSet(file, "HouseY", 0.0);
dini_FloatSet(file, "HouseZ", 0.0);
dini_IntSet(HFile(houseid), "Owned", 0);
dini_Set(HFile(houseid), "Owner", "None");
PlayerInfo[playerid][PCash] += dini_Int(HFile(houseid), "Price")/2;
SendClientMessage(playerid, COLOR_GREEN," » You have successfully sold your house");
format(str, 128," » PCash: +%i", dini_Int(HFile(houseid), "Price")/2);
SendClientMessage(playerid, COLOR_YELLOW, str);
format(str, 128,"House\r\nFor sale\r\nPrice: %i", dini_Int(HFile(houseid), "Price"));
Update3DTextLabelText(House3D, -1, str);
}
}
return 1;
}
Respuesta: Problema. -
Code8976Man - 31.05.2011
Trata de poner que termine el loop al comprar la casa con break; creo.
Re: Problema. -
arturo clark - 01.06.2011
Me podrнas dar un ejemplo, por favor.
Respuesta: Problema. -
Lunnatiicz - 01.06.2011
break
Se utiliza para terminar con un bucle.
Ejemplo:
pawn Код:
for(new i; i<10; i++)if(Array_N[i] == true)break;
Por The Chaoz
Re: Problema. -
arturo clark - 01.06.2011
Mmm, no entiendo.
Re: Problema. -
arturo clark - 02.06.2011
Me podrнan dar un ejemplo, es que en verdad necesito ayuda.
Hice esto:
pawn Код:
if(dini_Int(file, "HouseOwner") == 0) break;
Pero aunque tenga o no tenga no me sale nada porque puso break.
P.D.: Perdуn por el doble-post.
Respuesta: Problema. -
Code8976Man - 02.06.2011
pawn Код:
dcmd_buyhouse(playerid, params[])
{
#pragma unused params
for(new houseid = 0; houseid < MAX_HOUSES; houseid++)
{
new str[128], pName[20], file[128];
GetPlayerName(playerid, pName, 20);
format(file, sizeof(file), "/Users/%s.ini", pName);
if(dini_Int(file, "HouseOwner") == 1) return SendClientMessage(playerid, COLOR_RED," » You aleady own a house");
else if(dini_Int(HFile(houseid), "Owned") == 1) return SendClientMessage(playerid, COLOR_RED," » This house is already owned");
else if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ])) return SendClientMessage(playerid, COLOR_RED," » You are not near a house icon");
else if(PlayerInfo[playerid][PCash] < dini_Int(HFile(houseid), "Price")) return SendClientMessage(playerid, COLOR_RED," » You don't have enough money");
else
{
dini_IntSet(file, "HouseOwnedID", houseid);
dini_IntSet(file, "HouseOwner", 1);
dini_FloatSet(file, "HouseX", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterX]);
dini_FloatSet(file, "HouseY", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterY]);
dini_FloatSet(file, "HouseZ", HouseInfo[dini_Int(file, "HouseOwnedID")][hEnterZ]);
dini_IntSet(HFile(houseid), "Owned", 1);
dini_Set(HFile(houseid), "Owner", pName);
PlayerInfo[playerid][PCash] -= dini_Int(HFile(houseid), "Price");
SendClientMessage(playerid, COLOR_GREEN," » You have successfully purchased a new house");
format(str, 128," » PCash: -%i", dini_Int(HFile(houseid), "Price"));
SendClientMessage(playerid, COLOR_YELLOW, str);
format(str, 128,"House\r\nOwned by: %s", pName);
Update3DTextLabelText(House3D, -1, str);
--------> break;
}
}
return 1;
}
Re: Problema. -
arturo clark - 02.06.2011
Ya sirve gracias Codeman.