SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/01/2020, 05:38 PM   #1
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default MySQL not saving Price, Type, Locked Balance ETC

It's not doing this line mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `businesses` SET `Price` = %d, `Type` = %d `Owned` = %d, `Locked` = %d, `Balance` = %d WHERE `ID` = %d" , BusinessInfo[id][Price], BusinessInfo[id][Type], BusinessInfo[id][Owned], BusinessInfo[id][Locked], BusinessInfo[id][Balance], id);
mysql_query(g_iHandle, querylist);
Code:
Dialog:CreateBusiness(playerid, response, listitem, inputtext[])
{
    if(!response) {
		return 1;
    }
	switch(listitem)
	{
	    case 0:
		{
		   	GetPlayerPos(playerid, CreateEnterPos[playerid][0], CreateEnterPos[playerid][1], CreateEnterPos[playerid][2]);
		   	SendClientMessage(playerid, COLOR_ORANGE, "Server: Entry position of the business has been saved [land pos too].");
		   	SendClientMessage(playerid, COLOR_ORANGE, "Server: Use /teleport to pick a interior and /create to continue creating.");
		}
		case 1:
		{
		   	GetPlayerPos(playerid, CreateExitPos[playerid][0], CreateExitPos[playerid][1], CreateExitPos[playerid][2]);
		   	CreateInt[playerid] = GetPlayerInterior(playerid);
		   	SendClientMessage(playerid, COLOR_ORANGE, "Server: Interior position of the business has been saved.");
		   	SendClientMessage(playerid, COLOR_ORANGE, "Server: use /create to continue creating the creating.");
		}
		case 2:
		{
		   	Dialog_Show(playerid, CreateBusinessName, DIALOG_STYLE_INPUT, "Business Name", "Please type a name for the business below example: 24/7.", "Accept", "Close");
		}
		case 3:
		{
		   	Dialog_Show(playerid, CreateBusinessPrice, DIALOG_STYLE_INPUT, "Business Price", "Please type a price for the business below example: 125000.", "Accept", "Close");
		}
		case 4:
		{
		   	Dialog_Show(playerid, CreateBusinessType, DIALOG_STYLE_INPUT, "Business Type", "Please input the type of business 0 being interior set or 1 being land.", "Accept", "Close");
		}
		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;
		   	BusinessInfo[id][Owned] = 0;
		   	BusinessInfo[id][Locked] = 1;
		   	BusinessInfo[id][Balance] = 0;
		   	BusinessInfo[id][ID] = id;
		   	format(BusinessInfo[id][Name], 256, PCreateName[playerid]);
		    new querylist[2048];
            mysql_format(g_iHandle, 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')", 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(g_iHandle, querylist);
			mysql_format(g_iHandle, querylist, sizeof(querylist), "UPDATE `businesses` SET `Price` = %d, `Type` = %d `Owned` = %d, `Locked` = %d, `Balance` = %d WHERE `ID` = %d" , BusinessInfo[id][Price], BusinessInfo[id][Type], BusinessInfo[id][Owned], BusinessInfo[id][Locked], BusinessInfo[id][Balance], id);
	    	mysql_query(g_iHandle, querylist);
			new string[256];
			format(string, sizeof(string), "%s forsale $%d\nPress H to enter or exit\nOr type /enter or /exit\nType /buy to buy this business.", PCreateName[playerid], BusinessInfo[id][Price]);
			Business3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BusinessInfo[id][EnterX],BusinessInfo[id][EnterY],BusinessInfo[id][EnterZ]+0.75, 5.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], 0, 0, -1, 5.00, -1, 0);
			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);
		}
		case 6:
		{
		    SetPVarInt(playerid, "CreateType", 0);
		    SendClientMessage(playerid, COLOR_ORANGE, "Server: Business creation ended, All progress has been removed.");
		}
	}
	return 1;
}
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com
TheLeech is offline   Reply With Quote
Old 16/01/2020, 06:03 PM   #2
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 956
Reputation: 167
Default Re: MySQL not saving Price, Type, Locked Balance ETC

They are threaded queries. You execute the query to insert some data and try directly to update the data when they have not been inserted yet.

The biggest question is why do you need an update query right after an insert one? Set price and the rest of the columns and their values in the insert query and that is it.
__________________
Calisthenics is offline   Reply With Quote
Old 16/01/2020, 06:44 PM   #3
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default Re: MySQL not saving Price, Type, Locked Balance ETC

