SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 06/09/2016, 11:23 AM   #21
Max_Andolini
Huge Clucker
 
Max_Andolini's Avatar
 
Join Date: Oct 2013
Posts: 320
Reputation: 34
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by morris91 View Post
Im trying to make it so on attachment edit, it adds the floats etc.. to the row that correctly corresponds to the Username & Slot.

Code:
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
      new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", index);
Getting a argument 6 so guessing im missing something out.
Anyone can help? il be greatfull
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", index);

Change This

new handle = SQL::OpenEx(SQL::UPDATE2, "ATTACHMENTS", "Username", pNick(playerid), "Slot", index);
Max_Andolini is online now   Reply With Quote
Old 06/09/2016, 11:25 AM   #22
morris91
Big Clucker
 
morris91's Avatar
 
Join Date: Feb 2008
Location: London, England
Posts: 170
Reputation: 32
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by eco1999 View Post
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", index);

Change This

new handle = SQL::OpenEx(SQL::UPDATE2, "ATTACHMENTS", "Username", pNick(playerid), "Slot", index);
i Use
#define ATTACHMENTS "Attachments"

Just ease of mind, i did try just "Attachments" but still get the error.
morris91 is offline   Reply With Quote
Old 06/09/2016, 12:16 PM   #23
Max_Andolini
Huge Clucker
 
Max_Andolini's Avatar
 
Join Date: Oct 2013
Posts: 320
Reputation: 34
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by morris91 View Post
i Use
#define ATTACHMENTS "Attachments"

Just ease of mind, i did try just "Attachments" but still get the error.
Use this;

new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", "", index);
Max_Andolini is online now   Reply With Quote
Old 06/09/2016, 12:21 PM   #24
F1N4L
High-roller
 
F1N4L's Avatar
 
Join Date: Jun 2013
Location: Brazil
Posts: 2,676
Reputation: 242
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by eco1999 View Post
Use this;

new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", "", index);
Or

Code:
new handle = SQL::OpenEx(SQL::UPDATE2, ATTACHMENTS, "Username", pNick(playerid), "Slot", "", index);
F1N4L is offline   Reply With Quote
Old 06/09/2016, 12:52 PM   #25
morris91
Big Clucker
 
morris91's Avatar
 
Join Date: Feb 2008
Location: London, England
Posts: 170
Reputation: 32
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by eco1999 View Post
Use this;

new handle = SQL::OpenEx(SQL::UPDATE2, ""ATTACHMENTS"", "Username", pNick(playerid), "Slot", "", index);
That worked. thanks
morris91 is offline   Reply With Quote
Old 15/09/2016, 03:37 PM   #26
Max_Andolini
Huge Clucker
 
Max_Andolini's Avatar
 
Join Date: Oct 2013
Posts: 320
Reputation: 34
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

3.3 version updated.
Max_Andolini is online now   Reply With Quote
Old 07/11/2016, 01:30 AM   #27
vernz
Huge Clucker
 
vernz's Avatar
 
Join Date: Dec 2010
Posts: 234
Reputation: 6
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

How do you delete a row from the db houses by example ?
vernz is offline   Reply With Quote
Old 07/11/2016, 08:20 AM   #28
Max_Andolini
Huge Clucker
 
Max_Andolini's Avatar
 
Join Date: Oct 2013
Posts: 320
Reputation: 34
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by vernz View Post
How do you delete a row from the db houses by example ?
Code:
	native SQL::DeleteRow(const table[], const column[] = "", columnID = -1, limit = -1, limit2 = -1);
	native SQL::DeleteRow2(const table[], const column[] = "", columnID = -1, const column2[] = "", columnID2 = -1, const columnID3[] = "", limit = -1, limit2 = -1);
	native SQL::DeleteRow3(const table[], const column[] = "", type = 'i', {Float,_}:...);
	native SQL::DeleteRowEx(const table[], const column[] = "", const columnID[] = "", limit = -1, limit2 = -1);
	native SQL::DeleteRowEx2(const table[], const column[] = "", const columnID[] = "", const column2[] = "", const columnID2[] = "", columnID3 = -1, limit = -1, limit2 = -1);
Code:
SQL::DeleteRow("houses", "ID", id);
Max_Andolini is online now   Reply With Quote
Old 11/11/2016, 02:12 PM   #29
Unrea1
Gangsta
 
Unrea1's Avatar
 
Join Date: Oct 2013
Location: Venezuela
Posts: 866
Reputation: 123
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

The following code takes too long compared to just working directly with MySQL include ...

