SA-MP Forums Archive
Car Colors command and MySQL - 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: Car Colors command and MySQL (/showthread.php?tid=559228)



Car Colors command and MySQL - GuitarMan - 21.01.2015

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.


Re: Car Colors command and MySQL - Ironboy - 21.01.2015

You'd better show the mysql log.


Re: Car Colors command and MySQL - GuitarMan - 21.01.2015

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


Re: Car Colors command and MySQL - nGen.SoNNy - 21.01.2015

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


Re: Car Colors command and MySQL - Schneider - 21.01.2015

Watch the capitals,

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


Re: Car Colors command and MySQL - Ironboy - 21.01.2015

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);



Re: Car Colors command and MySQL - GuitarMan - 21.01.2015

Thanks! It worked!