[HELP]Y_INI Problem[HELP]!!!
#1

OK,so I have scripted a house system(buy house,sell house,etc.) using as database system Y_INI.But to do this,I followed a tutorial,but the tutorial used MySQL for creating the DataBase.Well,nevermind,after struggling and modifying A LOT OF THINGS(The original tutorial was using commands,I used dialogs,the tutorial was using checkpoints,I used icons),I have a 99% working system,and the database rocks:
Код:
[HouseInfo]
Owner = [LSCS]Eddie
SellPrice = 0
Interior = 5
TeleX = 1267.663208
TeleY = -781.323242
TeleZ = 1091.906250
EnterX = -2622.046630
EnterY = 375.950805
EnterZ = 6.156300
ExitX = 1261.278686
ExitY = -785.316711
ExitZ = 1091.906250
ForSell = 0
The only problem is when the server restarts,the house deletes(if the house was belonging to someone,it's again for sell),and I might have spotted the problem...This is the only piece of coded I wasn't able to convert because I have no idea how...:

pawn Код:
format(fquery, sizeof(fquery), "SELECT houseowner FROM HOUSEINFO WHERE housename = '%s'", HouseName);
How would look that in Y_INI?If you need an entire piece of my code,tell me...
Reply
#2

Can you give me the whole code?
Reply
#3

Here's my piece of CreateHouse code:
pawn Код:
stock CreateHouse(Price,Float:EnterX,Float:EnterY,Float:EnterZ,Float:ExitX,Float:ExitY,Float:ExitZ,Layout,Float:TeleX,Float:TeleY,Float:TeleZ)
{
   HouseInfo[houseid][DefaultPrice] = Price;
   HouseInfo[houseid][EnterPos][0] = EnterX;
   HouseInfo[houseid][EnterPos][1] = EnterY;
   HouseInfo[houseid][EnterPos][2] = EnterZ;
   HouseInfo[houseid][ExitPos][0] = ExitX;
   HouseInfo[houseid][ExitPos][1] = ExitY;
   HouseInfo[houseid][ExitPos][2] = ExitZ;
   HouseInfo[houseid][Interior] = Layout;
   HouseInfo[houseid][TelePos][0] = TeleX;
   HouseInfo[houseid][TelePos][1] = TeleY;
   HouseInfo[houseid][TelePos][2] = TeleZ;
   HouseInfo[houseid][SellPrice]=0;
   HouseInfo[houseid][hPickup] = CreatePickup(1273,1,EnterX,EnterY,EnterZ,-1);
   HouseInfo[houseid][ehPickup] = CreatePickup(1272,1,ExitX,ExitY,ExitZ,-1);
   new string[250];
   if(!HouseInfo[houseid][Owner][0]) format(string,sizeof(string),"{FOR SELL}\nPrice:%d$",Price);
   else if(HouseInfo[houseid][Owner][0] != 0)
   {
      if(HouseInfo[houseid][hSell]==0) format(string,sizeof(string),"Owner:%s",HouseInfo[houseid][Owner]);
      else if(HouseInfo[houseid][hSell]==1) format(string,sizeof(string),"{FOR SELL}\nOwner:%s\nSell price:%d$",HouseInfo[houseid][Owner],HouseInfo[houseid][SellPrice]);
   }
   HouseInfo[houseid][hText] = Create3DTextLabel(string,COLOR_BLUE,EnterX,EnterY,EnterZ+0.5,50.0,0,0);
   houseid++;
   return 1;
}
But the problem is that it lacks one line wich may solve the problem,the line I've pointed in the first point,and I don't know how to convert it into Y_INI...
Reply
#4

Not tested:
pawn Код:
stock CreateHouse(Price,Float:EnterX,Float:EnterY,Float:EnterZ,Float:ExitX,Float:ExitY,Float:ExitZ,Layout,Float:TeleX,Float:TeleY,Float:TeleZ)
{
   HouseInfo[houseid][DefaultPrice] = Price;
   HouseInfo[houseid][EnterPos][0] = EnterX;
   HouseInfo[houseid][EnterPos][1] = EnterY;
   HouseInfo[houseid][EnterPos][2] = EnterZ;
   HouseInfo[houseid][ExitPos][0] = ExitX;
   HouseInfo[houseid][ExitPos][1] = ExitY;
   HouseInfo[houseid][ExitPos][2] = ExitZ;
   HouseInfo[houseid][Interior] = Layout;
   HouseInfo[houseid][TelePos][0] = TeleX;
   HouseInfo[houseid][TelePos][1] = TeleY;
   HouseInfo[houseid][TelePos][2] = TeleZ;
   HouseInfo[houseid][SellPrice]=0;
   HouseInfo[houseid][hPickup] = CreatePickup(1273,1,EnterX,EnterY,EnterZ,-1);
   HouseInfo[houseid][ehPickup] = CreatePickup(1272,1,ExitX,ExitY,ExitZ,-1);
   HouseInfo[houseid][Owner] = GetOwner(houseid);
   new string[250];
   if(!HouseInfo[houseid][Owner][0]) format(string,sizeof(string),"{FOR SELL}\nPrice:%d$",Price);
   else if(HouseInfo[houseid][Owner][0] != 0)
   {
      if(HouseInfo[houseid][hSell]==0) format(string,sizeof(string),"Owner:%s",HouseInfo[houseid][Owner]);
      else if(HouseInfo[houseid][hSell]==1) format(string,sizeof(string),"{FOR SELL}\nOwner:%s\nSell price:%d$",HouseInfo[houseid][Owner],HouseInfo[houseid][SellPrice]);
   }
   HouseInfo[houseid][hText] = Create3DTextLabel(string,COLOR_BLUE,EnterX,EnterY,EnterZ+0.5,50.0,0,0);
   houseid++;
   return 1;
}

forward GetOwner(houseid);
{
    new file[500];
    //open your file here.
    if (strcmp(ParameterName, "Owner", false) == 0) // Change this to your read value(the strcmp)
                format(HouseInfo[houseid][Owner], 50, ParameterValue); // Store the information
               
    return HouseInfo[houseid][Owner];
}
Reply
#5

Forgot to mention that I am saving the file in the DataBase with the player's name,like Cjgogo.ini,because a player can own only 1 HOUSE!!!I'll still try to modify the function you gave me to my needs,anyone else who would come up with other solution is welcome.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)