Pickups not loading
#1

Hey guys!

My pickups are not loading, but why not?


LoadHouses(); is called under ongamemodeinit.
Код:
stock LoadHouses()
{
	new path[128];
	for(new i=1; i<MAX_HOUSES; i++)
	{
		format(path, 128, "Houses/%i.ini", i);
		strmid(HouseInfo[i][hOwner], dini_Get(path,"Owner"), 0, strlen(dini_Get(path,"Owner")), 255);
		strmid(HouseInfo[i][hDes], dini_Get(path,"Description"), 0, strlen(dini_Get(path,"Description")), 255);
		HouseInfo[i][hOwned] = dini_Int(path, "Owned");
		HouseInfo[i][hPrice] = dini_Int(path, "Price");
		HouseInfo[i][hRent] = dini_Int(path, "Rent");
		HouseInfo[i][hInterior] = dini_Int(path, "Interior");
		HouseInfo[i][hWorld] = dini_Int(path, "World");
		HouseInfo[i][hX] = dini_Float(path, "X");
		HouseInfo[i][hY] = dini_Float(path, "Y");
		HouseInfo[i][hZ] = dini_Float(path, "Z");
		HouseInfo[i][hA] = dini_Float(path, "A");
		HousePick[i] = CreatePickup(1273, 1, HouseInfo[i][hX],HouseInfo[i][hY],HouseInfo[i][hZ], -1);
		print("Houses loaded");
		return 1;
	}
	return 1;
}
Reply
#2

Quote:
Originally Posted by Devix
Посмотреть сообщение
Hey guys!

My pickups are not loading, but why not?


LoadHouses(); is called under ongamemodeinit.
Код:
stock LoadHouses()
{
	new path[128];
	for(new i=1; i<MAX_HOUSES; i++)
	{
		format(path, 128, "Houses/%i.ini", i);
		strmid(HouseInfo[i][hOwner], dini_Get(path,"Owner"), 0, strlen(dini_Get(path,"Owner")), 255);
		strmid(HouseInfo[i][hDes], dini_Get(path,"Description"), 0, strlen(dini_Get(path,"Description")), 255);
		HouseInfo[i][hOwned] = dini_Int(path, "Owned");
		HouseInfo[i][hPrice] = dini_Int(path, "Price");
		HouseInfo[i][hRent] = dini_Int(path, "Rent");
		HouseInfo[i][hInterior] = dini_Int(path, "Interior");
		HouseInfo[i][hWorld] = dini_Int(path, "World");
		HouseInfo[i][hX] = dini_Float(path, "X");
		HouseInfo[i][hY] = dini_Float(path, "Y");
		HouseInfo[i][hZ] = dini_Float(path, "Z");
		HouseInfo[i][hA] = dini_Float(path, "A");
		HousePick[i] = CreatePickup(1273, 1, HouseInfo[i][hX],HouseInfo[i][hY],HouseInfo[i][hZ], -1);
		print("Houses loaded");
		return 1;
	}
	return 1;
}
from I what see I can say that your pickups ARE loading, however they are spawned at the same location as your house, so if your house is at location, 0, 0, 0, it will spawn pickup there too, however house is covering pickup so you can't see it, you should add X,Y,Z for pickups at everyhouse
Reply
#3

The housing system is something you cannot see? Only pickups are seen?

I dont really get it :P
Reply
#4

Quote:
Originally Posted by Devix
Посмотреть сообщение
The housing system is something you cannot see? Only pickups are seen?

I dont really get it :P
okay, since I don't know how your housing system works I'm refering to the code you pasted, so basically you have txt file with some info about house, AND house X,Y,Z, what are those X,Y,Z values? location of the house?
Reply
#5

This is where the xyz is being created:

Код:
COMMAND:createhouse(playerid, params[])
{
	if(IsPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You're not logged in!");
	if(PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
	new interior;
	new name[256];
	new price;
	new h;
	if(sscanf(params, "iis[104]", h, interior, price, name))
	{
		SendClientMessage(playerid, COLOR_CRED, "Syntax: /createhouse");
		return 1;
	}
	new path[68];
	format(path, 68, "Houses/%i.ini", h);
	if(INI_Exists(path) == 1) return SendClientMessage(playerid, COLOR_CRED, "There is already a house with this ID!");
	new randvir = 2 + random(1999999);
	new Float:x, Float:y, Float:z;
	new Float:a;
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid, a);
	HouseInfo[h][hX] = x;
	HouseInfo[h][hY] = y;
	HouseInfo[h][hZ] = z;
	HouseInfo[h][hA] = a;
	HouseInfo[h][hDes] = name;
	HouseInfo[h][hPrice] = price;
	HouseInfo[h][hWorld] = randvir;
	HouseInfo[h][hRent] = 0;
	HouseInfo[h][hOwner] = 0;
	HouseInfo[h][hOwned] = 0;
	SaveHouses(h);
  	HousePick[h] = CreatePickup(1273, 1, x,y,z, -1);
	return 1;
}
And savehouses:

SaveHouses(houseid)
{
new path[128];

format(path, 128, "Houses/%i.ini", houseid);
new INI:HouseFile = INI_Open(path);
INI_WriteString(HouseFile,"Owner", HouseInfo[houseid][hOwner]);
INI_WriteString(HouseFile,"Description", HouseInfo[houseid][hDes]);
INI_WriteInt(HouseFile,"Price", HouseInfo[houseid][hPrice]);
INI_WriteInt(HouseFile,"Owned", HouseInfo[houseid][hOwned]);
INI_WriteInt(HouseFile,"Rent", HouseInfo[houseid][hRent]);
INI_WriteInt(HouseFile,"World", HouseInfo[houseid][hWorld]);
INI_WriteInt(HouseFile,"Interior", HouseInfo[houseid][hInterior]);
INI_WriteFloat(HouseFile,"X", HouseInfo[houseid][hX]);
INI_WriteFloat(HouseFile,"Y", HouseInfo[houseid][hY]);
INI_WriteFloat(HouseFile,"Z", HouseInfo[houseid][hZ]);
INI_WriteFloat(HouseFile,"A", HouseInfo[houseid][hA]);
INI_Close(HouseFile);
print("Houses saved");

return 1;
}

So yeah.. XYZ is valued with the position of the player, and at exactly that position should be the pickup.
When creating the house with the command, a pickup is spawned but, as the problem explains, it is not being loaded when restarting the server.
Reply
#6

Quote:
Originally Posted by Devix
Посмотреть сообщение
This is where the xyz is being created:

Код:
COMMAND:createhouse(playerid, params[])
{
	if(IsPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You're not logged in!");
	if(PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
	new interior;
	new name[256];
	new price;
	new h;
	if(sscanf(params, "iis[104]", h, interior, price, name))
	{
		SendClientMessage(playerid, COLOR_CRED, "Syntax: /createhouse");
		return 1;
	}
	new path[68];
	format(path, 68, "Houses/%i.ini", h);
	if(INI_Exists(path) == 1) return SendClientMessage(playerid, COLOR_CRED, "There is already a house with this ID!");
	new randvir = 2 + random(1999999);
	new Float:x, Float:y, Float:z;
	new Float:a;
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid, a);
	HouseInfo[h][hX] = x;
	HouseInfo[h][hY] = y;
	HouseInfo[h][hZ] = z;
	HouseInfo[h][hA] = a;
	HouseInfo[h][hDes] = name;
	HouseInfo[h][hPrice] = price;
	HouseInfo[h][hWorld] = randvir;
	HouseInfo[h][hRent] = 0;
	HouseInfo[h][hOwner] = 0;
	HouseInfo[h][hOwned] = 0;
	SaveHouses(h);
  	HousePick[h] = CreatePickup(1273, 1, x,y,z, -1);
	return 1;
}
And savehouses:

SaveHouses(houseid)
{
new path[128];

format(path, 128, "Houses/%i.ini", houseid);
new INI:HouseFile = INI_Open(path);
INI_WriteString(HouseFile,"Owner", HouseInfo[houseid][hOwner]);
INI_WriteString(HouseFile,"Description", HouseInfo[houseid][hDes]);
INI_WriteInt(HouseFile,"Price", HouseInfo[houseid][hPrice]);
INI_WriteInt(HouseFile,"Owned", HouseInfo[houseid][hOwned]);
INI_WriteInt(HouseFile,"Rent", HouseInfo[houseid][hRent]);
INI_WriteInt(HouseFile,"World", HouseInfo[houseid][hWorld]);
INI_WriteInt(HouseFile,"Interior", HouseInfo[houseid][hInterior]);
INI_WriteFloat(HouseFile,"X", HouseInfo[houseid][hX]);
INI_WriteFloat(HouseFile,"Y", HouseInfo[houseid][hY]);
INI_WriteFloat(HouseFile,"Z", HouseInfo[houseid][hZ]);
INI_WriteFloat(HouseFile,"A", HouseInfo[houseid][hA]);
INI_Close(HouseFile);
print("Houses saved");

return 1;
}

So yeah.. XYZ is valued with the position of the player, and at exactly that position should be the pickup.
When creating the house with the command, a pickup is spawned but, as the problem explains, it is not being loaded when restarting the server.
there must be something wrong with your code, I've never before used dini, you can check your x,y,z values with code like this
pawn Код:
new string[128];
format(string, sizeof(string), "x: %f, y: %f, z: %f", x, y ,z);
print(string);
x, y, z are variables you get from file, so in your case HouseInfo[i][hX] etc, however if you have a lot of houses you ar egoing to get big spam in your server console, because of that do a backup of your houses and use only one, so you can get where's the error
Reply
#7

Well, thing is that my files give me:
X = 139.321929
Y = -71.512245
Z = 1.429687
A = 193.748901

So it should work?
Reply
#8

how I said, use only 1 house for now and use print function to print coords, there's a chance that your script is loading coords in wrong way, so it's not 139.32xxxx for example but "= 139.32xxxx"
Reply
#9

Yeah it loads as 0.000 0.000 0.000.. Very odd, I also put a print at the savehouses and thats 100% correct.
So it goes wrong at loading the cords.

EDIT::
Is it coz savehouses is writen with ini and loadhouses with dini?
Reply
#10

Still not working, I changed it from ini to dini only.. Still no sign of pickups after restart.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)