Jump to content

проблема с сохранением данных


iron015

Recommended Posts

Здравствуйте! У меня проблема такая: При создании машины ID бывает 20, а после перезапуска 210(и с каждым созданием машины число растёт)

  
function adminCreateVehicle ( source, cmd, model, price ) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        if isPedInVehicle ( source ) then 
            local exVehicle = getPedOccupiedVehicle ( source ) 
            if exVehicle then 
                local x,y,z = getElementPosition( exVehicle ) 
                local ax,ay,az = getElementRotation ( exVehicle ) 
                setTimer ( manualVehicleCreate, 3000, 1, x, y, z, ax, ay, az, tonumber(model), tonumber(price) ) 
            end 
        else 
            local x,y,z = getElementPosition( source ) 
            local ax,ay,az = getElementRotation ( source ) 
            manualVehicleCreate ( x,y,z,ax,ay,az, tonumber(model), tonumber(price) ) 
        end 
    else 
        outputChatBox ("Ошибка: вы не можете использовать эту команду",source, 255,255,127 ) 
    end 
end 
  
addCommandHandler ("acarcreate", adminCreateVehicle) 
  

  
function manualVehicleCreate (x,y,z,ax,ay,az, model, price, new) 
    maxcars = maxcars+1 
    cars[maxcars] = createVehicle ( model,x,y,z,ax,ay,az ) 
    local color1, color2, color3, color4, color5, color6 = math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255) 
    createVehiclesRow (model, x,y,z,ax,ay,az, color1, color2, color3, color4, color5, color6, price,"Nobody") 
    setVehicleColor ( cars[maxcars], color1, color2, color3, color4, color5, color6 ) 
    setElementData ( cars[maxcars], "saveable", true ) 
    setElementData (cars[maxcars],"vehid",maxcars) 
    setElementData (cars[maxcars],"xpos",x) 
    setElementData (cars[maxcars],"ypos",y) 
    setElementData (cars[maxcars],"zpos",z) 
    setElementData (cars[maxcars],"anglex",ax) 
    setElementData (cars[maxcars],"angley",ay) 
    setElementData (cars[maxcars],"anglez",az) 
        setElementData (cars[maxcars],"owner","Nobody") 
    setElementData (cars[maxcars],"price",price) 
    setElementData (cars[maxcars],"type",8) 
    setElementData (cars[maxcars],"lock",0) 
    setElementData (cars[maxcars],"antirad",0) 
    setElementData (cars[maxcars],"money",0) 
        setVehicleData ( getElementData ( cars[maxcars], "vehid" ), "id", tonumber(maxcars) ) 
    if new then 
        setVehicleDamageProof ( cars[maxcars], true) 
        setTimer ( function ( veh ) setElementFrozen ( veh, true ) end, 2000, 1, cars[maxcars] ) 
    end 
end 
  

  
function setVehicleData ( ID, typ, value ) 
    setElementData ( cars[ID], saveableValues[typ], value ) 
    updateVehiclesDB ( ID, typ, value ) 
end 
  

  
function updateVehiclesDB(ID, typ, value) 
    -- Security array --  
    if(saveableValues[typ]) then 
        local result = dbQuery ( database, "UPDATE `cars` SET `"..saveableValues[typ].."` = '"..value.."' WHERE `id` = "..ID.."" ) 
        if(result) then 
              dbFree ( result ) 
            outputChatBox("saved Data: "..typ.." with the value: "..value.." for veh ID "..ID.."!") 
        else 
            outputChatBox("Can't save Data: "..typ.." with the value: "..value.." for veh ID "..ID.."!") 
        end 
    end 
end 
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...