saving car model & position into MySQL db -
justjamie - 26.05.2016
Hello.
I'm making a mysql car saving system, but it only puts the owner into the database, the modelid, the x,y,z,r variables don't get put into the database, and i have no idea why.
Someone got a idea?
Create car command:
PHP код:
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);
createPlayerCar:
PHP код:
createPlayerCar(playerid,mID,Float:xc,Float:yc,Float:zc,Float:rc,temp_color1,temp_color2,temp_autorespawn)
{
for(new i=0; i< sizeof(Vehicles); i++)
{
format(cInfo[i][carowner],MAX_PLAYER_NAME,"%s",PlayerName(playerid));
cInfo[i][c_x]=xc;
cInfo[i][c_y]=yc;
cInfo[i][c_z]=zc;
cInfo[i][c_r]=rc;
cInfo[i][c_color1]=temp_color1;
cInfo[i][c_color2]=temp_color2;
cInfo[i][c_autorespawn]=temp_autorespawn;
cInfo[i][carmodelid]= mID;
cInfo[i][db_id]= CreateVehicle(mID,xc,yc,zc,rc,temp_color1,temp_color2,temp_autorespawn);
saveCarToDB(playerid,db_id);
return 1;
}
return 1;
}
saveCarToDB:
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,"","");
}
if you need more info to help me, please say so.
Re: saving car model & position into MySQL db -
justjamie - 26.05.2016
hmm i see i need to retrieve the id in the database somehow.
Someone any idea on how i should do that?
:/