Car Colors command and MySQL
#1

Hey!
I was trying to make a car color changing command. It does change the color, but it wont save the color values in database". So here is the code:
PHP код:
CMD:vcolor(playeridparams[])
{
    if(
GetPlayerState(playerid) != 2) return SendClientMessage(playerid0xFF0000FF"You are not driving a vehicle.");
    new 
color[2];
    if(
sscanf(params"iI(-1)"color[0], color[1]))
    {
        return 
SendClientMessage(playerid0xFF0000FF"Piemers: /vcolor [krasa1] [krasa2]");
    }
    if(
color[1] == -1color[1] = color[0]; // If color2 was left out, set it the same as color 1
    
new szSuccess[44];
    
format(szSuccesssizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i."color[0], color[1]);
    
SendClientMessage(playerid0x00FF00FFszSuccess);
    
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    new 
Query[128];
    
format(query,sizeof(query),"UPDATE `TABLE_CARS` SET `colors` = '%i, %i' WHERE `id` = '%i'"color[0], color[1], 1);
    return 
mysql_query(Query);
    return 
1;

Heres how my database looks:

http://prntscr.com/5vd34k

And heres the table Cars settings:

http://prntscr.com/5vd3kf

Also, this is how the Table_Cars define looks:

PHP код:
#define TABLE_ACCOUNT       "accounts"
#define TABLE_HOUSE         "house"
#define TABLE_BIZZ          "bizz"
#define TABLE_CARS          "cars"
#define TABLE_FRACTION      "fraction"
#define TABLE_ENTERS        "enters"
#define TABLE_PICK          "mayor"
#define TABLE_OTHER         "other"
#define TABLE_GPS           "gps"
#define TABLE_VEH           "vehicle"
#define TABLE_ATM           "atm"
#define TABLE_GANGZONE      "gangzone"
#define TABLE_MAFIA         "mafia" 
If theres more information necessary please let me know.
Reply
#2

You'd better show the mysql log.
Reply
#3

PHP код:
[01:01:56CMySQLHandler::Query() - An error has occured. (Error ID1065Query was empty)
[
01:02:23] >> mysql_queryConnection handle)
[
01:02:23CMySQLHandler::Query() - An error has occured. (Error ID1065Query was empty)
[
01:02:25] >> mysql_queryConnection handle)
[
01:02:25CMySQLHandler::Query() - An error has occured. (Error ID1065Query was empty) 
Here it is.
Just after i used the command, it says that the Query was empty. But how could it be empty? =o
Reply
#4

pawn Код:
new Query[128];
format(Query,sizeof(Query),"UPDATE `TABLE_CARS` SET `colors` = '%i, %i' WHERE `id` = 1", color[0], color[1] );
change these lines
Reply
#5

Watch the capitals,

you're formatting 'query' (with lower-case q and use 'Query' (with capital Q) in the mysql-function.
Reply
#6

When you're using a define for the table use it inside the quotation mark as shown below

pawn Код:
format(query,sizeof(query),"UPDATE `"TABLE_CARS"` SET `colors` = '%i, %i' WHERE `id` = '%i'", color[0], color[1], 1);
Reply
#7

Thanks! It worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)