Quote:
Originally Posted by Calisthenics View Post
They are threaded queries. You execute the query to insert some data and try directly to update the data when they have not been inserted yet.

The biggest question is why do you need an update query right after an insert one? Set price and the rest of the columns and their values in the insert query and that is it.
When I do that it says the query is to big and gives me errors.
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com
TheLeech is offline   Reply With Quote
Old 16/01/2020, 06:52 PM   #4
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 956
Reputation: 167
Default Re: MySQL not saving Price, Type, Locked Balance ETC

Compiler errors? You should be using the community compiler which increases the character limit per line: https://github.com/pawn-lang/compiler/releases

Remove any unnecessary character, set default values in the table structure (for Owned, Locked, Balance) and increase the size of `querylist`.

pawn Code:
INSERT INTO businesses (ID,Name,EnterX,...) \
VALUES (%d,'%e',%f,...)
__________________
Calisthenics is offline   Reply With Quote
Old 16/01/2020, 07:19 PM   #5
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default Re: MySQL not saving Price, Type, Locked Balance ETC

Quote:
Originally Posted by Calisthenics View Post
Compiler errors? You should be using the community compiler which increases the character limit per line: https://github.com/pawn-lang/compiler/releases

Remove any unnecessary character, set default values in the table structure (for Owned, Locked, Balance) and increase the size of `querylist`.

pawn Code:
INSERT INTO businesses (ID,Name,EnterX,...) \
VALUES (%d,'%e',%f,...)
I still get

../gamemodes/Dialogs.pwn(674) : error 075: input line too long (after substitutions)
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com
TheLeech is offline   Reply With Quote
Old 16/01/2020, 07:26 PM   #6
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 956
Reputation: 167
Default Re: MySQL not saving Price, Type, Locked Balance ETC

Quote:
Originally Posted by TheLeech View Post
I still get

../gamemodes/Dialogs.pwn(674) : error 075: input line too long (after substitutions)

Get the community compiler, the limit is increased x8 (4095 characters per line).
__________________
Calisthenics is offline   Reply With Quote
Old 16/01/2020, 07:29 PM   #7
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default Re: MySQL not saving Price, Type, Locked Balance ETC

Quote:
Originally Posted by Calisthenics View Post
Get the community compiler, the limit is increased x8 (4095 characters per line).
Where to find that?
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com
TheLeech is offline   Reply With Quote
Old 16/01/2020, 07:39 PM   #8
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 956
Reputation: 167
Default Re: MySQL not saving Price, Type, Locked Balance ETC

https://github.com/pawn-lang/compiler/releases

Version 3.10.9 fixes const-correctness which will most likely give warnings for incorrect code (you have to fix them) but version 3.10.8 will not.
__________________
Calisthenics is offline   Reply With Quote
Old 16/01/2020, 07:56 PM   #9
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 173
Reputation: 6
Default Re: MySQL not saving Price, Type, Locked Balance ETC

doesn't insert anything into businesses now.

Code:
mysql_format(g_iHandle, querylist, sizeof(querylist), "INSERT INTO `businesses` (`ID`, `Name`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Interior`, `VirtualWorld`, `Price`, `Type`, `Owned`, `Locked`, `Balance`)\
			VALUES ('%d', '%e', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%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, BusinessInfo[id][Price], BusinessInfo[id][Type], BusinessInfo[id][Owned], BusinessInfo[id][Locked], BusinessInfo[id][Balance]);
			mysql_query(g_iHandle, querylist);
__________________
R.i.p Sa-mp.

#Save DL

2Real Roleplay is getting re-made slowly, Discord: https://discord.gg/veaG9bT
2Real Roleplay forums: 2r-rp.com

Last edited by TheLeech; 16/01/2020 at 08:41 PM.
TheLeech is offline   Reply With Quote
Old 16/01/2020, 09:08 PM   #10
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 423
Reputation: 32
Default Re: MySQL not saving Price, Type, Locked Balance ETC

check out Mysql_log!
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Business not saving price or type of creation. TheLeech Scripting Help 0 01/02/2019 09:22 PM
Team Balance and Auto Team Balance NeXoR Scripting Help 11 11/10/2016 05:31 PM
[HELP] date mysql saving format type Luca12 Scripting Help 11 09/08/2014 05:40 PM
MySQL R5 changing price, interior issue Type-R Scripting Help 12 09/06/2014 09:04 PM
mysql plugin thread locked, no downloads zgintasz Everything and Nothing 7 27/01/2013 11:17 AM


All times are GMT. The time now is 01:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.