Code:
cargar_autos()
{
    // for (new v = 0; v < MAX_VEHICLES; v++) IDCars[v] = false;
    new rows = SQL::CountRows("autos");
    new index;
    for (new i = 0; i < rows + 1; i++)
    {
    	if(SQL::RowExists("autos", "vID", i))
        {
	    	index++;

		    for(new slotmaletero = 1; slotmaletero != 4; slotmaletero++) vehTrunkCounter[i] = 0;

		    svAutos[i][vModelo] = SQL::GetIntEntry("autos", "vModelo", "vID", i);
			svAutos[i][vFaccion] = SQL::GetIntEntry("autos", "vFaccion", "vID", i);
			svAutos[i][vPosX] = Float:SQL::GetFloatEntry("autos", "vPosX", "vID", i);
			svAutos[i][vPosY] = Float:SQL::GetFloatEntry("autos", "vPosY", "vID", i);
			svAutos[i][vPosZ] = Float:SQL::GetFloatEntry("autos", "vPosZ", "vID", i);
			svAutos[i][vPosA] = Float:SQL::GetFloatEntry("autos", "vPosA", "vID", i);
			svAutos[i][vColor1] = SQL::GetIntEntry("autos", "vColor1", "vID", i);
			svAutos[i][vColor2] = SQL::GetIntEntry("autos", "vColor2", "vID", i);
			svAutos[i][vRespawn] = SQL::GetIntEntry("autos", "vRespawn", "vID", i);
			svAutos[i][vGasolina] = SQL::GetIntEntry("autos", "vGasolina", "vID", i);
			vehTrunkArmour[i] = Float:SQL::GetFloatEntry("autos", "vChaleco", "vID", i);

			i = GetFreeVehicleSlot();
		  	svAutos[i][vID] = CreateVehicle(svAutos[i][vModelo], svAutos[i][vPosX], svAutos[i][vPosY], svAutos[i][vPosZ], svAutos[i][vPosA], svAutos[i][vColor1], svAutos[i][vColor2], svAutos[i][vRespawn]);
		    IDCars[i] = true;

			if(vehTrunk[i][1] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;
			if(vehTrunk[i][2] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;
			if(vehTrunk[i][3] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;

			SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0);

		   	new vHP = minrand(0, 9);
		   	switch(vHP)
		   	{
		   		case 0..7: SetVehicleHealth(i, 401.0);
		   		case 8: SetVehicleHealth(i, 500.0);
		   		case 9: SetVehicleHealth(i, 999.0);
		   	}

		   	if(VehiculosNoPuenteables(svAutos[i][vModelo]))
		   	{
		   	    svAutos[i][vGasolina] = 100;
				SetVehicleParamsEx(i, 1, 0, 0, 0, 0, 0, 0);
			}
		}
    }
    printf(" Autos cargados: %i", index);
    return true;
}
They are 952 vehicles (per moment), on localhost the server without the include is delayed loading 2 to 3 seconds all cars, with the delay delay up to 20 seconds, have I misused the functions of the include ?, greetings.
Unrea1 is offline   Reply With Quote
Old 11/11/2016, 02:33 PM   #30
Max_Andolini
Huge Clucker
 
Max_Andolini's Avatar
 
Join Date: Oct 2013
Posts: 320
Reputation: 34
Default Re: Easy MySQL - Simplifying the usage of MySQL queries!

Quote:
Originally Posted by LatinZ View Post
The following code takes too long compared to just working directly with MySQL include ...

Code:
cargar_autos()
{
    // for (new v = 0; v < MAX_VEHICLES; v++) IDCars[v] = false;
    new rows = SQL::CountRows("autos");
    new index;
    for (new i = 0; i < rows + 1; i++)
    {
    	if(SQL::RowExists("autos", "vID", i))
        {
	    	index++;

		    for(new slotmaletero = 1; slotmaletero != 4; slotmaletero++) vehTrunkCounter[i] = 0;

		    svAutos[i][vModelo] = SQL::GetIntEntry("autos", "vModelo", "vID", i);
			svAutos[i][vFaccion] = SQL::GetIntEntry("autos", "vFaccion", "vID", i);
			svAutos[i][vPosX] = Float:SQL::GetFloatEntry("autos", "vPosX", "vID", i);
			svAutos[i][vPosY] = Float:SQL::GetFloatEntry("autos", "vPosY", "vID", i);
			svAutos[i][vPosZ] = Float:SQL::GetFloatEntry("autos", "vPosZ", "vID", i);
			svAutos[i][vPosA] = Float:SQL::GetFloatEntry("autos", "vPosA", "vID", i);
			svAutos[i][vColor1] = SQL::GetIntEntry("autos", "vColor1", "vID", i);
			svAutos[i][vColor2] = SQL::GetIntEntry("autos", "vColor2", "vID", i);
			svAutos[i][vRespawn] = SQL::GetIntEntry("autos", "vRespawn", "vID", i);
			svAutos[i][vGasolina] = SQL::GetIntEntry("autos", "vGasolina", "vID", i);
			vehTrunkArmour[i] = Float:SQL::GetFloatEntry("autos", "vChaleco", "vID", i);

			i = GetFreeVehicleSlot();
		  	svAutos[i][vID] = CreateVehicle(svAutos[i][vModelo], svAutos[i][vPosX], svAutos[i][vPosY], svAutos[i][vPosZ], svAutos[i][vPosA], svAutos[i][vColor1], svAutos[i][vColor2], svAutos[i][vRespawn]);
		    IDCars[i] = true;

			if(vehTrunk[i][1] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;
			if(vehTrunk[i][2] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;
			if(vehTrunk[i][3] != 0) vehTrunkCounter[i]++, SlotsV[i] ++;

			SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0);

		   	new vHP = minrand(0, 9);
		   	switch(vHP)
		   	{
		   		case 0..7: SetVehicleHealth(i, 401.0);
		   		case 8: SetVehicleHealth(i, 500.0);
		   		case 9: SetVehicleHealth(i, 999.0);
		   	}

		   	if(VehiculosNoPuenteables(svAutos[i][vModelo]))
		   	{
		   	    svAutos[i][vGasolina] = 100;
				SetVehicleParamsEx(i, 1, 0, 0, 0, 0, 0, 0);
			}
		}
    }
    printf(" Autos cargados: %i", index);
    return true;
}
They are 952 vehicles (per moment), on localhost the server without the include is delayed loading 2 to 3 seconds all cars, with the delay delay up to 20 seconds, have I misused the functions of the include ?, greetings.
Try this.

Code:
cargar_autos()
{
    new vid;
    new handle = SQL::Open(SQL::MTREAD, "autos"); 
    SQL_GetCallback(handle, i) 
    { 
		SQL::ReadInt(handle, "vID", vid, i); 
		SQL::ReadInt(handle, "vModelo", svAutos[vid][vModelo], i);
		SQL::ReadInt(handle, "vFaccion", svAutos[vid][vFaccion], i);
		SQL::ReadFloat(handle, "vPosX", svAutos[vid][vPosX], i);
		SQL::ReadFloat(handle, "vPosY", svAutos[vid][vPosY], i);
		SQL::ReadFloat(handle, "vPosZ", svAutos[vid][vPosZ], i);
		SQL::ReadFloat(handle, "vPosA", svAutos[vid][vPosA], i);
		SQL::ReadInt(handle, "vColor1", svAutos[vid][vColor1], i);
		SQL::ReadInt(handle, "vColor2", svAutos[vid][vColor2], i);
		SQL::ReadInt(handle, "vRespawn", svAutos[vid][vRespawn], i);
		SQL::ReadInt(handle, "vGasolina", svAutos[vid][vGasolina], i);
		SQL::ReadFloat(handle, "vChaleco", vehTrunkArmour[vid], i);
		
		svAutos[vid][vID] = CreateVehicle(svAutos[vid][vModelo], svAutos[vid][vPosX], svAutos[vid][vPosY], svAutos[vid][vPosZ], svAutos[vid][vPosA], svAutos[vid][vColor1], svAutos[vid][vColor2], svAutos[vid][vRespawn]);
		IDCars[vid] = true;

		for(new slotmaletero = 1; slotmaletero != 4; slotmaletero++) vehTrunkCounter[vid] = 0;
		if(vehTrunk[vid][1] != 0) vehTrunkCounter[vid]++, SlotsV[vid] ++;
		if(vehTrunk[vid][2] != 0) vehTrunkCounter[vid]++, SlotsV[vid] ++;
		if(vehTrunk[vid][3] != 0) vehTrunkCounter[vid]++, SlotsV[vid] ++;

		SetVehicleParamsEx(vid, 0, 0, 0, 0, 0, 0, 0);

		new vHP = minrand(0, 9);
		switch(vHP)
		{
		   	case 0..7: SetVehicleHealth(vid, 401.0);
		   	case 8: SetVehicleHealth(vid, 500.0);
		   	case 9: SetVehicleHealth(vid, 999.0);
		}

		if(VehiculosNoPuenteables(svAutos[vid][vModelo]))
		{
		   	svAutos[vid][vGasolina] = 100;
			SetVehicleParamsEx(vid, 1, 0, 0, 0, 0, 0, 0);
		}
    } 
    new Autos = SQL::Close(handle);
    printf(" Autos cargados: %d", Autos);
    return 1;
}
Also tables are start 1.

#define SQL_GetCallback(%0,%1) if(GetCallback(%0) == 1) if(cache_num_rows()) for(new %1 = 1; %1 < cache_num_rows()+1; %1++)
Max_Andolini is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Easy MySQL 1.0 - Simplifying the usage of MySQL queries! ThePhenix Includes 93 08/01/2017 04:04 AM
[Include] Easy SQLite: Simplyfing the usage of SQLite queries! ThePhenix Includes 6 24/10/2015 05:35 PM
[Tutorial] MySQL-queries iRaiDeN Tutorials 2 21/03/2014 03:20 PM
Help with MySQL queries LiamM Scripting Help 4 20/03/2013 10:37 AM


All times are GMT. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.