30.01.2016, 18:11
I have been trying to make a camp system with mysql but have some issues mabye u guys can help me? also check the pic what the result is when i buy a camp didnt set the pos or anything, and u see the owner just became numbers.

EDIT
this is from the console

PHP код:
}
stock SaveCamp(campid)
{
new string[2048];
printf("Saving Camp ID %d", campid);
format(string, sizeof(string), "UPDATE `camps` SET \
`cOwner`=%d, \
`cPosX`=%f, \
`cPosY`=%f, \
`cPosZ`=%f, \
`cPosAngle`=%f, \
`cLock`=%d, \
`cVirtualWorld`=%d WHERE `id`=%d",
CampInfo[campid][cOwner],
CampInfo[campid][cPosition][0],
CampInfo[campid][cPosition][1],
CampInfo[campid][cPosition][2],
CampInfo[campid][cPosition][3],
CampInfo[campid][cLocked],
CampInfo[campid][cVW],
campid+0
); // Array starts from zero, MySQL starts at 0 (this is why we are adding one).
mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
}
PHP код:
stock LoadCamp()
{
printf("[LoadCamp] Loading data from database...");
mysql_function_query(MainPipeline, "SELECT * FROM `camps`", true, "OnLoadCamps", "");
}
PHP код:
}
forward OnLoadCamps();
public OnLoadCamps()
{
new i, rows, fields, tmp[128];
cache_get_data(rows, fields, MainPipeline);
while(i < rows)
{
cache_get_field_content(i, "sqlID", tmp, MainPipeline); CampInfo[i][cSQLID] = strval(tmp);
cache_get_field_content(i, "cOwner", tmp, MainPipeline); CampInfo[i][cOwner] = strval(tmp);
cache_get_field_content(i, "cPosX", tmp, MainPipeline); CampInfo[i][cPosition][0] = floatstr(tmp);
cache_get_field_content(i, "cPosY", tmp, MainPipeline); CampInfo[i][cPosition][1] = floatstr(tmp);
cache_get_field_content(i, "cPosZ", tmp, MainPipeline); CampInfo[i][cPosition][2] = floatstr(tmp);
cache_get_field_content(i, "cPosAngle", tmp, MainPipeline); CampInfo[i][cPosition][3] = floatstr(tmp);
cache_get_field_content(i, "cLock", tmp, MainPipeline); CampInfo[i][cLocked] = strval(tmp);
cache_get_field_content(i, "cVirtualWorld", tmp, MainPipeline); CampInfo[i][cVW] = strval(tmp);
i++;
}
if(i > 0) printf("[LoadCamps] %d Camps rehashed/loaded.", i);
else printf("[LoadCamps] Failed to load any Camps.");
}
PHP код:
if(dialogid == DIALOG_CAMPBUY)
{
if(!response) return SendClientMessage(playerid,-1,""WHITE"You are exit from Camp Trailer Buy Menu!");
if(response)
{
if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You dont have money!");
{
new szQuery[128];
new poz = random(sizeof(RandomKampSpawn));
CampInfo[playerid][cPosition][0] = RandomKampSpawn[poz][0];
CampInfo[playerid][cPosition][1] = RandomKampSpawn[poz][1];
CampInfo[playerid][cPosition][2] = RandomKampSpawn[poz][2];
CampInfo[playerid][cPosition][3] = RandomKampSpawn[poz][3];
CampInfo[playerid][cLocked] = 1;
CampInfo[playerid][cVW] = 0;
strmid(CampInfo[playerid][cOwner], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), 999);
CampInfo[playerid][cSQLID] = CreateVehicle(607, CampInfo[playerid][cPosition][0], CampInfo[playerid][cPosition][1], CampInfo[playerid][cPosition][2], CampInfo[playerid][cPosition][3], 0, 0, 100);
objekt = CreateObject(3171, 0,0,0,0,0,0);
AttachObjectToVehicle(objekt, CampInfo[playerid][cSQLID], 0.084999, -2.125115, -1.144999, -3.014999, 0.000000, 178.890090);
GivePlayerMoney(playerid,-10000);
PlayerInfo[playerid][pCampTrailer] = 1;
SaveCamp(playerid);
g_mysql_SaveAccount(playerid);
format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `CampTrailer`=%d WHERE `id` = %d", PlayerInfo[playerid][pCampTrailer]);
mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
ShowPlayerDialog(playerid,INFOBUY_DIALOG,DIALOG_STYLE_MSGBOX,""GREEN"Camp Trailer",""WHITE"You are sucessfuly buy Camp Trailer, use "GREEN"/camptrailer\n"WHITE"If you want to tow trailer use key "GREEN"'Y'"WHITE", for enter in trailer use key "GREEN"'N'","Okey","");
//break;
}
}
}
if(dialogid == DIALOG_CAMP)
{
if(!response) return 1;
if(PlayerInfo[playerid][pCampTrailer] == 0) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"Vi ne posjedujete kamp prikolicu!");
new i = PlayerInfo[playerid][pCampTrailer];
switch(listitem)
{
case 0:
{
new kPrikolica[250];
new z[5]; if(CampInfo[i][cLocked] == 1) z = "Da"; else z = "Ne";
format(kPrikolica, sizeof(kPrikolica), ""GREEN"_______________________________\n\n\
"WHITE"Locked: "WHITE"%s | "WHITE"Owner: "WHITE"%s\n\n\
"GREEN"_______________________________", z, CampInfo[i][cOwner]);
ShowPlayerDialog(playerid, DIALOG_CAMPINFO, DIALOG_STYLE_MSGBOX, ""GREEN"Camp Trailer Info", kPrikolica, "Okey", "");
}
case 1:
{
new Float:Poz[3];
GetVehiclePos(CampInfo[i][cSQLID], Poz[0], Poz[1], Poz[2]);
if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp Trailer!");
if(CampInfo[i][cLocked] == 0)
{
CampInfo[i][cLocked] = 1; SaveCamp(i);
GameTextForPlayer(playerid, "~w~Camp trailer ~r~locked", 5000, 3);
}
else
{
CampInfo[i][cLocked] = 0; SaveCamp(i);
GameTextForPlayer(playerid, "~w~Camp Trailer ~g~unlocked", 5000, 3);
}
}
case 2:
{
new Float:Poz[4];
GetVehiclePos(CampInfo[i][cSQLID], Poz[0], Poz[1], Poz[2]);
GetVehicleZAngle(CampInfo[i][cSQLID], Poz[3]);
new vehicleid = GetPlayerVehicleID(playerid);
if(!IsPlayerInVehicle(playerid,vehicleid)) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be in vehicle!");
if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp Trailer!");
if(TowedCamp[playerid] == 1)
{
CampInfo[i][cPosition][0] = Poz[0]; CampInfo[i][cPosition][1] = Poz[1];
CampInfo[i][cPosition][2] = Poz[2]; CampInfo[i][cPosition][3] = Poz[3];
DestroyVehicle(CampInfo[i][cSQLID]);
CampInfo[i][cSQLID] = CreateVehicle(607, CampInfo[i][cPosition][0], CampInfo[i][cPosition][1], CampInfo[i][cPosition][2], CampInfo[i][cPosition][3], 0, 0, -1);
SendClientMessage(playerid,-1,""RED"[!] "WHITE"Camp Trailer sucessfuly parked!");
SaveCamp(i); SetVehicleToRespawn(CampInfo[i][cSQLID]);
}
else return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to tow Camp Trailer on vehicle (Key: Y)!");
}
case 3:
{
new Float:Poz[3]; LocateCamp[playerid] = 1;
GetVehiclePos(CampInfo[i][cSQLID], Poz[0], Poz[1], Poz[2]);
SetPlayerCheckpoint(playerid, Poz[0], Poz[1], Poz[2], 4.0);
SendClientMessage(playerid,-1,""GREEN"Your Camp Trailer are marked on radar!");
}
case 4:
{
new Float:Poz[3];
GetVehiclePos(CampInfo[i][cSQLID], Poz[0], Poz[1], Poz[2]);
if(!IsPlayerInRangeOfPoint(playerid, 6.0, Poz[0], Poz[1], Poz[2])) return SendClientMessage(playerid,-1,""RED"[!] "WHITE"You need to be near your Camp trailer!");
ShowPlayerDialog(playerid,DIALOG_CAMPSELL,DIALOG_STYLE_MSGBOX,""GREEN"Sell Camp Trailer",""WHITE"Do you want sell your Camp Trailer for $5000?","Sell","Cancel");
}
}
}
if(dialogid == DIALOG_CAMPSELL)
{
if(!response) return SendClientMessage(playerid,-1,""GREEN"You have been withdrawn from the sale of Camp trailer!");
if(response)
{
new i = PlayerInfo[playerid][pCampTrailer];
DestroyVehicle(CampInfo[i][cSQLID]); DestroyObject(objekt);
//IzbrisiKampPrikolicu(PlayerInfo[playerid][pCampTrailer]);
PlayerInfo[playerid][pCampTrailer] = 0;
GivePlayerMoney(playerid,5000); //SavePlayer(playerid);
g_mysql_SaveAccount(playerid);
SendClientMessage(playerid,-1,""GREEN"You are succesfuly sold your Camp Trailer!");
SaveCamp();
}
}
this is from the console
Код:
[19:54:17] [MySQL] Query Error - (ErrorID: 1064) (Handle: 1) [19:54:17] [MySQL] Check mysql_log.txt to review the query that threw the error. [19:54:17] Dumping query from 2016/1/30 (19:54:17) Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 (index 0). Query:


