Little issue with a function I made
#1

Hey, I created a function to load all the houses added in by AddHouses (which I made earlier)
is something wrong:
Код:
public LoadHouses(houseid)
{
			new string2[64];
			format(string2, sizeof(string2), "accounts/%d.cer", houseid);
			new File: HouseFile = fopen(string2, io_read);
			new key[128],val[128];
 			new Data[128];
 			while(fread(HouseFile,Data,sizeof(Data)))
			{
				key = ini_GetKey(Data);
        if( strcmp( key , "HouseOwner" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseOwnerName] = strval( val ); }
  				if( strcmp( key , "HouseOwnerId" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseOwnerId] = strval( val ); }
  				if( strcmp( key , "HouseInterior" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseInterior] = strval( val ); }
				if( strcmp( key , "HouseId" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseId] = strval( val ); }
	  			if( strcmp( key , "Cost" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseCost] = strval( val ); }
	  			if( strcmp( key , "Locked" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHouseLocked] = strval( val ); }
			 	if( strcmp( key , "Housex" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHousex] = strval( val ); }
	  			if( strcmp( key , "Housey" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHousey] = strval( val ); }
	  			if( strcmp( key , "Housez" , true ) == 0 ) { val = ini_GetValue( Data ); HouseInfo[houseid][hHousez] = strval( val ); }
			}
			fclose(HouseFile);
			HousePickup[houseid] = CreatePickup(1273,1,HouseInfo[houseid][hHousex], HouseInfo[houseid][hHousey], HouseInfo[houseid][hHousez]);
			print("Houses Loaded");
			return 1;
}
Now Under GameModeInit, I put LoadHouses(2) so it loads house number two (yes the file name is 2.cer) and when I launch the server I get a don't send error, I did a DEBUG and I traced it to LoadHouses(2); that is the only LoadHouses code in OnGameModeInit .. or in the whole script at the matter.
Reply
#2

You convert all values to integers, but I bet HouseInfo[houseid][hHouseOwnerName] is a string and HouseInfo[houseid][hHousex], HouseInfo[houseid][hHousey] and HouseInfo[houseid][hHousez] are floats, so maybe instead of strval you use format or strmid on a string and floatstr on a float? And maybe I just don't know but what is "a don't send error"?
Reply
#3

I will try your idea

A don't send error is when a program crashes basically.
Reply
#4

Quote:
Originally Posted by MadeMan
You convert all values to integers, but I bet HouseInfo[houseid][hHouseOwnerName] is a string and HouseInfo[houseid][hHousex], HouseInfo[houseid][hHousey] and HouseInfo[houseid][hHousez] are floats, so maybe instead of strval you use format or strmid on a string and floatstr on a float? And maybe I just don't know but what is "a don't send error"?
Thank you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)