SA-MP Forums Archive
Get String MySql to Spawn Vehicle - 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: Get String MySql to Spawn Vehicle (/showthread.php?tid=379407)



Get String MySql to Spawn Vehicle [REP +] - pepy - 21.09.2012

Hi Guys,
I have problem, I don't know how I can try a method to get a string from my db and to use the information received from the string.
This is an example.

Thi is my db (test=>playervehicles)
I want to spawn all vehicle in my db.
How Can I do it?


Re: Get String MySql to Spawn Vehicle - pepy - 21.09.2012

I want to Spawn all vehicle in the list, I think isn't difficult!


Re: Get String MySql to Spawn Vehicle - pepy - 21.09.2012

Please Help me!


Re: Get String MySql to Spawn Vehicle - [HiC]TheKiller - 22.09.2012

Are you using the R7 mysql plugin or the R6 mysql plugin? You also should be saving the floats in the database as floats / strings rather than ints because those positions that you have don't exist without a '.' in the middle .


Re: Get String MySql to Spawn Vehicle - pepy - 22.09.2012

I use R5 version, for the float i fix them now


Re: Get String MySql to Spawn Vehicle - pepy - 22.09.2012

Please help me!


Re: Get String MySql to Spawn Vehicle - pepy - 23.09.2012

UP!!!


Re: Get String MySql to Spawn Vehicle - mamorunl - 23.09.2012

You can use a select statement to get all information about the vehicle:
SELECT * FROM playervehicles

Then you can retrieve the info like this:
new ret = mysql_query("SELECT * FROM playervehicles");
new row;
while(row = mysql_fetch_array(ret)) {
CreateVehicle(pvModel, pvPosX, pvPosY, pvPosZ, pvPosZAngle, pvColor1, pvColor2);
}

If you want to save the owner etc as well then you'd have to set your variables in the enum for the vehicle info.

Disclaimer: This post contains no actual working code. You'd have to edit this code for it to work as this is only an example. My mysql plugin version is R7 so it works differently. I'd recommend you update your plugin to R7 as well as it is way faster


Re: Get String MySql to Spawn Vehicle - pepy - 23.09.2012

I use R5


Re: Get String MySql to Spawn Vehicle - mamorunl - 23.09.2012

That is very nice of you. I gave you an example, it is your job to finish the code We aren't here to give you copy -paste code