SQL syntax problem
#1

Hi, I'm creating my own vehicle system for 1 month now and I'm very close from success.. But I got a problem, when I do this command IG my client crashes

Actually I got a table named "cars" where all cars are stored. On game mode init only cars that are for sales load so player who own a car must to /getcar1 to get their car which match with slot 1. Key 999 means no key.

This command is supposed to read the line number x (x is the ID of the car = player's key) of the cars table and then spawn a car with all its informations (price, owner, description, colors, etc...)
I think the problem is from the SQL syntax, so could someone help me please? Thanks in advance.
pawn Код:
if(strcmp("/getcar1", cmdtext, true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            if (PlayerInfo[playerid][pPcarkey] == 999)
            {
                SendClientMessage(playerid, COLOR_GREY, "Vous n'avez aucun vйhicule а cet emplacement.");
                return 1;
            }
            if(HasACarSpawned(playerid))
            {
                SendClientMessage(playerid, COLOR_GREY, "Vous avez dйjа un vйhicule spawned.");
                return 1;
            }
            printf("test 1");
            new car = PlayerInfo[playerid][pPcarkey];
            new fields[25][40];
            new Float:park_x, Float:park_y, Float:park_z, Float:park_a;
            format(sql, sizeof(sql), "SELECT * FROM cars WHERE id=%d", car);
            printf("test 2");
            samp_mysql_query(sql);
            samp_mysql_store_result();
            printf("test 3");
            new model = strval(fields[1]);
            new Float: x = floatstr(fields[2]);
            new Float: y = floatstr(fields[3]);
            new Float: z = floatstr(fields[4]);
            new Float: angle = floatstr(fields[5]);
            park_x = floatstr(fields[6]);
            park_y = floatstr(fields[7]);
            park_z = floatstr(fields[8]);
            park_a = floatstr(fields[9]);
            if (park_x != 0 && park_y != 0 && park_z != 0)
          {
            x = park_x;
                y = park_y;
                z = park_z;
                angle = park_a;
          }
            new ColorOne = strval(fields[10]);
            new ColorTwo = strval(fields[11]);
            new Value = strval(fields[18]);
      new carspawned = CreateVehicle(model,x,y,z,angle, ColorOne,ColorTwo, 9999);
      printf("test 3.5");
            format(string, 24, fields[17]);
            memcpy(CarInfo[carspawned][cOwner], sendername, 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
            memcpy(CarInfo[carspawned][cDescription], string, 0, 32*4, 32*4);
      printf("test 4");
            SetPlayerCheckpoint(playerid, x, y, z, 5.0);
            printf("test 5");
            TmpCarKeys[playerid] = carspawned;
            TmpCarID[carspawned] = PlayerInfo[playerid][pPcarkey];
            Engine[carspawned] = 0;
            CarInfo[carspawned][cType] = 2;
            CarInfo[carspawned][cColorOne] = ColorOne;
            CarInfo[carspawned][cColorTwo] = ColorTwo;
            CarInfo[carspawned][cLock] = 0;
            CarInfo[carspawned][cOwned] = 1;
            CarInfo[carspawned][cValue] = Value;
            CarInfo[carspawned][cLocationx] = x;
            CarInfo[carspawned][cLocationy] = y;
            CarInfo[carspawned][cLocationz] = z;
            CarInfo[carspawned][cAngle] = angle;
            printf("test 6");
            SendClientMessage(playerid, COLOR_YELLOW, "Vйhicule spawned.");
            return 1;
        }
        return 1;
    }
Well the debug works well, I see all "test" texts in server log... Any idea please?
Reply
#2

Well, any help please?
Reply
#3

It belongs to a relased script, I dunno the name, Ask in their topic.
Reply
#4

Quote:
Originally Posted by MenaceX^
It belongs to a relased script, I dunno the name, Ask in their topic.
I did make it myself -_-'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)