) - and i am trying to do dini_Get(file, "owner") and compare it using strcmp to see if its owned or not... - But even when the house is owned (A name is in 'Owner')public OnPlayerPickUpPickup(playerid, pickupid)
{
new file[64], pName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
for(new i; i < LastID; i++)
{
if(pickupid == Pickups[i])
{
format(file, sizeof(file), "houses/%i.house", i);
if(strcmp(dini_Get(file, "Owner"), "") == 0)
{
SendClientMessage(playerid, COLOUR, "This house is for sale");
if(dini_Int(file, "Type") == 0)
{
format(string, sizeof(string), "It costs: %i and is a very small house", dini_Int(file, "Cost"));
}
else if(dini_Int(file, "Type") == 1)
{
format(string, sizeof(string), "It costs: %i and is a small house", dini_Int(file, "Cost"));
}
else if(dini_Int(file, "Type") == 2)
{
format(string, sizeof(string), "It costs: %i and is a medium house", dini_Int(file, "Cost"));
}
else if(dini_Int(file, "Type") == 3)
{
format(string, sizeof(string), "It costs: %i and is a big house", dini_Int(file, "Cost"));
}
else if(dini_Int(file, "Type") == 4)
{
format(string, sizeof(string), "It costs: %i and is a very big house", dini_Int(file, "Cost"));
}
else if(dini_Int(file, "Type") == 5)
{
format(string, sizeof(string), "It costs: %i and is a massive house", dini_Int(file, "Cost"));
}
}
else if(strcmp(dini_Get(file, "Owner"), pName) == 0)
{
format(string, sizeof(string), "You own this house, it cost %i", pName, dini_Int(file, "Cost"));
}
else
{
format(string, sizeof(string), "%s owns this house, it cost them %i", dini_Get(file, "Owner"), dini_Int(file, "Cost"));
}
SendClientMessage(playerid, COLOUR, string);
printf("DINI: %s, pName: %s", dini_Get(file, "Owner"), pName); //As you can see here - i tried printing - i have shown what came out below
}
}
}
[11:09:33] DINI: , pName: Ash
if(strcmp(dini_Get(file, "Owner"), "") == 0)
|
Well, with strcmp, the return is not as simple as if they match it's 1, and if they don't it's 0. It's actually a little more complex, although I don't think the SA-MP Wiki explains the return value perfectly either.
What you must remember though specifically, is that using strcmp to compare an empty string to a string will actually always come up with 0. Therefore: pawn Код:
Although I cannot explain why later on it does not print out a name. |
if(string == string2)
|
Thanks, how else would i compare the two strings - using
pawn Код:
|
if(strlen(string) == 0) // String is empty
|
Well that's the only way to do it really (using strcmp).
So specifically for checking if a string is empty, just use strlen. pawn Код:
|
- Is it worth trying to change the .house file association to .ini ?|
Have you tried printing out i?
So you can make sure the ID of the house is indeed correct. |

|
EDIT: I am now testing all my scripts in 0.3c - i have tested the code above, in my first post, and now it seems OnPlayerPickupPickUp doesnt work at all... - Any ideas? |