MySQL car saving system -
justjamie - 23.05.2016
Hello,
i'm trying to make a mysql car saving system, everything works fine, except r(rotation),doesn't get stored in the database, while everything else does.
And when the car is created, the rotation works just fine.
Only in the database a = 0.000000
PHP код:
createPlayerCar(playerid,mID,Float:x,Float:y,Float:z,Float:temp_r,temp_color1,temp_color2,temp_autorespawn)
{
for(new i=0; i< sizeof(cInfo); i++)
{
if(cInfo[i][id_x]!=0)continue;
format(cInfo[i][carowner],MAX_PLAYER_NAME,"%s",PlayerName(playerid));
cInfo[i][c_x]=x;
cInfo[i][c_y]=y;
cInfo[i][c_z]=z;
cInfo[i][c_r]=r;
cInfo[i][c_color1]=temp_color1;
cInfo[i][c_color2]=temp_color2;
cInfo[i][c_autorespawn]=temp_autorespawn;
cInfo[i][carmodelid]= mID;
cInfo[i][id_x]= CreateVehicle(mID,x,y,z,r,temp_color1,temp_color2,temp_autorespawn);
saveCarToDB(playerid,id_x);
return 1;
}
return 1;
}
PHP код:
saveCarToDB(playerid,carid)
{
new query[128];
format(query,sizeof(query),"INSERT INTO vehicles(owner,model,x,y,z,a) VALUES ('%s','%i','%f','%f','%f','%f')",cInfo[playerid][carowner],cInfo[carid][carmodelid],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
mysql_function_query(dbhandle,query,false,"","");
}
PHP код:
//my command :3
else if(!strcmp(tmp, "create", true, 4))
{
if(PlayerInfo[playerid][power] < 4) return SendClientError(playerid, CANT_USE_CMD);
new mID;
if(!strlen(tmp2)) return SCP(playerid, "create [model name / model id]");
if(!IsNumeric(tmp2)) mID = ModelFromName(tmp2);
if(mID == -1 || mID < 400 || mID > 611) return SendClientError(playerid, "Invalid model!");
new Float:xc,Float:yc,Float:zc,Float:rc;
GetPlayerPos(playerid,xc,yc,zc);
GetPlayerFacingAngle(playerid,rc);
createPlayerCar(playerid,mID,xc,yc,zc,rc,1,1,-1);
What did i do wrong?
Re: MySQL car saving system -
Vince - 23.05.2016
PHP код:
cInfo[i][c_r]=r;
Where is "r" coming from, exactly? I don't see any reference to it. I only see "temp_r". Are you ignoring warnings?
Re: MySQL car saving system -
AdrianG - 23.05.2016
You have to change
cInfo[i][c_r]=r; with c[Info[i][c_r]=temp_r;