SA-MP Forums Archive
Not saved into database and dialog issue - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not saved into database and dialog issue (/showthread.php?tid=663167)



Not saved into database and dialog issue - TheLeech - 23.01.2019

So my businesses aren't saving into my database but I copy and pasted the code to save buildings and edited the values to be set to the business ones yet not saving when buildings do? And my dialog for setting the business price doesn't work, Keeps opening it up again no matter what I set price too.

Code:
case 5:
				{
				    new id = GetBusinesses();
				   	SetPlayerPos(playerid, CreateEnterPos[playerid][0], CreateEnterPos[playerid][1], CreateEnterPos[playerid][2]);
				   	BusinessInfo[id][EnterX] = CreateEnterPos[playerid][0];
				   	BusinessInfo[id][EnterY] = CreateEnterPos[playerid][1];
				   	BusinessInfo[id][EnterZ] = CreateEnterPos[playerid][2];
				   	BusinessInfo[id][ExitX] = CreateExitPos[playerid][0];
				   	BusinessInfo[id][ExitY] = CreateExitPos[playerid][1];
				   	BusinessInfo[id][ExitZ] = CreateExitPos[playerid][2];
				   	BusinessInfo[id][Int] = CreateInt[playerid];
				   	BusinessInfo[id][Price] = CreatePrice[playerid];
				   	BusinessInfo[id][Type] = CreateBType[playerid];
				   	BusinessInfo[id][VW] = id;
				   	format(BusinessInfo[id][Name], 256, PCreateName[playerid]);
				    new querylist[556];
		            mysql_format(mysql, querylist, sizeof(querylist), "INSERT INTO `businesses` (`ID`, `Name`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Interior`, `VirtualWorld`)\
					VALUES ('%d', '%e', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d')", id, PCreateName[playerid], BusinessInfo[id][EnterX], BusinessInfo[id][EnterY], BusinessInfo[id][EnterZ], BusinessInfo[id][ExitX], BusinessInfo[id][ExitY], BusinessInfo[id][ExitZ], BusinessInfo[id][Int], id);
					mysql_query(mysql, querylist);
					mysql_format(mysql, querylist, sizeof(querylist), "UPDATE `businesses` SET `Price` = %d, `Type` = %d WHERE `ID` = %d" , BusinessInfo[id][Name], BusinessInfo[id][Type], id);
			    	mysql_query(mysql, querylist);
					new string[256];
  					format(string, sizeof(string), "%s forsale $%d\nPress H to buy\nAlso /buy", PCreateName[playerid], BusinessInfo[id][Price]);
	    			Business3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BusinessInfo[id][EnterX],BusinessInfo[id][EnterY],BusinessInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
   					BusinessPickup[id] = CreateDynamicPickup(1272, 1, BusinessInfo[id][EnterX],BusinessInfo[id][EnterY],BusinessInfo[id][EnterZ]);
   					SetPVarInt(playerid, "CreateType", 0);
   					format(string, sizeof(string), "Server: business %s has been created and saved. (ID:%d)", PCreateName[playerid], id);
					SendClientMessage(playerid, COLOR_ORANGE, string);
					SendClientMessage(playerid, COLOR_ORANGE, "Server: To edit the business type /edit then down to businesses");
					SetPlayerInterior(playerid, 0);
					SetPlayerVirtualWorld(playerid, 0);
				}
Code:
case CreateBusinessPrice:
		{
  			if(!response) {
				ShowPlayerDialog(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
		    }
			else {
				if(!strlen(inputtext)) return ShowPlayerDialog(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
                if(strlen(inputtext) >= 3) return ShowPlayerDialog(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
	   			new amount = strval(inputtext);
          		if(amount >= 99999999) return ShowPlayerDialog(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
            	new price = strval(inputtext);
             	if(price > 0)
              	{
              		CreatePrice[playerid] = amount;
		    		SendClientMessage(playerid, COLOR_ORANGE, "Server: Business price has been set.");
				}
				else ShowPlayerDialog(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
			}
		}



Re: Not saved into database and dialog issue - codExpert - 23.01.2019

what is your code doing?
first you insert business and then update it?
this code doesnt make any sense, you have to think also what you copy together


Re: Not saved into database and dialog issue - TheLeech - 24.01.2019

Quote:
Originally Posted by codExpert
View Post
what is your code doing?
first you insert business and then update it?
this code doesnt make any sense, you have to think also what you copy together
When I put all the values of the business into inserting into the database I got an error that it was to long, I then tried to insert values but didn't work. I then thought I would try to change the second insert into update but it didn't save in still.


Re: Not saved into database and dialog issue - fiki574 - 24.01.2019

1. querylist might be too small of size, increase it
2. This query:

INSERT INTO `businesses` (`ID`, `Name`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Interior`, `VirtualWorld`) VALUES ('%d', '%e', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d')

You have 10 columns, yet you're trying to pass 11 elements in VALUES(...) part.