SA-MP Forums

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

Closed Thread
 
Thread Tools Display Modes
Old 23/01/2015, 10:56 PM   #1
TheCartman
Huge Clucker
 
TheCartman's Avatar
 
Join Date: Mar 2013
Location: Romania
Posts: 272
Reputation: 16
Default Any wrong in this code?

Hi guys. I didn't see any wrong thing here:

Code:
format (szQuery, sizeof(szQuery), "%s, `PlayerVehicleModel1`='%d', `PlayerVehicleFacing1`='%f', `PlayerVehicle1Color`='%d', `PlayerVehicle1Color2`='%d', `PlayerVehiclePosX1`='%f'", szQuery, PlayerInfo[playerid][PlayerVehicleModel1],PlayerInfo[playerid][PlayerVehicleFacing1],PlayerInfo[playerid][pPlayerVehicle1Color],PlayerInfo[playerid][pPlayerVehicle1Color2],PlayerInfo[playerid][PlayerVehiclePosX1]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehiclePosY1`='%f', `PlayerVehiclePosZ1`='%f', `PlayerVehicle1PaintJob`='%d', `PlayerVehicle1Nos`='%d', `PlayerVehicle1ModSlot0`='%d', `PlayerVehicle1ModSlot1`='%d'", szQuery,PlayerInfo[playerid][PlayerVehiclePosY1],PlayerInfo[playerid][PlayerVehiclePosZ1],PlayerInfo[playerid][PlayerVehicle1PaintJob],PlayerInfo[playerid][PlayerVehicle1Nos],PlayerInfo[playerid][PlayerVehicle1ModSlot0],PlayerInfo[playerid][PlayerVehicle1ModSlot1]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot2`='%d', `PlayerVehicle1ModSlot3`='%d', `PlayerVehicle1ModSlot4`='%d', `PlayerVehicle1ModSlot5`='%d', `PlayerVehicle1ModSlot6`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot2],PlayerInfo[playerid][PlayerVehicle1ModSlot3],PlayerInfo[playerid][PlayerVehicle1ModSlot4],PlayerInfo[playerid][PlayerVehicle1ModSlot5],PlayerInfo[playerid][PlayerVehicle1ModSlot6]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot7`='%d', `PlayerVehicle1ModSlot8`='%d', `PlayerVehicle1ModSlot9`='%d', `PlayerVehicle1ModSlot10`='%d', `PlayerVehicle1ModSlot11`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot7],PlayerInfo[playerid][PlayerVehicle1ModSlot8],PlayerInfo[playerid][PlayerVehicle1ModSlot9],PlayerInfo[playerid][PlayerVehicle1ModSlot10],PlayerInfo[playerid][PlayerVehicle1ModSlot11]);
	
	format (szQuery, sizeof(szQuery), "%s, `PlayerVehicle1ModSlot12`='%d', `PlayerVehicle1ModSlot13`='%d', `VehLock1`='%d', `VehLocked1`='%d', `PlayerVehicle1Interior`='%d', `PlayerVehicle1VirWorld`='%d'", szQuery,PlayerInfo[playerid][PlayerVehicle1ModSlot12],PlayerInfo[playerid][PlayerVehicle1ModSlot13],PlayerInfo[playerid][pVehLock1],PlayerInfo[playerid][pVehLocked1],PlayerInfo[playerid][PlayerVehicle1Interior],PlayerInfo[playerid][PlayerVehicle1VirWorld]);
But my mysql_log say this:
Code:
[01:28:21] [ERROR] CMySQLQuery::Execute[OnQueryFinish] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`Pla' at line 1
And those lines are the singles who have "`Pla"... I didn't see anything wrong. Did you see? Thanks!
__________________
This is my work:
[Filterscript] Server Protect Attack
TheCartman is offline  
Old 23/01/2015, 11:09 PM   #2
Zume
High-roller
 
Zume's Avatar
 
Join Date: Nov 2011
Location: El Salvador
Posts: 1,642
Reputation: 311
Default Respuesta: Any wrong in this code?

The first line of the query is not necessary to add the %s, nor szQuery in the grounds of format, in another instance chain may have a lower limit to which was defined
__________________
Zume is offline  
Old 23/01/2015, 11:25 PM   #3
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: Any wrong in this code?

Why is evident that something like houses or objects gets their own separate tables, yet everything related to the player is crammed into one table? If you need to add a number to a column name then you're doing it wrong. MySQL is an RDBMS. Relational Database Management System. With the emphasis on that first word.

Each player can have zero or more vehicles. That's the first one-to-many relation. Each vehicle can have zero or mods. That's the second one-to-many relation.

__________________
Vince is offline  
Old 24/01/2015, 05:58 AM   #4
TheCartman
Huge Clucker
 
TheCartman's Avatar
 
Join Date: Mar 2013
Location: Romania
Posts: 272
Reputation: 16
Default Re: Any wrong in this code?

Quote:
Originally Posted by Vince View Post
Why is evident that something like houses or objects gets their own separate tables, yet everything related to the player is crammed into one table? If you need to add a number to a column name then you're doing it wrong. MySQL is an RDBMS. Relational Database Management System. With the emphasis on that first word.

Each player can have zero or more vehicles. That's the first one-to-many relation. Each vehicle can have zero or mods. That's the second one-to-many relation.

I know this. This is how I get the code, but it was on SQLite. I will change it. But now I need to see what's wrong here...

Quote:
Originally Posted by _Zume View Post
The first line of the query is not necessary to add the %s, nor szQuery in the grounds of format, in another instance chain may have a lower limit to which was defined

This is just a part of the query... I have ~20 lines with query format, but I think just those are problematics...
__________________
This is my work:
[Filterscript] Server Protect Attack
TheCartman is offline  
Old 24/01/2015, 02:14 PM   #5
TheCartman
Huge Clucker
 
TheCartman's Avatar
 
Join Date: Mar 2013
Location: Romania
Posts: 272
Reputation: 16
Default Re: Any wrong in this code?

Can someone help me? I see nothing wrong here...
__________________
This is my work:
[Filterscript] Server Protect Attack
TheCartman is offline  
Closed Thread

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
what's wrong with this code Strier Scripting Help 2 24/08/2013 12:13 AM
What's wrong with this code? Brandlax Scripting Help 3 27/10/2012 08:04 AM
What is wrong in that code boyan96 Scripting Help 5 26/04/2012 10:23 PM
WHat is wrong in this code? Kyle_Olsen Help Archive 6 09/12/2010 04:04 AM


All times are GMT. The time now is 11:20 AM.


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