Get a field on OnPlayerEnterVehicle
#1

Hi, i want to get vehicles i am entering in, ID field in mysql, how should i do that?
Reply
#2

create a field ( column ) in your table called `ID` or something
if you use phpmyadmin, go to the `index` icon, and create an index on the column
when you have done this, edit the field, under 'extra' you can select 'auto increment'

(note: there is a way to do this with a query, check your SQL syntax guide place )

Now every time you INSERT INTO your table, the row will be assigned a unique ID number, which you can retrieve with
pawn Код:
mysql_insert_id();
Reply
#3

Thank's for post. But the problem is that, I allready have everything you said. I load vehicles using loop and every thing is just fine. But when i connect to server and i wan't to check if vehicle is locked i need to take information from the db. I need to SELECT the current vehicle's ID from the DB to get other fields using this:

pawn Код:
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE ID= %d", HERE_IS_SOMETHING_I_CANT_GET);
Reply
#4

then you need to store the sql ID in the vehicle array, and use the samp vehicle ID to get the sql ID, and use this in your query.

Really you should be using SQL to load the vehicles, and the array to manage locked / unlocked etc, but its your script .. so
Reply
#5

pawn Код:
new Query[256];
    for(new id; id < MAX_VEHICLES; id++) // Makes an loop so all vehicles get loaded.
    {
        format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE ID= %d", id);
        mysql_query(Query); // Querys the "Query" Variable.
        mysql_store_result(); // Stores the result from Query
        if(mysql_num_rows()) // Checks if theres anyrow.
        if(mysql_fetch_row_format(Query,"|"))
        {
            sscanf(Query, "p<|>e<ds[25]dffffdddddddddddddddddddds[20]s[20]>",vInfo[id]);
This is where i load vehicles, but later the information i get here not works. That's the main problem.
Reply
#6

Anyone can help how to get information on other callbacks?
Reply
#7

No one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)