cache_get_data problem -
zeth98 - 11.07.2015
Hi i make this stock to load my car database, this was on mysql R5 and i go to mysql R39-3
i have this error
http://i.imgur.com/nta7m7Z.png
The code from mysql r5
[spoiler]
Код HTML:
stock LoadPVehicles()
{
new result[24], index = 0;
mysql_query("SELECT * FROM `vehicles` ORDER BY `vehicles`.`CarID` ASC");
mysql_store_result();
while(mysql_retrieve_row())
{
// LOADING DATA \====================================================================/
index++;
mysql_get_field("CarID", result); vInfo[index][vCariD] = strval(result);
mysql_get_field("Model", result); vInfo[index][vModel] = strval(result);
mysql_get_field("Color1", result); vInfo[index][vColor1] = strval(result);
mysql_get_field("Color2", result); vInfo[index][vColor2] = strval(result);
mysql_get_field("Price", result); vInfo[index][vPrice] = strval(result);
mysql_get_field("Owner", result); strmid(vInfo[index][vOwner], result, false, strlen(result), 24);
mysql_get_field("vPosX", result); vInfo[index][vPosX] = floatstr(result);
mysql_get_field("vPosY", result); vInfo[index][vPosY] = floatstr(result);
mysql_get_field("vPosZ", result); vInfo[index][vPosZ] = floatstr(result);
mysql_get_field("vPosA", result); vInfo[index][vPosA] = floatstr(result);
mysql_get_field("Plate", result); strmid(vInfo[index][vPlate], result, false, strlen(result), 24);
mysql_get_field("PaintJ", result); vInfo[index][vPaintJ] = strval(result);
mysql_get_field("Locked", result); vInfo[index][vLocked] = strval(result);
mysql_get_field("Towed", result); vInfo[index][vTowed] = strval(result);
mysql_get_field("Carcode", result); vInfo[index][vCarCode] = strval(result);
mysql_get_field("Zile", result); vInfo[index][vOre] = strval(result);
mysql_get_field("KM", result); vInfo[index][vVodo] = strval(result);
mysql_get_field("Weapon1", result); vInfo[index][trWeapon1] = strval(result);
mysql_get_field("Weapon2", result); vInfo[index][trWeapon2] = strval(result);
mysql_get_field("Weapon3", result); vInfo[index][trWeapon3] = strval(result);
mysql_get_field("Weapon4", result); vInfo[index][trWeapon4] = strval(result);
mysql_get_field("Weapon5", result); vInfo[index][trWeapon5] = strval(result);
mysql_get_field("Weapon6", result); vInfo[index][trWeapon6] = strval(result);
mysql_get_field("Ammo1", result); vInfo[index][trAmmo1] = strval(result);
mysql_get_field("Ammo2", result); vInfo[index][trAmmo2] = strval(result);
mysql_get_field("Ammo3", result); vInfo[index][trAmmo3] = strval(result);
mysql_get_field("Ammo4", result); vInfo[index][trAmmo4] = strval(result);
mysql_get_field("Ammo5", result); vInfo[index][trAmmo5] = strval(result);
mysql_get_field("Ammo6", result); vInfo[index][trAmmo6] = strval(result);
mysql_get_field("FirstAid", result); vInfo[index][tMedkit] = strval(result);
mysql_get_field("Variabila", result); vInfo[index][vVariabila] = strval(result);
mysql_get_field("Wheels", result); vInfo[index][vComponent0] = strval(result); //Wheels
mysql_get_field("Nitro", result); vInfo[index][vComponent1] = strval(result);//Nitro
mysql_get_field("hydraulics", result); vInfo[index][vComponent2] = strval(result);//hydraulics
mysql_get_field("Spoiler", result); vInfo[index][vComponent3] = strval(result);//Spoiler
mysql_get_field("Hood", result); vInfo[index][vComponent4] = strval(result);//Hood
mysql_get_field("Roof", result); vInfo[index][vComponent5] = strval(result);//Roof
mysql_get_field("SideSkirts", result); vInfo[index][vComponent6] = strval(result);//SideSkirts
mysql_get_field("Lamps", result); vInfo[index][vComponent7] = strval(result);//Lamps
mysql_get_field("Exhaust", result); vInfo[index][vComponent8] = strval(result);//Exhaust
mysql_get_field("Stereo", result); vInfo[index][vComponent9] = strval(result);//Stereo
mysql_get_field("FrontBumper", result); vInfo[index][vComponent10] = strval(result);//FrontBumper
mysql_get_field("RearBumper", result); vInfo[index][vComponent11] = strval(result);//RearBumper
mysql_get_field("RightVent", result); vInfo[index][vComponent12] = strval(result);//RightVent
mysql_get_field("LeftVent", result); vInfo[index][vComponent13] = strval(result);//LeftVent
mysql_get_field("Neon", result); vInfo[index][vNeon] = strval(result);//neon
mysql_get_field("Ligts", result); vInfo[index][vLights] = strval(result);//Lights
// CREATING VEHICLE new i = index;
if(vInfo[i][vPosX] == 0.0 && vInfo[i][vPosY] == 0.0 && vInfo[i][vPosZ] == 0.0) { ++ Total_Veh_Created; /*INI_Close();*/ continue; }
new
vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
OwnedVeh(vCarID) = index;
Total_Veh_Created = vInfo[index][vCariD];
}
mysql_free_result();
printf("%d cars created!", Total_Veh_Created);
return 1;
}
[/spoiler]
And this code i maded for mysql r39-3
[spoiler]
Код HTML:
stock LoadPVehicles()
{
new index;
cache_get_data(rows, fields, handle);
mysql_tquery(handle, query, "SELECT * FROM `vehicles` ORDER BY `vehicles`.`CarID` ASC");
// LOADING DATA \====================================================================/
while(cache_num_rows())
{
index++;
cache_get_field_content(0,"CarID", temp); vInfo[index][vCariD] = strval(temp);
cache_get_field_content(0,"Model", temp); vInfo[index][vModel] =strval(temp);
cache_get_field_content(0,"Color1", temp); vInfo[index][vColor1] =strval(temp);
cache_get_field_content(0,"Color2", temp); vInfo[index][vColor2] =strval(temp);
cache_get_field_content(0,"Price", temp); vInfo[index][vPrice] =strval(temp);
cache_get_field_content(0,"Owner", temp); format(vInfo[index][vOwner], 128, temp);
cache_get_field_content(0,"vPosX", temp); vInfo[index][vPosX] = strval(temp);
cache_get_field_content(0,"vPosY", temp); vInfo[index][vPosY] = strval(temp);
cache_get_field_content(0,"vPosZ", temp); vInfo[index][vPosZ] = strval(temp);
cache_get_field_content(0,"vPosA", temp); vInfo[index][vPosA] = strval(temp);
cache_get_field_content(0,"Plate", temp); format(vInfo[index][vPlate], 128, temp);
cache_get_field_content(0,"PaintJ", temp); vInfo[index][vPaintJ] =strval(temp);
cache_get_field_content(0,"Locked", temp); vInfo[index][vLocked] =strval(temp);
cache_get_field_content(0,"Towed", temp); vInfo[index][vTowed] =strval(temp);
cache_get_field_content(0,"Carcode", temp); vInfo[index][vCarCode] =strval(temp);
cache_get_field_content(0,"Zile", temp); vInfo[index][vOre] =strval(temp);
cache_get_field_content(0,"KM", temp); vInfo[index][vVodo] =strval(temp);
cache_get_field_content(0,"Weapon1", temp); vInfo[index][trWeapon1] =strval(temp);
cache_get_field_content(0,"Weapon2", temp); vInfo[index][trWeapon2] =strval(temp);
cache_get_field_content(0,"Weapon3", temp); vInfo[index][trWeapon3] =strval(temp);
cache_get_field_content(0,"Weapon4", temp); vInfo[index][trWeapon4] =strval(temp);
cache_get_field_content(0,"Weapon5", temp); vInfo[index][trWeapon5] =strval(temp);
cache_get_field_content(0,"Weapon6", temp); vInfo[index][trWeapon6] =strval(temp);
cache_get_field_content(0,"Ammo1", temp); vInfo[index][trAmmo1] =strval(temp);
cache_get_field_content(0,"Ammo2", temp); vInfo[index][trAmmo2] =strval(temp);
cache_get_field_content(0,"Ammo3", temp); vInfo[index][trAmmo3] =strval(temp);
cache_get_field_content(0,"Ammo4", temp); vInfo[index][trAmmo4] =strval(temp);
cache_get_field_content(0,"Ammo5", temp); vInfo[index][trAmmo5] =strval(temp);
cache_get_field_content(0,"Ammo6", temp); vInfo[index][trAmmo6] =strval(temp);
cache_get_field_content(0,"FirstAid", temp); vInfo[index][tMedkit] =strval(temp);
cache_get_field_content(0,"Variabila", temp); vInfo[index][vVariabila] =strval(temp);
cache_get_field_content(0,"Wheels", temp); vInfo[index][vComponent0] = strval(temp); //Wheels
cache_get_field_content(0,"Nitro", temp); vInfo[index][vComponent1] = strval(temp);//Nitro
cache_get_field_content(0,"hydraulics",temp); vInfo[index][vComponent2] = strval(temp);//hydraulics
cache_get_field_content(0,"Spoiler",temp); vInfo[index][vComponent3] = strval(temp);//Spoiler
cache_get_field_content(0,"Hood", temp); vInfo[index][vComponent4] = strval(temp);//Hood
cache_get_field_content(0,"Roof",temp); vInfo[index][vComponent5] = strval(temp);//Roof
cache_get_field_content(0,"SideSkirts",temp); vInfo[index][vComponent6] = strval(temp);//SideSkirts
cache_get_field_content(0,"Lamps",temp); vInfo[index][vComponent7] = strval(temp);//Lamps
cache_get_field_content(0,"Exhaust",temp); vInfo[index][vComponent8] = strval(temp);//Exhaust
cache_get_field_content(0,"Stereo", temp); vInfo[index][vComponent9] = strval(temp);//Stereo
cache_get_field_content(0,"FrontBumper", temp); vInfo[index][vComponent10] = strval(temp);//FrontBumper
cache_get_field_content(0,"RearBumper", temp); vInfo[index][vComponent11] = strval(temp);//RearBumper
cache_get_field_content(0,"RightVent", temp); vInfo[index][vComponent12] = strval(temp);//RightVent
cache_get_field_content(0,"LeftVent", temp); vInfo[index][vComponent13] = strval(temp);//LeftVent
cache_get_field_content(0,"Neon", temp); vInfo[index][vNeon] = strval(temp);//neon
cache_get_field_content(0,"Ligts", temp); vInfo[index][vLights] = strval(temp);//Lights
// CREATING VEHICLE \====================================================================/
new i = index;
if(vInfo[i][vPosX] == 0.0 && vInfo[i][vPosY] == 0.0 && vInfo[i][vPosZ] == 0.0) { ++ Total_Veh_Created; /*INI_Close();*/ continue; }
new vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
OwnedVeh(vCarID) = index;
Total_Veh_Created = vInfo[index][vCariD];
printf("%d cars created!", Total_Veh_Created);
}
return 1;
}
[/spoiler]
when I start the server, he stop with that crash not responding
this is in server_log
Код HTML:
----------
Loaded log file: "server_log.txt".
----------
SA-MP Dedicated Server
----------------------
v0.3.7, ©2005-2015 SA-MP Team
[18:00:48]
[18:00:48] Server Plugins
[18:00:48] --------------
[18:00:48] Loading plugin: crashdetect
[18:00:48] CrashDetect v4.15.1 is OK.
[18:00:48] Loaded.
[18:00:48] Loading plugin: mysql
[18:00:48] >> plugin.mysql: R39-3 successfully loaded.
[18:00:48] Loaded.
[18:00:48] Loading plugin: streamer
[18:00:48]
*** Streamer Plugin v2.7.7 by Incognito loaded ***
[18:00:48] Loaded.
[18:00:48] Loading plugin: sscanf
[18:00:48]
[18:00:48] ===============================
[18:00:48] sscanf plugin loaded.
[18:00:48] © 2009 Alex "******" Cole
[18:00:48] 0.3d-R2 500 Players "dnee"
[18:00:48] ===============================
[18:00:48] Loaded.
[18:00:48] Loading plugin: LIFE-CMD
[18:00:48] *====================================================*
[18:00:48] * *
[18:00:48] * LIFE:CMD - Loaded *
[18:00:48] * *
[18:00:48] * Version: v2.0 *
[18:00:48] * *
[18:00:48] * ©2013 Kazon *
[18:00:48] * *
[18:00:48] *====================================================*
[18:00:48] Loaded.
[18:00:48] Loaded 5 plugins.
[18:00:48]
[18:00:48] Filterscripts
[18:00:48] ---------------
[18:00:48] Loading filterscript 'Harta.amx'...
[18:00:48] Loaded 1 filterscripts.
[18:00:48] [MYSQL]: Connection to database (myserver) was established!
[18:00:49]
[18:00:49]
[18:00:49] _____________________
[18:00:49] Number of vehicle models: 117
Re: cache_get_data problem -
zeth98 - 11.07.2015
What is wrong?
Re: cache_get_data problem -
Sime30 - 11.07.2015
When you SELECT something, you need to specify a callback, at least in the newest MySQL.
Like this...
pawn Код:
mysql_format(MySQLHandle, query, sizeof(query), "SELECT * FROM users WHERE PlayerName = '%e' LIMIT 1", GetName(playerid));
mysql_tquery(MySQLHandle, query, "OnPlayerLoad", "i", playerid);
And then under OnPlayerLoad you do stuff like storing variables etc.