SA-MP Forums Archive
Won't read "nobody" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Won't read "nobody" (/showthread.php?tid=103499)



Won't read "nobody" - CAR - 20.10.2009

I was trying to make a house system with dini
Coцrdinates work, Price works... everything works.
If I make a new House, in the file stand: Owner=nobody
And if somebody want to buy the house:
pawn Код:
format(HInfo[houseid][owner], 24, dini_Get(Huis, "Owner"));
if(strcmp(cmd,"/buyhouse",true)==0)
{
if(PlayerToPoint(3.0, playerid, HInfo[houseid][iconx],HInfo[houseid][icony],HInfo[houseid][iconz]))
{
if(strcmp(HInfo[houseid][owner], "nobody", true))
{
if(GetPlayerMoney(playerid) >= HInfo[houseid][price])
{
new pname[24];
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "You are now the owner of houseid: %d !!!", HInfo[houseid][hHouseid]);
SendClientMessage(playerid, GROEN, string);
dini_Set(Huis, "Owner", pname);
}
else
{
SendClientMessage(playerid, ROOD, "You don't have enough money.");
}
}
else
{
SendClientMessage(playerid, ROOD, "This house is already bought.");
}
}
else
{
SendClientMessage(playerid, ROOD, "You are not at an house.");
}
return 1;
}
But if I type /buyhouse there stands: This house is already bought.

Can anyone help me?


Re: Won't read "nobody" - Mike Garber - 20.10.2009

Do you have something that tells the script that, If the owner is "nobody", It's buyable?


Re: Won't read "nobody" - CAR - 20.10.2009

Yes, in the code^:
pawn Код:
if(strcmp(HInfo[houseid][owner], "nobody", true))
{
//...
Why it doesn't work, maybe next code will help you?..

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
new houseid, Howner[MAX_HOUSES], Hprice[MAX_HOUSES];
new string[256];
houseid = dini_Int(Huis, "Id");
format(Howner[houseid], 256, dini_Get(Huis, "Owner"));
Hprice[houseid] = dini_Int(Huis, "Price");
if(pickupid == EnterHousePickup[houseid])
{
  if(strcmp(Howner[houseid],"nobody", true))
  {
    format(string, sizeof(string), "~w~Type /buyhouse to buy this house ~h~Price: %d", Hprice[houseid]);
    GameTextForPlayer(playerid, string, 500, 0);
  }
  else
  {
    format(string, sizeof(string), "~w~Owner: %s ~w~Type /enter to enter the house", Howner[houseid]);
    GameTextForPlayer(playerid,string, 500, 0);
  }
}
if(pickupid == ExitHousePickup[houseid])
{
  GameTextForPlayer(playerid,"~w~Type ~r~/exit ~w~to exit the house", 500, 0);
}
return 1;
}



Re: Won't read "nobody" - dice7 - 20.10.2009

pawn Код:
if(strcmp(HInfo[houseid][owner], "nobody", true) == 0)



Re: Won't read "nobody" - CAR - 20.10.2009

(Maybe a stupid question)

But what means == 0 ??


Re: Won't read "nobody" - Clank - 20.10.2009

Quote:
Originally Posted by dice7
pawn Код:
if(strcmp(HInfo[houseid][owner], "nobody", true) == 0)
the ==0 is equal to (not true)

i think it has to be ==1, because it has to be nobody... so it has to be

pawn Код:
if(strcmp(HInfo[houseid][owner], "nobody", true) == 1)



Re: Won't read "nobody" - CAR - 20.10.2009

Thank you! Thank you, very very very much!

and it must be 0. Don't know why... BUT WORKS!