Checking INT of key in MYSQL.
#1

Hello.

I want to show you my script if it's okay or there's any easy way that you can tell me.
By the way, It's working for me, but if there another easy way, it will help me.

Details:
I checked the INT of the key `Parked` in mysql, if this is -1, the vehicle didn't respawn, and if its 0+,
the vehicle had been respawned untill the next server restart and then it's find the XYZ of my vehicle.
In ongamemodeinit I did that it will be Parked=-1 automatically.

There's another easy and fast way? script: *Again, the code is working.
PHP код:
            new loadstrp[128], Float:VPos[3];
            
cmd strtok(cmdtextidx);
            
format(querysizeof(query), "SELECT * FROM `vehicles` WHERE `VehicleID`='%d' AND `Owner`='%s'"strval(cmd)-1GetName(playerid));
            
mysql_query(query);
            
mysql_store_result();
            if(
mysql_retrieve_row()) mysql_fetch_field_row(loadstrp"Parked");
            
mysql_free_result();
            if(
strval(loadstrp) != -1)
            {
                
GetVehiclePos(strval(loadstrp), VPos[0], VPos[1], VPos[2]);
                
SetPlayerCheckpoint(playeridVPos[0], VPos[1], VPos[2], 2);
            }
            else 
SendClientMessage(playeridWhite"You're vehicle is parked."); 
I think I didn't understand the results between "SELECT * FROM" and "SELECT", if you can give me examples
I'll be happy.
Reply
#2

I did it, tell me if that better or there's another better way:
PHP код:
            format(querysizeof(query), "SELECT `Parked` FROM `vehicles` WHERE `VehicleID`='%d' AND `Owner`='%s'"strval(cmd)-1GetName(playerid));
            
mysql_query(query);
            
mysql_store_result();
            new 
values mysql_fetch_int();
            if(
values != -1)
            {
                
GetVehiclePos(valuesVPos[0], VPos[1], VPos[2]);
                
SetPlayerCheckpoint(playeridVPos[0], VPos[1], VPos[2], 2);
            }
            else 
SendClientMessage(playeridWhite"You're vehicle is parked.");
            
mysql_free_result(); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)