New MySQL R41 converting from R33 pissing me off.
#3

Quote:
Originally Posted by Jeffry
View Post
There you go:
Code:
stock LoadApplications() 
{
	mysql_tquery(mysql, "SELECT * FROM applications", "LoadApplicationsSQL", ""); 
	return 1; 
}

forward LoadApplicationsSQL(); 
public LoadApplicationsSQL() 
{
	new rows, string[128]; 
	cache_get_row_count(rows); 
	for(new id = 0; id < rows; id++)
	{
		cache_get_value_name_int(id, "ID", ApplicationInfo[id][ID]); 
		cache_get_value_name(id, "Name", string); 
		format(ApplicationInfo[id][Name], 128, string); 
		cache_get_value_name(id, "Question1", string); 
		format(ApplicationInfo[id][Question1], 128, string); 
		cache_get_value_name(id, "Question2", string); 
		format(ApplicationInfo[id][Question2], 128, string); 
		cache_get_value_name(id, "Question3", string); 
		format(ApplicationInfo[id][Question3], 128, string); 
		cache_get_value_name(id, "Question4", string); 
		format(ApplicationInfo[id][Question4], 128, string); 
		cache_get_value_name(id, "Question5", string); 
		format(ApplicationInfo[id][Question5], 128, string); 
		cache_get_value_name(id, "Question6", string); 
		format(ApplicationInfo[id][Question6], 128, string); 
		cache_get_value_name_int(id, "Accepted", ApplicationInfo[id][AppPassed]); 
		cache_get_value_name_int(id, "SentIn", ApplicationInfo[id][SentIn]); 
		ApplicationInfo[id][PlayerID] = -1; 
		format(string, sizeof(string), "Application for %s loaded", ApplicationInfo[id][Name]); 
		print(string); 
	}
	return 1; 
}

stock LoadBuildings() 
{
	mysql_tquery(mysql, "SELECT * FROM buildings", "LoadBuildingsSQL", ""); 
	return 1; 
}

forward LoadBuildingsSQL(id); 
public LoadBuildingsSQL(id) 
{
	new rows, string[128]; 
	cache_get_row_count(rows); 
	for(new id = 0; id < rows; id++)
	{
		cache_get_value_name_int(id, "ID", BuildingInfo[id][ID]); 
		cache_get_value_name(id, "Name", string); 
		format(BuildingInfo[id][Name], 256, string); 
		cache_get_value_name_float(id, "EnterX", BuildingInfo[id][EnterX]); 
		cache_get_value_name_float(id, "EnterY", BuildingInfo[id][EnterY]); 
		cache_get_value_name_float(id, "EnterZ", BuildingInfo[id][EnterZ]); 
		cache_get_value_name_float(id, "ExitX", BuildingInfo[id][ExitX]); 
		cache_get_value_name_float(id, "ExitY", BuildingInfo[id][ExitY]); 
		cache_get_value_name_float(id, "ExitZ", BuildingInfo[id][ExitZ]); 
		cache_get_value_name_int(id, "Interior", BuildingInfo[id][Int]); 
		cache_get_value_name_int(id, "VirtualWorld", BuildingInfo[id][VW]); 
		cache_get_value_name_int(id, "FreezeTimer", BuildingInfo[id][FreezeTimer]); 
		if(BuildingInfo[id][EnterX] > 0.0) 
		{
			format(string, sizeof(string), "%s\nPress H to enter\nAlso /Enter or /Exit", BuildingInfo[id][Name]); 
			Build3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0); 
			BuildPickup[id] = CreateDynamicPickup(1318, 1, BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]); 
			format(string, sizeof(string), "%s created successfully", BuildingInfo[id][Name]); 
			print(string); 
		}
	}
	return 1; 
}
By the way, you can also use
Code:
cache_get_value_name(id, "Question1", ApplicationInfo[id][Question1], LENGTH_HERE);
Instead of fetching it in a variable first and using format afterwards. Not a big deal though, that's why I kept it, for your understanding.
Thank you, Been having issues with this for so long and now it works, Thank you so much have a warning though but all works perfectly.

Code:
../gamemodes/Functions.pwn(534) : warning 219: local variable "id" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply


Messages In This Thread
New MySQL R41 converting from R33 pissing me off. - by TheLeech - 20.01.2019, 09:41
Re: New MySQL R41 converting from R33 pissing me off. - by Jeffry - 20.01.2019, 09:52
Re: New MySQL R41 converting from R33 pissing me off. - by TheLeech - 20.01.2019, 09:57
Re: New MySQL R41 converting from R33 pissing me off. - by Jeffry - 20.01.2019, 09:59

Forum Jump:


Users browsing this thread: 1 Guest(s)