Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum eVehicleData {
- v_iModel,
- Float:v_fPos[4],
- v_iCol[2],
- MainPipeline
- }
- new
- arrVehData[MAX_VEHICLES][eVehicleData],
- szMiscArray[4096];
- public OnGameModeInit()
- {
- LoadVehicles();
- // THIS IS NOT MY ENTIRE GAMEMODEINIT
- }
- public OnGameModeExit()
- {
- SaveVehicles();
- return 1;
- }
- CMD:createveh(playerid,params[])
- {
- new vmodel,cole,colw;
- if(sscanf(params,"iii",vmodel,cole,colw))SendClientMessage(playerid,C_YELLOW,"Usage:{FFFFFF}/createveh [modelid] [col] [col]");
- else if(vmodel == INVALID_VEHICLE_ID)SendClientMessage(playerid,C_YELLOW,"Invalid Player Id Entered");
- else
- {
- new Float:iX, Float:iY, Float:iZ, Float:iA;
- GetPlayerPos(playerid, iX, iY, iZ);
- GetPlayerFacingAngle(playerid, iA);
- CreateDVehicle(vmodel, iX, iY,iZ, iA, cole, colw);
- }
- return 1;
- }
- CreateDVehicle(iModel, Float:PosX, Float:PosY, Float:PosZ, Float:Rot, iColor1, iColor2)
- {
- new iVehID = CreateVehicle(iModel, PosX, PosY, PosZ, Rot, iColor1, iColor2, 60000);
- arrVehData[iVehID][v_iModel] = iModel;
- arrVehData[iVehID][v_fPos][0] = PosX;
- arrVehData[iVehID][v_fPos][1] = PosY;
- arrVehData[iVehID][v_fPos][2] = PosZ;
- arrVehData[iVehID][v_fPos][3] = Rot;
- arrVehData[iVehID][v_iCol][0] = iColor1;
- arrVehData[iVehID][v_iCol][1] = iColor2;
- SaveVehicle(iVehID);
- }
- SaveVehicle(iVehID)
- {
- szMiscArray[0] = 0;
- format(szMiscArray, 4096, "UPDATE `vehicles` SET \
- `Model` = '%i', \
- `X` = '%f', \
- `Y` = '%f', \
- `Z` = '%f', \
- `FAngle` = '%f', \
- `Color` = '%i', \
- `Col2` = '%i' WHERE `vID` = '%i'",
- arrVehData[iVehID][v_iModel],
- arrVehData[iVehID][v_fPos][0],
- arrVehData[iVehID][v_fPos][1],
- arrVehData[iVehID][v_fPos][2],
- arrVehData[iVehID][v_fPos][3],
- arrVehData[iVehID][v_iCol][0],
- arrVehData[iVehID][v_iCol][1],
- iVehID
- );
- mysql_function_query(MainPipeline, szMiscArray, false, "", "");
- }
- SaveVehicles()
- {
- for(new v = 0; v < MAX_VEHICLES; v++) SaveVehicle(v);
- }
- LoadVehicles()
- {
- print("[Vehicle System] Load dynamic vehicles.");
- mysql_function_query(MainPipeline, "SELECT * FROM `vehicles`", false, "OnLoadVehicles", "");
- }
- PF: OnLoadVehicles()
- {
- new
- i = 0,
- iRows,
- iFields;
- szMiscArray[0] = 0;
- cache_get_data(iRows, iFields, MainPipeline);
- while(i < iRows)
- {
- cache_get_field_content(i, "Model", szMiscArray, MainPipeline); arrVehData[i][v_iModel] = strval(szMiscArray);
- cache_get_field_content(i, "X", szMiscArray, MainPipeline); arrVehData[i][v_fPos][0] = floatstr(szMiscArray);
- cache_get_field_content(i, "Y", szMiscArray, MainPipeline); arrVehData[i][v_fPos][1] = floatstr(szMiscArray);
- cache_get_field_content(i, "Z", szMiscArray, MainPipeline); arrVehData[i][v_fPos][2] = floatstr(szMiscArray);
- cache_get_field_content(i, "FAngle", szMiscArray, MainPipeline); arrVehData[i][v_fPos][3] = floatstr(szMiscArray);
- cache_get_field_content(i, "Color", szMiscArray, MainPipeline); arrVehData[i][v_iCol][0] = strval(szMiscArray);
- cache_get_field_content(i, "Color2", szMiscArray, MainPipeline); arrVehData[i][v_iCol][1] = strval(szMiscArray);
- CreateVehicle(arrVehData[i][v_iModel], arrVehData[i][v_fPos][0], arrVehData[i][v_fPos][1], arrVehData[i][v_fPos][2], arrVehData[i][v_fPos][3], arrVehData[i][v_iCol][0], arrVehData[i][v_iCol][1], 60000);
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment