Jump to content

[Ayuda] Fuel/Combustible


Agu#

Recommended Posts

Hola, tengo un error en este resource http://community.multitheftauto.com/ind ... ils&id=190, que se llama slrFuel.

El error es el siguiente, WARNING: Fuel/Client_Petrol.lua:19: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil]

~Script~

Clien-side:

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 = getPedOccupiedVehicle( 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"] = getElementModel (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("-- Tienes  poco combustible.", source, 255, 255, 0, true) 
    if ( math.abs(0.01500 - 0.015001999214292) < 0.0001) then 
        freezeCarOutOfFuel () 
            end 
        end 
    end 
end 
  
function decFuel1() 
    local PlayerInCar = getPedOccupiedVehicle( 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"] = getElementModel (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("-- Tienes  poco combustible.", source, 255, 255, 0, true) 
    if ( math.abs(0.01500 - 0.015001999214292) < 0.0001) then 
        freezeCarOutOfFuel () 
            end  
        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 
addEvent("freezeCarOutOfFuel", true) 
addEventHandler("freezeCarOutOfFuel", getLocalPlayer(), freezeCarOutOfFuel) 
  
function standardRefills () 
    local PlayerInCar = getPedOccupiedVehicle( getLocalPlayer() ) 
    local details = {} 
        details ["VehicleId"] = getElementModel (PlayerInCar) 
    triggerServerEvent("moneyCheck", getLocalPlayer(), details ) 
end  
     
function refillStart () 
    outputChatBox("-- Se volvió a llenar de combustible su coche por $ 118", getRootElement(), 255, 255, 0, true) 
        guiSetVisible (helpGui, false ) 
        showCursor ( false) 
    showPlayerFuel(getRootElement()) 
end    
    addEvent("cashiin", true ) 
    addEventHandler("cashiin", getLocalPlayer(), refillStart)  
     
function abandonRefiling () 
    outputChatBox("-- Usted ha abandonado su coche.", 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("-- Todos sus controles se han congelado Por favor, Reconecte Y Haga clic en Aceptar.", source,  255, 255, 0, true)    
 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 ) 
     
function petrolwindow (fuelDetails) 
    local x,y,z = getElementPosition( getLocalPlayer()) 
        petrolwindow = guiCreateWindow ( 550, 250, 200, 300, getZoneName ( x, y, z ).." Gasolineria", false ) 
            paybutton = guiCreateButton( 0.60, 0.90, 0.30, 0.30, "Pago", true, petrolwindow) 
                guiCreateLabel (0.06, 0.10, 0.96, 0.050, "Gasolineria: "..getZoneName ( x, y, z ), true, petrolwindow) 
                    guiCreateLabel (0.06, 0.16, 0.50, 0.050, "Combustible: "..fuelDetails ["slrpercent"].."%", true, petrolwindow) 
                        guiCreateLabel (0.06, 0.22, 0.96, 0.050, "Precio: $1.18 por litro", true, petrolwindow) 
                    guiCreateLabel (0.06, 0.28, 0.58, 0.050, "Litros añadidos: "..fuelDetails ["Percent"].."l", true, petrolwindow) 
                guiCreateLabel (0.06, 0.31, 0.96, 0.050, "-------------------------", true, petrolwindow) 
            guiCreateLabel (0.06, 0.37, 0.48, 0.050, "Costo: $"..fuelDetails ["WorkOut"], true, petrolwindow) 
        showCursor ( true ) 
    addEventHandler ( "onClientGUIClick", paybutton, petrolWindowPay, false )    
end 
    addEvent("petrolwindow", true) 
    addEventHandler("petrolwindow",getLocalPlayer(), petrolwindow) 
  
function petrolNoCash(fuelDetails) 
    local x,y,z = getElementPosition ( getLocalPlayer()) 
        petrolnocash = guiCreateWindow ( 550, 250, 200, 300, getZoneName ( x, y, z ).." Gasolineria", false ) 
            leavebutton = guiCreateButton  ( 0.60, 0.90, 0.30, 0.30, "Dejar", true, petrolnocash) 
                guiCreateLabel (0.06, 0.10, 0.96, 0.050, "Gasolineria: "..getZoneName ( x, y, z ), true, petrolnocash) 
                    guiCreateLabel (0.06, 0.16, 0.50, 0.050, "Combustible: "..fuelDetails ["slrpercent"].."%", true, petrolnocash) 
                        guiCreateLabel (0.06, 0.22, 0.96, 0.050, "Precio: $1.18 por litro", true, petrolnocash) 
                        guiCreateLabel (0.06, 0.28, 0.58, 0.050, "Litros añadidos: "..fuelDetails ["Percent"].."lt", true, petrolnocash) 
                    guiCreateLabel (0.06, 0.31, 0.96, 0.050, "-------------------------", true, petrolnocash) 
                noCashMemo = guiCreateMemo  (0.10, 0.38, 0.80, 0.48, "Lo siento, pero me temo que tendrás que salir, no tienen suficiente dinero para comprar Gasolina.", true, petrolnocash) 
            guiMemoSetReadOnly (noCashMemo, true) 
        showCursor ( true ) 
    addEventHandler ( "onClientGUIClick", leavebutton, petrolWindowLeave, false )    
end  
    addEvent("petrolNoCash", true ) 
    addEventHandler("petrolNoCash", getLocalPlayer(), petrolNoCash) 
  
function petrolWindowPay () 
    guiSetVisible ( petrolwindow, false ) 
        showCursor ( false ) 
    outputChatBox ( "-- Pagado con éxito.", source, 255, 255, 0, true ) 
end 
  
function petrolWindowLeave () 
        guiSetVisible ( petrolnocash, false ) 
        showCursor ( false ) 
    outputChatBox ( "-- Gracias por su visita.", source, 255, 255, 0, true ) 
end 
  

Server-side:

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 )
    createMarker ( 1890.3913574219, -2622.7065429688, 13.122525215149, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 1828.7033691406, -2622.9721679688, 13.11102771759, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 1763.58203125, -2622.8273925781, 13.119339942932, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 1688.2907714844, -2623.7719726563, 13.110878944397, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 1625.6751708984, -2624.9548339844, 13.119853019714, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1200.3817138672, -141.11245727539, 13.716547012329, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1243.7838134766, -99.152908325195, 13.714056968689, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1342.1311035156, -525.42883300781, 13.718987464905, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1414.1588134766, -564.72583007813, 13.712074279785, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1465.4914550781, -620.67816162109, 13.72026348114, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1397.5747070313, -618.99066162109, 13.711554527283, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1338.6430664063, -617.5263671875, 13.701593399048, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( -1275.048828125, -615.94647216797, 13.719861984253, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 411.34689331055, 2492.462890625, 16.04790687561, "cylinder", 4, 255, 255, 0, 170 )
    createMarker ( 381.79415893555, 2537.1967773438, 16.110816955566, "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 )
   
    Airport1 = createColCircle ( 1890.3913574219, -2622.7065429688, 4 )
    Airport2 = createColCircle ( 1828.7033691406, -2622.9721679688, 4 )
    Airport3 = createColCircle ( 1763.58203125, -2622.8273925781, 4 )
    Airport4 = createColCircle ( 1688.2907714844, -2623.7719726563, 4 )
    Airport5 = createColCircle ( 1625.6751708984, -2624.9548339844, 4 )
    Airport6 = createColCircle (  -1200.3817138672, -141.11245727539, 4 )
    Airport7 = createColCircle ( -1243.7838134766, -99.152908325195, 4 )
    Airport8 = createColCircle ( -1342.1311035156, -525.42883300781, 4 )
    Airport9 = createColCircle ( -1414.1588134766, -564.72583007813, 4 )
    Airport10 = createColCircle ( -1465.4914550781, -620.67816162109, 4 )
    Airport11 = createColCircle ( -1397.5747070313, -618.99066162109, 4 )
    Airport12 = createColCircle ( -1338.6430664063, -617.5263671875, 4 )
    Airport13 = createColCircle ( -1275.048828125, -615.94647216797, 4 )
    Airport14 = createColCircle ( 411.34689331055, 2492.462890625, 4 )
    Airport15 = createColCircle ( 381.79415893555, 2537.1967773438, 4 )
       
 
    addEventHandler ( "onColShapeHit", Airport1, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport1, petrolLeave )  
    addEventHandler ( "onColShapeHit", Airport2, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport2, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport3, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport3, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport4, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport4, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport5, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport5, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport6, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport6, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport7, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport7, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport8, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport8, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport9, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport9, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport10, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport10, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport11, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport11, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport12, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport12, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport13, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport13, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport14, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport14, petrolLeave )
    addEventHandler ( "onColShapeHit", Airport15, petroljoin  ) 
    addEventHandler ( "onColShapeLeave", Airport15, petrolLeave )
    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("-- Blips Gasolina Eliminado", source )
end
 
function playerJoinFreeze()
    local sourcename = getPlayerName ( source )  
    local result = executeSQLSelect ( "players", "player", "player = '" .. sourcename .. "'" )
        if ( result == true ) then  
            outputChatBox ("-- Ajuste playerjoinfreeze Efectivo", source, 255, 255, 0, true )
                executeSQLInsert ( "players", "'none','" .. sourcename .. "'" )
                executeSQLUpdate ( "players", "Cash = '1000'", "player = '" .. sourcename .. "'" )
            setPlayerMoney ( source, 1000 )
        else
            triggerClientEvent(source, "Join", getRootElement(), "Join")
    end
end
    addEventHandler ( "onPlayerJoin", getRootElement(), playerJoinFreeze )
 
 
function CashSet ( name )
    local sourcename = getPlayerName ( source )  
    local result = executeSQLSelect ( "players", "player", "player = '" .. sourcename .. "'" )
        if ( result == false ) then  
            outputChatBox ("-- "..getClientName (name ["player"]).." Ahora estamos guardando todo tu dinero" , source )
                outputChatBox ("-- Ajuste de Efectivo", source, 255, 255, 0, true )
            executeSQLInsert ( "players", "'none','" .. sourcename .. "'" )
        executeSQLUpdate ( "players", "Cash = '1000'", "player = '" .. sourcename .. "'" )
    setPlayerMoney ( source, 1000 )
        else
            local currentCash = executeSQLSelect ( "players", "Cash", "player = '" .. sourcename .. "'" )
            outputChatBox ("-- Ajuste de Efectivo", source, 255, 255, 0, true )
        setPlayerMoney ( source, tonumber(currentCash[1][1]) )
    end    
end
    addEvent("OkJoin", true)
    addEventHandler("OkJoin", getRootElement(), CashSet)
 
function sendClientCash ()
    local SlrPlayer = xmlLoadFile( "SlrPlayer.xml", "data" )
    local SlrPlayerSubNode = slrReturnPlayerSqlData ( source, "Cash", "players" )
    if ( SlrPlayerSubNode )  then
        triggerClientEvent(source, "playerCash", getRootElement(), SlrPlayerSubNode )
    end
end
    addEvent("sendMoney", true)
    addEventHandler("sendMoney",getRootElement(), sendClientCash)
 
function startFuleScript ( theVehicle, seat, jacked )
    local VehId = getElementModel ( theVehicle )
    local result = executeSQLSelect ( "vehicle", "Id", "Id = '"..VehId.."'" )
        if  ( result == false )then
            triggerClientEvent(source, "FullTank", getRootElement(), "fulltankit")  
        elseif ( result[1] ) then  
            local id = executeSQLSelect ( "vehicle", "SizeX, SizeY, PosX, PosY, Percent", "Id = '"..VehId.."'" )
            outputChatBox("x "..id[1][1])
            outputChatBox("y "..id[1][2])
            outputChatBox("px "..id[1][3])
            outputChatBox("py "..id[1][4])
            outputChatBox("% "..id[1][5])
            if ( tonumber(id[1][5]) < tonumber(2)) then
                outputChatBox("-- Este vehículo está vacío", source, 255, 255, 0, true)
                triggerClientEvent(source, "freezeCarOutOfFuel", getRootElement(), "freezeCarOutOfFuel")
            else       
                local currentFuel = {}
                    currentFuel ["sizex"] = id[1][1]  
                    currentFuel ["sizey"] = id[1][2]
                    currentFuel ["posx"] = id[1][3]
                    currentFuel ["posy"] = id[1][4]
                triggerClientEvent(source, "CurrentFuel", getRootElement(), currentFuel)
            end
        end
        if (jacked ) then triggerClientEvent(jacked, "jacked", getRootElement(), "hideFuelGage")
    end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), startFuleScript )
 
function SavePositions(Positions)
    local VehId = Positions ["VehicleId"]
    local result = executeSQLSelect ( "vehicle", "Id", "Id = '"..VehId.."'" )
        if ( result == false ) then  
            executeSQLInsert ( "vehicle", "'"..VehId.."', 'none', 'none', 'none', 'none', 'none'" )
        executeSQLUpdate ( "vehicle", "SizeX = '"..Positions["Size.X"].."' ,SizeY = '"..Positions["Size.Y"].."', PosX = '"..Positions["Pos.X"].."', Posy = '"..Positions["Pos.Y"].."', Percent = '100'", "Id = '" .. VehId .. "'" )
        else
            local id = executeSQLSelect ( "vehicle", "SizeX, SizeY, PosX, PosY, Percent", "Id = '"..VehId.."'" )
        executeSQLUpdate ( "vehicle", "SizeX = '"..Positions["Size.X"].."' ,SizeY = '"..Positions["Size.Y"].."', PosX = '"..Positions["Pos.X"].."', Posy = '"..Positions["Pos.Y"].."', Percent = '".. tonumber(id[1][5]) - tonumber(0.61) .."'", "Id = '" .. VehId .. "'" )
    end
end
    addEvent("Positions", true)
    addEventHandler("Positions", getRootElement(), SavePositions)
 
function playerCash ( ammo, attacker, weapon, bodypart )                 
    if ( bodypart == 9 ) and ( attacker ) then
    slrUpdateCashSql ( attacker, 100, "add", "true")
    end
        if ( bodypart == 8 ) and ( attacker ) then
        slrUpdateCashSql ( attacker, 30, "add", "true")
        end
            if ( bodypart == 7 ) and ( attacker ) then
            slrUpdateCashSql ( attacker, 30, "add", "true")
            end
                if ( bodypart == 6 ) and ( attacker )then
                slrUpdateCashSql ( attacker, 40, "add", "true")
                end
            if ( bodypart == 5 ) and ( attacker ) then
            slrUpdateCashSql ( attacker, 40, "add", "true")
            end
        if ( bodypart == 4 ) and ( attacker ) then
        slrUpdateCashSql ( attacker, 60, "add", "true")
        end
    if ( bodypart == 3 ) and ( attacker ) then
    slrUpdateCashSql ( attacker, 40, "add", "true")
    end
end 
    addEventHandler ( "onPlayerWasted", getRootElement(), playerCash )
 
function moneyCheck (details)
    local VehId = details ["VehicleId"]
    local SlrPlayerCash = slrReturnPlayerSqlData ( source, "Cash", "players" )
                if ( tonumber(SlrPlayerCash) >= tonumber(118) ) then
                    triggerClientEvent(source, "cashiin", getRootElement(), "cashiin" )
                        slrUpdateCashSql ( source, 118, "take", "true")
                            local result = executeSQLSelect ( "vehicle", "Id", "Id = '"..VehId.."'" )
                        if ( result ~= false ) then  
                    executeSQLUpdate ( "vehicle", "Percent = '100'", "Id = '" .. VehId .. "'" )                
                end
            elseif ( tonumber(SlrPlayerCash) < tonumber(118) ) then
        triggerClientEvent(source, "nocash", getRootElement(), "nocash" )
    end
end
   
Link to post
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...