Garages not showing up (Garage System SQL)
#1

Hey,

I made this Garage system for my gamemode. Its based on SQL and loads data from a DB in scriptfiles.
Whenever I try to use /creategarage, it doesn't show anything not even a message like 'Garage created'.

Heres the /creategarage code:-
Код:
COMMAND:creategarage(cmdid, playerid, params[])
{
	if(playerData[playerid][playerLoggedIn])
	{
		if(playerData[playerid][playerLevel] >= 5)
		{
			new
				newPrice
			;

			if(sscanf(params, "i", newPrice))
			{
				SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"creategarage <garage price>\"");
			}
			else
			{
				new
					query[400],
					Float:x,
					Float:y,
					Float:z,
					Float:intX,
					Float:intY,
					Float:intZ,
					Float:intA,
					Float:vintX,
					Float:vintY,
					Float:vintZ,
					Float:vintA,
					intID
				;

				GetPlayerPos(playerid, x, y, z);
				intX = 1341.3508;
				intY = -1547.2848;
				intZ = 10036.9199;
				intA = 354.7931;
				vintX = 1341.3508;
				vintY = -1547.2848;
				vintZ = 10036.9199;
				vintA = 0.7696;

				intID = 9;

				format(query, sizeof(query), "INSERT INTO `garage_data` (garage_bought, garage_price, garage_owner, garageX, garageY, garageZ, interiorID, pinteriorX, pinteriorY, pinteriorZ, pinteriorAngle, vinteriorX, vinteriorY, vinteriorZ, vinteriorAngle) VALUES ('0', '%i', 'FGCNR', '%f', '%f', '%f', '%i', '%f', '%f', '%f', '%f')", newPrice, x, y, z, intID, intX, intY, intZ, intA, vintX, vintY, vintZ, vintA);
				db_query(DB:GARAGEDB, query);

				reloadGarages();
			}
		}
		else
		{
			return 0;
		}
	}

	return 1;
}
(The return 0 is for someone who is not an admin and shows 'Unknown command' to them)
I didn't know what to search for this problem.

Any Help is appreciated.
Reply
#2

PHP код:
COMMAND:creategarage(cmdidplayeridparams[])
{
    if(!
playerData[playerid][playerLoggedIn])
        return 
SendClientMessage(playerid, -1"Yo uare not log in.");
    
    if(
playerData[playerid][playerLevel] < 5)
        return 
0;
        
    new
        
newPrice
    
;
    if(
sscanf(params"i"newPrice)) 
        return 
SendClientMessage(playeridCOLOR_WHITE"{B7B7B7}[SERVER] {FFFFFF}Usage: \"creategarage <garage price>\"");
    
    new
        
query[400],
        
Float:x,
        
Float:y,
        
Float:z,
        
Float:intX,
        
Float:intY,
        
Float:intZ,
        
Float:intA,
        
Float:vintX,
        
Float:vintY,
        
Float:vintZ,
        
Float:vintA,
        
intID
    
;
    
GetPlayerPos(playeridxyz);
    
intX 1341.3508;
    
intY = -1547.2848;
    
intZ 10036.9199;
    
intA 354.7931;
    
vintX 1341.3508;
    
vintY = -1547.2848;
    
vintZ 10036.9199;
    
vintA 0.7696;
    
intID 9;
    
format(querysizeof(query), "INSERT INTO `garage_data` (garage_bought, garage_price, garage_owner, garageX, garageY, garageZ, interiorID, pinteriorX, pinteriorY, pinteriorZ, pinteriorAngle, vinteriorX, vinteriorY, vinteriorZ, vinteriorAngle) VALUES ('0', '%i', 'FGCNR', '%f', '%f', '%f', '%i', '%f', '%f', '%f', '%f')"newPricexyzintIDintXintYintZintAvintXvintYvintZvintA);
    
db_free_result(db_query(GARAGEDBquery));
    
reloadGarages();
    
SendClientMessage(playerid, -1"Command end up succesfully.");
    return 
1;

I give you an advice, try to avoid if nesting doing like i did is a more readable

Try the command and see if you recive the message at the end. Other than that i dont see any problem with your code
Reply
#3

It did show 'command end up successfully'.
I think its something other than the cmd which is bugged. Should I private message you the whole code.
Reply
#4

All i can think of is the database is not open, the GARAGEDB. If the command running good then the query is not getting executed and i dont see any issue with the query itself
Reply
#5

It shows running in the server logs.

My gamemodeinit has -

Код:
	GARAGEDB = db_open("dbs/Garages.db");
	print("GARAGE :: Database Running!");

	load_garages();
In server log, it showed:
[23:26:33] GARAGE :: Database Running! // From gamemodeinit
[23:26:33] GARAGES:: Loaded 0 from Database // From load_garages()

So it loads the database without any problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)