D3vZ Posted February 27, 2014 Share Posted February 27, 2014 Boa Noite. Estou usando um script de fuel ( https://community.multitheftauto.com/ind ... ils&id=190 ) mas não estou usando o SQL, estou usando a versão que utiliza o XML mas não consigo entender os erros que ele me tem dado 2_ClientFuelGage function showPlayerFuel() if guiGetVisible(fuelFrame) == true or guiGetVisible(fuelFrame2) == true then guiSetVisible( fuelBar1, false ) guiSetVisible ( fuelFrame, false ) guiSetVisible (warningdot1, false ) guiSetVisible( fuelBar2, false ) guiSetVisible ( fuelFrame2, false ) guiSetVisible (warningdot2, false ) end fuelFrame = guiCreateStaticImage( 0.93, 0.68, 0.05, 0.20, "Petrol/Image/Fuel_Gage.png", true) fuelBar1 = guiCreateStaticImage( 0.952, 0.701, 0.021, 0.17, "Petrol/Image/Fuel_Dot.png", true) guiSetVisible( fuelBar1, true ) guiBringToFront ( fuelFrame ) setTimer ( decFuel1, 30000, 0, getLocalPlayer()) end addEvent("FullTank", true ) addEventHandler("FullTank", getLocalPlayer(), showPlayerFuel) addEvent("fullRefill", true) addEventHandler("fullRefill", refillName, showPlayerFuel) addEvent("fuelGageShow", true) addEventHandler("fuelGageShow", getLocalPlayer(), showPlayerFuel) function CurrentFuelIn ( currentFuel ) local sizex = currentFuel["sizex"] local sizey = currentFuel["sizey"] local posx = currentFuel["posx"] local posy = currentFuel["posy"] fuelFrame2 = guiCreateStaticImage( 0.93, 0.68, 0.05, 0.20, "Petrol/Image/Fuel_Gage.png", true) fuelBar2 = guiCreateStaticImage( tonumber(posx), tonumber(posy), tonumber(sizex), tonumber(sizey), "Petrol/Image/Fuel_Dot.png", true) guiSetVisible( fuelBar2, true ) guiBringToFront ( fuelFrame2 ) setTimer ( decFuel2, 30000, 0, getLocalPlayer()) end addEvent("CurrentFuel", true) addEventHandler("CurrentFuel", getLocalPlayer(), CurrentFuelIn) function startExit ( thePlayer ) if thePlayer == getLocalPlayer() then hidePlayerFuel() end end addEventHandler("onClientVehicleStartExit", getRootElement(), startExit ) function decFuel2() local PlayerInCar = getPlayerOccupiedVehicle( getLocalPlayer() ) if (PlayerInCar ) then local x, y = guiGetSize( fuelBar2, true ) local NewY = y - 0.001 local Posx, Posy = guiGetPosition ( fuelBar2, true ) local NewPosY = Posy + 0.001 guiSetSize(fuelBar2, x, NewY, true) guiSetPosition(fuelBar2, Posx, NewPosY, true ) local Positions = {} Positions ["Size.X"] = x Positions ["Size.Y"] = NewY Positions ["Pos.X"] = Posx Positions ["Pos.Y"] = NewPosY Positions ["VehicleId"] = getVehicleID (PlayerInCar) triggerServerEvent("Positions", getLocalPlayer(), Positions) if ( tonumber(gettok(tostring(y),1,49)) == 0.03700) then warningdot2 = guiCreateStaticImage( 0.9388, 0.802, 0.014, 0.016, "Petrol/Image/warning_dot.png", true) guiBringToFront (warningdot2) outputChatBox("You Are Quite Low On Fuel", source) elseif ( tonumber(gettok(tostring(y),1,49)) == 0.01500) then freezeCarOutOfFuel () end end end function decFuel1() local PlayerInCar = getPlayerOccupiedVehicle( getLocalPlayer() ) if (PlayerInCar ) then local x, y = guiGetSize( fuelBar1, true ) local NewY = y - 0.001 local Posx, Posy = guiGetPosition ( fuelBar1, true ) local NewPosY = Posy + 0.001 guiSetSize(fuelBar1, x, NewY, true) guiSetPosition(fuelBar1, Posx, NewPosY, true ) local Positions = {} Positions ["Size.X"] = x Positions ["Size.Y"] = NewY Positions ["Pos.X"] = Posx Positions ["Pos.Y"] = NewPosY Positions ["VehicleId"] = getVehicleID (PlayerInCar) triggerServerEvent("Positions", getLocalPlayer(), Positions) if ( tonumber(gettok(tostring(y),1,49)) == 0.03700) then warningdot1 = guiCreateStaticImage( 0.9388, 0.802, 0.014, 0.016, "Petrol/Image/warning_dot.png", true) guiBringToFront (warningdot1) outputChatBox("You Are Quite Low On Fuel", source) elseif ( tonumber(gettok(tostring(y),1,49)) == 0.01500) then freezeCarOutOfFuel () end end end function freezeCarOutOfFuel () helpGui = guiCreateWindow ( 400, 500, 200, 300, "Help", false ) outFuelMemo = guiCreateMemo(0.10, 0.10, 0.80, 0.60, "Looks Like You Have Run Out Of Fuel Below Are 2 Options, Abandon Vehicle Or Refill($60). Abandoning Your Vehicle Means You Are Not Paying, Refill Is $15 More Than Filling Up At A Garage.", true, helpGui) playerHelpGuibutton = guiCreateButton( 0.10, 0.90, 0.30, 0.30, "Abandon", true, helpGui) refillGuibutton = guiCreateButton( 0.60, 0.90, 0.30, 0.30, "Refill", true, helpGui) showCursor ( true ) guiMemoSetReadOnly (outFuelMemo, true) addEventHandler ( "onClientGUIClick", playerHelpGuibutton, abandonRefiling, false ) addEventHandler ( "onClientGUIClick", refillGuibutton, standardRefills , false ) end function standardRefills () local PlayerInCar = getPlayerOccupiedVehicle( getLocalPlayer() ) local details = {} details ["VehicleId"] = getVehicleID (PlayerInCar) triggerServerEvent("moneyCheck", getLocalPlayer(), details ) end function refillStart () outputChatBox("You Refilled Your Car For $60", getRootElement()) guiSetVisible (helpGui, false ) showCursor ( false) showPlayerFuel(getRootElement()) end addEvent("cashiin", true ) addEventHandler("cashiin", getLocalPlayer(), refillStart) function abandonRefiling () outputChatBox("You Have Abandoned Your Car", getRootElement()) guiSetVisible (helpGui, false ) showCursor ( false) hidePlayerFuel(getRootElement()) triggerServerEvent("AbandonVehicle", getLocalPlayer(),"abandon" ) end addEvent("nocash", true ) addEventHandler("nocash", getLocalPlayer(), abandonRefiling) function joinGui() joinGui = guiCreateWindow ( 550, 250, 200, 300, "Welcome", false ) joinGuibutton = guiCreateButton( 0.60, 0.90, 0.30, 0.30, "Accept", true, joinGui) guiCreateStaticImage( 0.25, 0.50, 0.50, 0.28, "Petrol/Image/Welcome.png", true, joinGui ) declineGuibutton = guiCreateButton( 0.10, 0.90, 0.30, 0.30, "Decline", true, joinGui) joinMemo = guiCreateMemo(0.10, 0.10, 0.80, 0.30, "In Order For You To Use This Script And Play You Must Click Accept Or Decline Below", true, joinGui) guiMemoSetReadOnly (joinMemo, true) showCursor ( true ) addEventHandler ( "onClientGUIClick", joinGuibutton, triggerServer, false ) addEventHandler ( "onClientGUIClick", declineGuibutton, freezePlayer , false ) addEventHandler ( "onClientGUIClick", joinGuibutton, hideWelcomeFuel, false ) addEventHandler ( "onClientGUIClick", declineGuibutton, hideWelcomeFuel, false ) end addEvent("Join", true) addEventHandler("Join",getLocalPlayer(), joinGui ) function triggerServer() local name = {} name ["player"] = getLocalPlayer() triggerServerEvent("OkJoin", getLocalPlayer(), name) end function hideWelcomeFuel () guiSetVisible( joinGui, false ) showCursor ( false ) end function freezePlayer ( ) toggleAllControls ( false ) outputChatBox("All Your Controls Have Been Frozen Please Rejoin And Click Accept", source) end function hidePlayerFuel () if fuelBar1 then guiSetVisible( fuelBar1, false ) guiSetVisible ( fuelFrame, false ) guiSetVisible (warningdot1, false ) end if fuelBar2 then guiSetVisible( fuelBar2, false ) guiSetVisible ( fuelFrame2, false ) guiSetVisible (warningdot2, false ) end end addEvent("jacked", true ) addEventHandler("jacked", getLocalPlayer(), hidePlayerFuel ) 1_ServerFuelGage: function resource ( ) createMarker ( 1006.5333251953, -940.23657226563, 42.483940124512, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( 1382.1794433594, 462.65112304688, 20.481601715088, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( -1328.7069091797, 2677.6293945313, 50.411556243896, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( -1675.5217285156, 413.21072387695, 7.5281267166138, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( -2030.1632080078, 157.583984375, 29.185176849365, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( -2243.849609375, -2561.1311035156, 32.270923614502, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( -1607.1502685547, -2713.6411132813, 48.884605407715, "cylinder", 4, 255, 255, 0, 170 ) createMarker ( 1937.2746582031, -1773.8128662109, 13.729103088379, "cylinder", 4, 255, 255, 0, 170 ) Tempel = createColCircle ( 1006.5333251953, -940.23657226563, 4 ) Montgomery = createColCircle ( 1382.1794433594, 462.65112304688, 4 ) TierraRobada = createColCircle ( -1328.7069091797, 2677.6293945313, 4 ) EasterBasin = createColCircle ( -1675.5217285156, 413.21072387695, 4 ) Doherty = createColCircle ( -2030.1632080078, 157.583984375, 4 ) AngelPine = createColCircle ( -2243.849609375, -2561.1311035156, 4 ) Whetstone = createColCircle ( -1607.1502685547, -2713.6411132813, 4 ) Idlewood = createColCircle ( 1937.2746582031, -1773.8128662109, 4 ) addEventHandler ( "onColShapeHit", Tempel, petroljoin ) addEventHandler ( "onColShapeLeave", Tempel, petrolLeave ) addEventHandler ( "onColShapeHit", Montgomery, petroljoin ) addEventHandler ( "onColShapeLeave", Montgomery, petrolLeave ) addEventHandler ( "onColShapeHit", TierraRobada, petroljoin ) addEventHandler ( "onColShapeLeave", TierraRobada, petrolLeave ) addEventHandler ( "onColShapeHit", EasterBasin, petroljoin ) addEventHandler ( "onColShapeLeave", EasterBasin, petrolLeave ) addEventHandler ( "onColShapeHit", Doherty, petroljoin ) addEventHandler ( "onColShapeLeave", Doherty, petrolLeave ) addEventHandler ( "onColShapeHit", AngelPine, petroljoin ) addEventHandler ( "onColShapeLeave", AngelPine, petrolLeave ) addEventHandler ( "onColShapeHit", Whetstone, petroljoin ) addEventHandler ( "onColShapeLeave", Whetstone, petrolLeave ) addEventHandler ( "onColShapeHit", Idlewood, petroljoin ) addEventHandler ( "onColShapeLeave", Idlewood, petrolLeave ) end addEventHandler ( "onResourceStart", getRootElement(), resource) function callPetrolBlips (source ) TempelB = createBlip ( 1006.5333251953, -940.23657226563, 42.483940124512, 48, 0, 0, 0, 255, getRootElement()) --Tempel MontgomeryB = createBlip ( 1382.1794433594, 462.65112304688, 20.481601715088, 48, 0, 0, 0, 255, getRootElement()) --Montgomery TierraRobadaB = createBlip ( -1328.7069091797, 2677.6293945313, 50.411556243896, 48, 0, 0, 0, 255, getRootElement()) --TierraRobada EasterBasinB = createBlip ( -1675.5217285156, 413.21072387695, 7.5281267166138, 48, 0, 0, 0, 255, getRootElement()) --EasterBasin DohertyB = createBlip ( -2030.1632080078, 157.583984375, 29.185176849365, 48, 0, 0, 0, 255, getRootElement()) --Doherty AngelPineB = createBlip ( -2243.849609375, -2561.1311035156, 32.270923614502, 48, 0, 0, 0, 255, getRootElement()) --AngelPine WhetstoneB = createBlip ( -1607.1502685547, -2713.6411132813, 48.884605407715, 48, 0, 0, 0, 255, getRootElement()) --Whetstone IdlewoodB = createBlip ( 1937.2746582031, -1773.8128662109, 13.729103088379, 48, 0, 0, 0, 255, getRootElement()) --Idlewood setTimer (destroyPetrolBlips, 60000, 1 ) end addCommandHandler ("petrol", callPetrolBlips ) function destroyPetrolBlips ( source ) destroyElement(TempelB) destroyElement(MontgomeryB) destroyElement(TierraRobadaB) destroyElement(EasterBasinB) destroyElement(DohertyB) destroyElement(AngelPineB) destroyElement(WhetstoneB) destroyElement(IdlewoodB) outputChatBox("SLR: Petrol Blips Removed", source ) end function playerJoinFreeze() local SlrPlayer = xmlLoadFile( "SlrPlayer.xml", "data" ) local SlrPlayerSubNode = FindSlrPlayerNode ( SlrPlayer, getPlayerSerial ( source ) ) if ( SlrPlayerSubNode ) then cashSetKnown ( SlrPlayerSubNode ) else triggerClientEvent(source, "Join", getRootElement(), "Join") end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoinFreeze ) function cashSetKnown ( SlrPlayerSubNode ) local SlrPlayerCash = xmlNodeGetAttribute ( SlrPlayerSubNode, "Cash" ) setPlayerMoney ( source, tonumber(SlrPlayerCash)) outputChatBox ("SLR: Setting Cash", source, 255, 255, 0, true ) end function CashSet ( name ) local SlrPlayer = xmlLoadFile( "SlrPlayer.xml", "data" ) local SlrPlayerSubNode = FindSlrPlayerNode ( SlrPlayer, getPlayerSerial ( name ["player"] ) ) if ( SlrPlayerSubNode ) then local SlrPlayerCash = xmlNodeGetAttribute ( SlrPlayerSubNode, "Cash" ) setPlayerMoney ( source, tonumber(SlrPlayerCash)) outputChatBox ("SLR: Setting Cash", source, 255, 255, 0, true ) else local SlrPlayerCreateSubNode = xmlCreateSubNode ( SlrPlayer, "User" ) xmlNodeSetAttribute ( SlrPlayerCreateSubNode, "Serial", getPlayerSerial( name ["player"] ) ) xmlNodeSetAttribute ( SlrPlayerCreateSubNode, "Name", getClientName( name ["player"] ) ) xmlNodeSetAttribute ( SlrPlayerCreateSubNode, "Cash", "1000" ) setPlayerMoney ( source, 1000 ) xmlSaveFile ( SlrPlayer ) outputChatBox ("SLR: "..getClientName (name ["player"]).." We Are Now Saving All Your Cash" , source ) outputChatBox ("SLR: Setting Cash", source, 255, 255, 0, true ) end end addEvent("OkJoin", true) addEventHandler("OkJoin", getRootElement(), CashSet) function sendClientCash () local SlrPlayer = xmlLoadFile( "SlrPlayer.xml", "data" ) local SlrPlayerSubNode = FindSlrPlayerNode ( SlrPlayer, getPlayerSerial ( source ) ) if ( SlrPlayerSubNode ) then local SlrPlayerCash = xmlNodeGetAttribute ( SlrPlayerSubNode, "Cash" ) triggerClientEvent(source, "playerCash", getRootElement(), SlrPlayerCash ) end end addEvent("sendMoney", true) addEventHandler("sendMoney",getRootElement(), sendClientCash) function startFuleScript ( theVehicle, seat, jacked ) local VehId = getVehicleID ( theVehicle ) local SlrVehicle = xmlLoadFile ( "SlrVehicles.xml" ) local SlrVehicleSubNodeStart = FindVehicleNode ( SlrVehicle, VehId) if ( SlrVehicleSubNodeStart) then local yy = xmlNodeGetAttribute ( SlrVehicleSubNodeStart, "Percent" ) if ( tonumber(yy) < tonumber(2)) then outputChatBox("This Vehicle Empty", source) else local currentFuel = {} currentFuel ["sizex"] = xmlNodeGetAttribute ( SlrVehicleSubNodeStart, "SizeX" ) currentFuel ["sizey"] = xmlNodeGetAttribute ( SlrVehicleSubNodeStart, "SizeY" ) currentFuel ["posx"] = xmlNodeGetAttribute ( SlrVehicleSubNodeStart, "PosX" ) currentFuel ["posy"] = xmlNodeGetAttribute ( SlrVehicleSubNodeStart, "PosY" ) triggerClientEvent(source, "CurrentFuel", getRootElement(), currentFuel) end end if ( SlrVehicleSubNodeStart == false )then triggerClientEvent(source, "FullTank", getRootElement(), "fulltankit") end if (jacked ) then triggerClientEvent(jacked, "jacked", getRootElement(), "hideFuelGage") end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), startFuleScript ) function SavePositions(Positions) local VehId = Positions ["VehicleId"] local SlrVehicle = xmlLoadFile ( "SlrVehicles.xml", getThisResource() ) local SlrVehicleSubNode = FindVehicleNode ( SlrVehicle, VehId) local SlrTakeOne = xmlNodeGetAttribute ( SlrVehicleSubNode, "Percent") if ( SlrVehicleSubNode ) then xmlNodeSetAttribute ( SlrVehicleSubNode, "SizeX", Positions["Size.X"]) xmlNodeSetAttribute ( SlrVehicleSubNode, "SizeY", Positions["Size.Y"]) xmlNodeSetAttribute ( SlrVehicleSubNode, "PosX", Positions["Pos.X"]) xmlNodeSetAttribute ( SlrVehicleSubNode, "PosY", Positions["Pos.Y"]) xmlNodeSetAttribute ( SlrVehicleSubNode, "Percent", tonumber(SlrTakeOne) - 0.61) xmlSaveFile ( SlrVehicle ) else local SlrCreateVehicleSubNode = xmlCreateSubNode ( SlrVehicle, "Vehicle" ) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "Id", VehId ) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "SizeX", Positions["Size.X"]) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "SizeY", Positions["Size.Y"]) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "PosX", Positions["Pos.X"]) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "PosY", Positions["Pos.Y"]) xmlNodeSetAttribute ( SlrCreateVehicleSubNode, "Percent", 100) xmlSaveFile ( SlrVehicle ) end end addEvent("Positions", true) addEventHandler("Positions", getRootElement(), SavePositions) function FindVehicleNode ( SlrVehicle, VehId ) i = 0 local vehicleSubNode = xmlFindSubNode ( SlrVehicle, "Vehicle", i ) while ( vehicleSubNode ~= false ) do if ( tonumber(xmlNodeGetAttribute ( vehicleSubNode, "Id" )) == VehId ) then return vehicleSubNode end i = i + 1 vehicleSubNode = xmlFindSubNode ( SlrVehicle, "Vehicle", i ) end return false end function Create () local existPlayer = fileOpen ( "SlrPlayer.xml" ) local existVehicle = fileOpen ( "SlrVehicles.xml" ) local SlrFileLoad = xmlLoadFile ( "SlrPlayer.xml" ) local SlrFileLoadVehicle = xmlLoadFile ( "SlrVehicles.xml" ) if (existPlayer) and (existVehicle) then outputChatBox ("SLR: Petrol Script Reactive", getRootElement(), 255, 255, 0, true ) else if not (slrFileLoad and SlrFileLoadVehicle) then local SlrFileCreate = xmlCreateFile ( "SlrPlayer.xml", "data", getThisResource() ) local SlrFileCreateVehicle = xmlCreateFile ( "SlrVehicles.xml", "data", getThisResource() ) xmlSaveFile(SlrFileCreate) xmlSaveFile(SlrFileCreateVehicle) fileClose ( "SlrPlayer.xml" ) fileClose ( "SlrVehicles.xml" ) end end end addEventHandler ( "onResourceStart", getRootElement(), Create ) function playerCash ( ammo, attacker, weapon, bodypart ) local SlrPlayer = xmlLoadFile ( "SlrPlayer.xml", "data" ) local moneySubNode = FindAttackerNode ( SlrPlayer, getPlayerSerial ( attacker ) ) if ( bodypart == 9 ) and ( moneySubNode ) and ( attacker ) then local readHeadCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 100 xmlNodeSetAttribute ( moneySubNode, "Cash", readHeadCash) local new = getPlayerMoney(attacker) + 100 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 8 ) and ( moneySubNode ) and ( attacker ) then local readRightLegCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 30 xmlNodeSetAttribute ( moneySubNode, "Cash", readRightLegCash) local new = getPlayerMoney(attacker) + 30 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 7 ) and ( moneySubNode ) and ( attacker ) then local readLeftLegCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 30 xmlNodeSetAttribute ( moneySubNode, "Cash", readLeftLegCash) local new = getPlayerMoney(attacker) + 30 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 6 ) and ( moneySubNode ) and ( attacker )then local readRightArmCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 40 xmlNodeSetAttribute ( moneySubNode, "Cash", readRightArmCash) local new = getPlayerMoney(attacker) + 40 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 5 ) and ( moneySubNode ) and ( attacker ) then local readLeftArmCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 40 xmlNodeSetAttribute ( moneySubNode, "Cash", readLeftArmCash) local new = getPlayerMoney(attacker) + 40 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 4 ) and ( moneySubNode ) and ( attacker ) then local readAssCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 60 xmlNodeSetAttribute ( moneySubNode, "Cash", readAssCash) local new = getPlayerMoney(attacker) + 60 setPlayerMoney ( attacker, tonumber(new)) end if ( bodypart == 3 ) and ( moneySubNode ) and ( attacker ) then local readTorsoCash = xmlNodeGetAttribute ( moneySubNode, "Cash" ) + 40 xmlNodeSetAttribute ( moneySubNode, "Cash", readTorsoCash) local new = getPlayerMoney(attacker) + 40 setPlayerMoney ( attacker, tonumber(new)) end xmlSaveFile ( SlrPlayer ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerCash ) function FindAttackerNode ( SlrPlayer, user ) i = 0 Link to comment
DNL291 Posted February 28, 2014 Share Posted February 28, 2014 Este script já é velho, eu recomendo você baixar outro script de combustível. Você pode baixar esse: https://community.multitheftauto.com/in ... ls&id=3287 Com relação ao 1º erro (linha 19), não vejo refillName definido em nenhum lugar. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now