Checking INT of key in 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: Checking INT of key in MYSQL. (
/showthread.php?tid=412277)
Checking INT of key in MYSQL. -
Activest - 01.02.2013
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(cmdtext, idx);
format(query, sizeof(query), "SELECT * FROM `vehicles` WHERE `VehicleID`='%d' AND `Owner`='%s'", strval(cmd)-1, GetName(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(playerid, VPos[0], VPos[1], VPos[2], 2);
}
else SendClientMessage(playerid, White, "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.
Re: Checking INT of key in MYSQL. -
Activest - 01.02.2013
I did it, tell me if that better or there's another better way:
PHP код:
format(query, sizeof(query), "SELECT `Parked` FROM `vehicles` WHERE `VehicleID`='%d' AND `Owner`='%s'", strval(cmd)-1, GetName(playerid));
mysql_query(query);
mysql_store_result();
new values = mysql_fetch_int();
if(values != -1)
{
GetVehiclePos(values, VPos[0], VPos[1], VPos[2]);
SetPlayerCheckpoint(playerid, VPos[0], VPos[1], VPos[2], 2);
}
else SendClientMessage(playerid, White, "You're vehicle is parked.");
mysql_free_result();