Dialog at dynamic house system
#1

Hello.
I want to learn pawn after awhile again, so I started with a little Freeroam-Server with a dynamic house system. For this I made with dini, dmcd + sscanf a command to save the current position, increase the housecounter by one and create a new .ini file in scriptfiles with the ID from the housecounter. Then I want to open a dialog if someone enters a pickup, but I didn't really know how to. So I tried like this.

This is my forwarded LoadHouses Callback, which is called in OnGameModeInit. It works, but my problem is that it doesn't load the 3DTextLabel for houses without owner beginning from ID 3 upwards or something there (only some TextLabels).
pawn Code:
public LoadHouses()
{
    new path[128];
    for(new h=1; h<MAX_HOUSE; h++)
    {
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        format(path,sizeof(path),"/hauser/%i.ini",h);
        if(fexist(path))
        {
            new world = i;
            new Float:x, Float:y, Float:z, Region[256], owner[256], Preis, icon[256];
            owner = dini_Get(path,"Owner");
            Region = dini_Get(path,"Gebiet");
            Preis = dini_Int(path,"Preis");
            x = dini_Float(path,"X");
            y = dini_Float(path,"Y");
            z = dini_Float(path,"Z");
            if(strcmp(owner,"Frei"))
            {
                format(icon,sizeof(icon),"Besitzer: %s\nRegion: %s",owner, Region);
                Create3DTextLabel(icon, COLOR_BLUE, x, y, z+1.0, 20.0, world, 1);
                CreatePickup(1272, 1, x, y, z, world);
            }
            else
            {
                format(icon,sizeof(icon),"Frei.\nRegion:%s\nPreis: %i$",Region,Preis);
                Create3DTextLabel(icon, COLOR_GREEN, x, y, z+1.0, 20.0, world, 1);
                CreatePickup(1273, 1, x, y, z, world);
            }
        }
        else break;
    }
    }
    return 1;
}
And here is my OnPlayerPickUpPickup Callback.
pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    new path[128], Float:x, Float:y, Float:z, preis;
    for(new i=0; i<MAX_HOUSE; i++)
    {
        format(path,sizeof(path),"/hauser/%i.ini",i);
        if(fexist(path))
        {
            x = dini_Float(path,"X");
            y = dini_Float(path,"Y");
            z = dini_Float(path,"Z");
            preis = dini_Int(path,"Preis");
            if(IsPlayerInRangeOfPoint(playerid,3.0,x,y,z))
            {
                new dialog[128];
                format(dialog,sizeof(dialog),"Willst du dieses Haus wirklich fьr %i$ kaufen?",preis);
                ShowPlayerDialog(playerid, DIALOG_HAUS, 0, "Hauskauf", dialog, "Ja", "Nein");
            }
        }
        else break;
    }
    return 1;
}
I hope you can help me and tell me what's wrong with this and why the DIALOG_HAUS doesn't open.

Thanks for your help
Padarom

PS: The house .ini's are set like this:
Code:
Owner=FreakY
Gebiet=LSEC
Preis=7500
X=1914.552001
Y=-1912.999389
Z=15.256797
Interieur=3
Reply
#2

Remove the
pawn Code:
else break;
from the loops.
Reply
#3

Now the dialogs are working, but there still aren't text labels at some houses.
But thanks for helping with this problem.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)