Houses always bought by NULL or 0
#1

Hello,

I am camping with this problem for a time now, and I couldn't figure out what it actually causes.

pawn Код:
new ss = sscanf(Line,"p<|>dffffffffffffffddds[24]",IDHolder,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ],HouseInfo[h][PickupInsidePosX],HouseInfo[h][PickupInsidePosY],HouseInfo[h][PickupInsidePosZ],HouseInfo[h][SpawnOutsideX],HouseInfo[h][SpawnOutsideY],HouseInfo[h][SpawnOutsideZ],HouseInfo[h][SpawnOutsideAngle],
                HouseInfo[h][SpawnInsideX],HouseInfo[h][SpawnInsideY],HouseInfo[h][SpawnInsideZ],HouseInfo[h][SpawnInsideAngle],HouseInfo[h][InteriorID],HouseInfo[h][Locked],HouseInfo[h][Price],HouseInfo[h][Owner]);
                if(!ss)
                {
                    if(!strlen(HouseInfo[h][Owner])) HouseInfo[h][PickupID] = CreateDynamicPickup(1273,23,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ],-1,-1,-1,200.0);
                    else HouseInfo[h][PickupID] = CreateDynamicPickup(1272,23,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ],-1,-1,-1,200.0);
                    printf("- HOUSE %d: X: %f || Y: %f || Z: %f",h,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ]);
                }
As you see it should load houses here. That all works fine, but the owner is always NULL or 0.

If this:

Then it says this ingame:



Or if I delete the 0, then the field will be "(null)" and it says the house is owned by NULL ingame. Isn't this weird?

Jochem
Reply
#2

What version of SA-MP client and server are you using?
Reply
#3

Does not matter, don't post just to post please.
Reply
#4

Showing us your query would probably be important here.

You've not explained very much, are you experiencing this problem with the results in SA-MP and phpMyAdmin (or alternatives) too or just through SA-MP?
Reply
#5

It is only with SA:MP, as you see in the info box. I don't know where else because I don't use it anywhere else.

Here is my OnPlayerPickUpDynamicPickup

pawn Код:
for(new h = 0; h < MAX_HOUSES; h ++)
    {
        if(pickupid == HouseInfo[h][PickupID])
        {
            new string[155];
            if(!strlen(HouseInfo[h][Owner]))
            {
                format(string,sizeof(string),"~r~House~n~~n~~w~This house is ~y~for sale! ~w~You can ~b~purchase ~w~it for ~r~$%d. ~w~Type ~g~/buyhouse ~w~to purchase it~n~~n~~b~House ID: ~w~%d",HouseInfo[h][Price],h);
            }
            else
            {
                format(string,sizeof(string),"~w~This house is ~r~not ~y~for sale.~n~Owner: ~g~%s~n~~n~~b~House ID: ~w~%d",HouseInfo[h][Owner],h);
            }
            SetInfoBoxMessage(playerid,string,3000);
            return 1;
        }
    }
Reply
#6

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Does not matter, don't post just to post please.
You dont tell me what to do and what not to do!
And yes, it does matter! Sscanf doesn't work proper with 0.3d.
Reply
#7

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
You dont tell me what to do and what not to do!
And yes, it does matter! Sscanf doesn't work proper with 0.3d.
Only the u parameter. Also, I had to tell it didn't work on 0.3c as well. Sorry.
Reply
#8

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Only the u parameter. Also, I had to tell it didn't work on 0.3c as well. Sorry.
Np
Reply
#9

The strlen check has no point. The length for string "0" is still 1, not 0.

I'd suggest coming up with a better solution such as using unique player IDs (database-driven) in your house owner checks or changing strlen checks to check if the string is 0 or NULL.
Reply
#10

Quote:
Originally Posted by AndreT
Посмотреть сообщение
The strlen check has no point. The length for string "0" is still 1, not 0.

I'd suggest coming up with a better solution such as using unique player IDs (database-driven) in your house owner checks or changing strlen checks to check if the string is 0 or NULL.
As I said, checking if it's NULL doesn't work as well - nor the isnull macro does.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)