Error reading from ini - 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: Error reading from ini (
/showthread.php?tid=71934)
Error reading from ini -
Vince - 04.04.2009
Hi
I followed
this tutorial on how to read from ini files. Currently, I'm stuck with my script:
Код:
D:\Documents and Settings\Vince\Mijn Documenten\SA-MP SERVER\gamemodes\island.pwn(440) : error 033: array must be indexed (variable "owner")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
new inimessage[256], inisection[32];
new owner[MAX_PLAYER_NAME], buyprice[32], rent[32];
for(new p = 0; p <= sizeof(Icons_Houses_A); p++)
{
if(pickupid == Icons_Houses_A[p])
{
format(inisection, sizeof(inisection), "HOUSE_%d", p);
getINIStringDefault("HOUSES_A.ini", inisection, "owner", "No-one", owner);
getINIStringDefault("HOUSES_A.ini", inisection, "price", "0", buyprice);
getINIStringDefault("HOUSES_A.ini", inisection, "rent", "0", rent);
if(owner == "No-one") // <= this is the line with the error
{
format(inimessage, sizeof(inimessage), "~w~This house is ~r~FOR SALE~w~~n~Buy for: ~g~$%d", buyprice);
GameTextForPlayer(playerid, inimessage, 5000, 5);
}
else
{
format(inimessage, sizeof(inimessage), "~w~This house is owned by: ~r~%s ~w~~n~Rent: ~~g$%d", owner, rent);
GameTextForPlayer(playerid, inimessage, 3000, 5);
}
}
}
return 1;
}
Thanks in advance!
Re: Error reading from ini -
Jefff - 04.04.2009
Код:
if(owner == "No-one") // <= this is the line with the error
Код:
if(!strcmp(owner, "No-one", true))
Re: Error reading from ini -
Vince - 05.04.2009
Ok, now it compiles, but now I have a different problem.
When I enter the pickup at a house (doesn't matter which one), I always get the message: "This house is for sale. buy for $48".
I don't know where the 48 comes from, because it's not in the script nor the ini file.
Also, I changed the owner of house id 0 to 'Test' and it still displays the same message.
I know the loop is working correctly, 'cause I had the server print the id's of the houses.
Edit: nevermind. I fixed it with valstr.