28.01.2017, 14:17
Hey everyone,
So I need a little help with my gamemode and I have a problem with my vehicle color saving ( MYSQL )
Here it is.
the color is sometimes saving and sometimes not. Can anyone help me with this?
Sorry for my bad english.
So I need a little help with my gamemode and I have a problem with my vehicle color saving ( MYSQL )
Here it is.
Код:
stock LoadPlayerVehicle(playerid) { new query[74]; format(query, sizeof(query), "SELECT * FROM `vehicle` WHERE `Savininkas` = '%s'", GetPlayerNameEx(playerid)); mysql_query(query); mysql_store_result(); if(mysql_retrieve_row()) { new vModel,Float:vPos[4],color[2], result[256], Mslotas[14]; mysql_fetch_field_row(result, "Modelis"); vModel = strval(result); mysql_fetch_field_row(result, "xPos"); vPos[0] = floatstr(result); mysql_fetch_field_row(result, "yPos"); vPos[1] = floatstr(result); mysql_fetch_field_row(result, "zPos"); vPos[2] = floatstr(result); mysql_fetch_field_row(result, "cPos"); vPos[3] = floatstr(result); mysql_fetch_field_row(result, "Color1"); color[0] = strval(result); mysql_fetch_field_row(result, "Color2"); color[1] = strval(result); zInfo[playerid][Transportas1] = _CreateVehicle(vModel, vPos[0], vPos[1], vPos[2]+1, vPos[3], color[0], color[1], -1); mysql_fetch_field_row(result, "DegaluTipas"); tInfo[zInfo[playerid][Transportas1]][DegaluTipas] = strval(result); mysql_fetch_field_row(result, "Radijas"); if(strval(result) > 0) tInfo[zInfo[playerid][Transportas1]][Radijas] = true; else tInfo[zInfo[playerid][Transportas1]][Radijas] = false; mysql_fetch_field_row(result, "Registruota"); if(strval(result) > 0) tInfo[zInfo[playerid][Transportas1]][Registruota] = true; else tInfo[zInfo[playerid][Transportas1]][Registruota] = false; mysql_fetch_field_row(result, "Technikine"); if(strval(result) > 0) tInfo[zInfo[playerid][Transportas1]][Technikine] = true; else tInfo[zInfo[playerid][Transportas1]][Technikine] = false; mysql_fetch_field_row(result, "Tranzitiniai"); format(tInfo[zInfo[playerid][Transportas1]][Tranzitiniai], 24, "%s", result); mysql_fetch_field_row(result, "Raides"); format(tInfo[zInfo[playerid][Transportas1]][Raides], 24, "%s", result); mysql_fetch_field_row(result, "Skaiciai"); format(tInfo[zInfo[playerid][Transportas1]][Skaiciai], 24, "%s", result); mysql_fetch_field_row(result, "Degalai"); tInfo[zInfo[playerid][Transportas1]][Degalai] = strval(result); mysql_fetch_field_row(result, "Rida"); tInfo[zInfo[playerid][Transportas1]][Rida] = floatstr(result); mysql_fetch_field_row(result, "Gyvybes"); tInfo[zInfo[playerid][Transportas1]][vHeal] = floatstr(result); mysql_fetch_field_row(result, "Savininkas"); format(tInfo[zInfo[playerid][Transportas1]][Savininkas], 24, "%s", result); mysql_fetch_field_row(result, "PaintJob"); tInfo[zInfo[playerid][Transportas1]][Paintjob] = strval(result); mysql_fetch_field_row(result, "mParduodamaKaina"); tInfo[zInfo[playerid][Transportas1]][mParduodamaKaina] = strval(result); mysql_fetch_field_row(result, "MasinaParduodama"); tInfo[zInfo[playerid][Transportas1]][MasinaParduodama] = !!strval(result); for(new t = 0; t < 13; t ++) { format(result,sizeof(result),"Tuningas%d",t); mysql_fetch_field_row(query, result); Mslotas[t] = strval(query); AddVehicleComponent(zInfo[playerid][Transportas1],Mslotas[t]) ; } if(tInfo[zInfo[playerid][Transportas1]][Technikine]) { new numeriz[24]; format(numeriz, 24, "%s:%s", tInfo[zInfo[playerid][Transportas1]][Raides], tInfo[zInfo[playerid][Transportas1]][Skaiciai]); SetVehicleNumberPlate(zInfo[playerid][Transportas1], numeriz); } else if(!tInfo[zInfo[playerid][Transportas1]][Technikine]) { new numeriz[24]; format(numeriz, 24, "%s.%s", tInfo[zInfo[playerid][Transportas1]][Raides], tInfo[zInfo[playerid][Transportas1]][Skaiciai]); SetVehicleNumberPlate(zInfo[playerid][Transportas1], numeriz); } if(!tInfo[zInfo[playerid][Transportas1]][Registruota]) { new tranzai[24]; format(tranzai, 24, "%s", tInfo[zInfo[playerid][Transportas1]][Tranzitiniai]); SetVehicleNumberPlate(zInfo[playerid][Transportas1], tranzai); } tInfo[zInfo[playerid][Transportas1]][Uzraktas] = true; tInfo[zInfo[playerid][Transportas1]][vOwned] = true; zInfo[playerid][Transportas1] = zInfo[playerid][Transportas1]; SetVehicleToRespawn(zInfo[playerid][Transportas1]); } mysql_free_result(); printf("%s Transportai uћkrauti", GetPlayerNameEx(playerid)); }
Код:
stock SavePlayerVehicle(playerid, bool:atsijungia) { if(zInfo[playerid][zaidzia] == 3) { if(zInfo[playerid][Transportas1] !=-1) { new GTCount = GetTickCount(); new query[500],Float:vPos[4],vehicleid = zInfo[playerid][Transportas1],vModel; GetVehiclePos(vehicleid, vPos[0], vPos[1], vPos[2]); GetVehicleZAngle(vehicleid, vPos[3]); vModel = GetVehicleModel(vehicleid); format(query, sizeof(query), "UPDATE `vehicle` SET `Modelis`='%i', `xPos`='%f', `yPos`='%f', `zPos`='%f', `cPos`='%f' WHERE ( `Savininkas` = '%s' )", vModel, vPos[0], vPos[1], vPos[2], vPos[3], GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Savininkas`='%s', `DegaluTipas`='%i', `Degalai`='%i', `Color1`='%i', `Color2`='%i' WHERE ( `Savininkas` = '%s' )", tInfo[vehicleid][Savininkas], tInfo[vehicleid][DegaluTipas], tInfo[vehicleid][Degalai], tInfo[zInfo[playerid][Transportas1]][Color1], tInfo[zInfo[playerid][Transportas1]][Color2], GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET PaintJob = '%d', `Rida`='%f', `Gyvybes`='%f' WHERE ( `Savininkas` = '%s' )",tInfo[vehicleid][Paintjob],tInfo[vehicleid][Rida], tInfo[vehicleid][vHeal], GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET MasinaParduodama = '%d', mParduodamaKaina = '%d' WHERE Savininkas = '%s'",tInfo[vehicleid][MasinaParduodama],tInfo[vehicleid][mParduodamaKaina],GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Radijas`='%i', `Registruota`='%i', `Tranzitiniai`='%s', `Raides`='%s', `Skaiciai`='%s' WHERE ( `Savininkas` = '%s' )", tInfo[vehicleid][Radijas], tInfo[vehicleid][Registruota], tInfo[vehicleid][Tranzitiniai], tInfo[vehicleid][Raides], tInfo[vehicleid][Skaiciai], GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Technikine`='%i' WHERE ( `Savininkas` = '%s' )", tInfo[vehicleid][Technikine], GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Tuningas0`='%i', `Tuningas1`='%i', `Tuningas2`='%i', `Tuningas3`='%i', `Tuningas4`='%i' WHERE ( `Savininkas` = '%s' )", GetVehicleComponentInSlot(vehicleid, 0), GetVehicleComponentInSlot(vehicleid, 1), GetVehicleComponentInSlot(vehicleid, 2), GetVehicleComponentInSlot(vehicleid, 3), GetVehicleComponentInSlot(vehicleid, 4), GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Tuningas5`='%i', `Tuningas6`='%i', `Tuningas7`='%i', `Tuningas8`='%i', `Tuningas9`='%i' WHERE ( `Savininkas` = '%s' )", GetVehicleComponentInSlot(vehicleid, 5), GetVehicleComponentInSlot(vehicleid, 6), GetVehicleComponentInSlot(vehicleid, 7), GetVehicleComponentInSlot(vehicleid, 8), GetVehicleComponentInSlot(vehicleid, 9), GetPlayerNameEx(playerid)); mysql_query(query); format(query, sizeof(query), "UPDATE `vehicle` SET `Tuningas10`='%i', `Tuningas11`='%i', `Tuningas12`='%i', `Tuningas13`='%i' WHERE ( `Savininkas` = '%s' )", GetVehicleComponentInSlot(vehicleid, 10), GetVehicleComponentInSlot(vehicleid, 11), GetVehicleComponentInSlot(vehicleid, 12), GetVehicleComponentInSlot(vehicleid, 13), GetPlayerNameEx(playerid)); mysql_query(query); if(atsijungia == true) { DestroyVehicle(vehicleid); } printf("Ћaidėjo transporto saugojimas uћtruko %d ms", GetTickCount() - GTCount); printf("Spalva1 - %i",tInfo[vehicleid][Color1]); printf("Spalva2 - %i",tInfo[vehicleid][Color2]); } } mysql_free_result(); }
Sorry for my bad english.