Jump to content

A small problem..


MajdMTA

Recommended Posts

function hidingaVehicle() 
    local vehicle = getVehicleByID(id) 
    if isElement(vehicle) then 
        local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) 
        if type(data) == "table" and #data ~= 0 then 
        local aman = getVehicleOccupant(vehicle) 
            destroyVehicle(vehicle) 
                if isElement(source) and playerVehicles[source] then 
        for i=1,#playerVehicles[source] do 
            if playerVehicles[source][i] == vehicle then 
                table.remove(playerVehicles[source],i) 
                break 
            end 
        end 
    else 
        playerVehicles[source] = nil 
    end 
            outputChatBox("You destroy your vehicle", source, 255, 0, 0)  
            cur = getElementData(source,"spawnedcars") or {} 
            for ind,veh in ipairs(cur) do 
            if veh == getVehicleNameFromModel(data[1]["Model"]) then 
            table.remove(cur,ind) 
            end 
            end 
            setElementData(source,"spawnedcars",cur) 
        else 
            outputChatBox("No vehicle is spawned", source, 255, 0, 0) 
        end 
    else 
        outputChatBox("No vehicle is spawned ", source, 255, 0, 0) 
    end 
end 
addCommandHandler ( "hide", hidingaVehicle ) 

Help please.

Link to comment
function hidingaVehicle(player, command) 
    local vehicle = getVehicleByID(id) 
    if isElement(vehicle) then 
        local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(player)), id), -1) 
        if type(data) == "table" and #data ~= 0 then 
        local aman = getVehicleOccupant(vehicle) 
            destroyVehicle(vehicle) 
                if isElement(player) and playerVehicles[player] then 
        for i=1,#playerVehicles[player] do 
            if playerVehicles[player][i] == vehicle then 
                table.remove(playerVehicles[player],i) 
                break 
            end 
        end 
    else 
        playerVehicles[player] = nil 
    end 
            outputChatBox("You destroy your vehicle", player, 255, 0, 0) 
            cur = getElementData(player,"spawnedcars") or {} 
            for ind,veh in ipairs(cur) do 
            if veh == getVehicleNameFromModel(data[1]["Model"]) then 
            table.remove(cur,ind) 
            end 
            end 
            setElementData(player,"spawnedcars",cur) 
        else 
            outputChatBox("No vehicle is spawned", player, 255, 0, 0) 
        end 
    else 
        outputChatBox("No vehicle is spawned ", player, 255, 0, 0) 
    end 
end 
addCommandHandler ( "hide", hidingaVehicle ) 

Link to comment
function hidingaVehicle(player, command) 
    local vehicle = getVehicleByID(id) 
    if isElement(vehicle) then 
        local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(player)), id), -1) 
        if type(data) == "table" and #data ~= 0 then 
        local aman = getVehicleOccupant(vehicle) 
            destroyVehicle(vehicle) 
                if isElement(player) and playerVehicles[player] then 
        for i=1,#playerVehicles[player] do 
            if playerVehicles[player][i] == vehicle then 
                table.remove(playerVehicles[player],i) 
                break 
            end 
        end 
    else 
        playerVehicles[player] = nil 
    end 
            outputChatBox("You destroy your vehicle", player, 255, 0, 0) 
            cur = getElementData(player,"spawnedcars") or {} 
            for ind,veh in ipairs(cur) do 
            if veh == getVehicleNameFromModel(data[1]["Model"]) then 
            table.remove(cur,ind) 
            end 
            end 
            setElementData(player,"spawnedcars",cur) 
        else 
            outputChatBox("No vehicle is spawned", player, 255, 0, 0) 
        end 
    else 
        outputChatBox("No vehicle is spawned ", player, 255, 0, 0) 
    end 
end 
addCommandHandler ( "hide", hidingaVehicle ) 

And now it's worked, but My I Pick a car, and tried /hide in the outputChatBox("No vehicle is spawned")

Link to comment
What you mean?

I've spawned a car, and tried /hide It's didn't work, I mean, In outputChatBox there's message for me ("No vehicle is spawned")

So, it's another problem, isn't /hide worked?

Lemme give you another one

addEvent("DestroyMyVehicle", true) 
addEventHandler("DestroyMyVehicle", root,  
function (id) 
    local vehicle = getVehicleByID(id) 
    if isElement(vehicle) then 
        local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) 
        if type(data) == "table" and #data ~= 0 then 
        local aman = getVehicleOccupant(vehicle) 
            destroyVehicle(vehicle) 
                if isElement(source) and playerVehicles[source] then 
        for i=1,#playerVehicles[source] do 
            if playerVehicles[source][i] == vehicle then 
                table.remove(playerVehicles[source],i) 
                break 
            end 
        end 
    else 
        playerVehicles[source] = nil 
    end 
            exports.CSFtexts:output ("Your Vehicle "..getVehicleNameFromModel(data[1]["Model"]).." has been destroyed.", source, 255, 85, 0, true) 
            cur = getElementData(source,"spawnedcars") or {} 
            for ind,veh in ipairs(cur) do 
            if veh == getVehicleNameFromModel(data[1]["Model"]) then 
            table.remove(cur,ind) 
            end 
            end 
            setElementData(source,"spawnedcars",cur) 
        else 
            exports.CSFtexts:output("Select the Vehicle that you want to destroy.", source, 255, 85, 0, true) 
        end 
    else 
        exports.CSFtexts:output("Your Vehicle is not spawned.", source, 255, 85, 0, true) 
    end 
end) 

Can you add /hide for this function?

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...