Jump to content

destroy vehicles


abu5lf

Recommended Posts

Could you explain me what do you really want to do?
function playermenu () 
    if ( guiGetVisible (mainwindow) == false ) then 
        victimemt = getElementData ( getRootElement(), "adminclickselplayer" ) 
        mainwindow = guiCreateWindow ( 750, 250, 240, 180, "Car menu", false ) 
  
        -- 
        delveh = guiCreateButton ( 0.05, 0.35, 0.4, 0.15, "Delete vehicle", true, mainwindow ) 
  
        selowner = guiCreateButton ( 0.55, 0.55, 0.4, 0.15, "Select driver", true, mainwindow ) 
        -- 
        closebutton = guiCreateButton ( 0.30, 0.8, 0.4, 0.15, "Close", true, mainwindow ) 
  
    end 
end 
addEvent ("carmenu", true) 
addEventHandler ("carmenu", getRootElement(), playermenu) 
function disable () 
guiSetVisible ( mainwindow, false) 
setElementData ( source, "adminclickselplayer", "none" ) 
setElementData (getRootElement(), "adminclickopen", false) 
end 
function selectowner () 
thecar = getElementData ( getRootElement(), "adminclickselplayer" ) 
occupant = getVehicleOccupant ( thecar ) 
guiSetVisible ( mainwindow, false) 
    if ( occupant ) then  
        setElementData ( getRootElement(), "adminclickselplayer", getPlayerName(occupant) ) 
        triggerEvent ("playermenu", occupant) 
    else 
        outputChatBox ("This vehicle does not have a driver", 255, 0, 0 ) 
         
    end 
end 
  
function de () 
thecar = getElementData ( getRootElement(), "adminclickselplayer" ) 
occupant = getVehicleOccupant ( thecar ) 
guiSetVisible ( mainwindow, false) 
    if ( occupant ) then  
    vehicles = getElementsByType("vehicle") 
    for i,v in ipairs(vehicles) do 
        destroyElement(v) 
    else 
        outputChatBox ("This vehicle", 255, 0, 0 ) 
    end 
    end 
end 
     

destroy vehicles not work

Link to comment

you should use destoryElement from server side.

also i don't understand what you want to do, it's seems like you are saving vehicle element as data and you check if the vehicle is occupant or not and then you destroy all vehicles in the server LOL!

Link to comment

I want to do, such as panel admin panel, when the press at O seems to me the mouse and press the Right on the player or the vehicle (show me a window moves) that they operate correctly, but when you press the delete button on the vehicle

Do not delete the vehicle.

Excuse me for my language

Link to comment

-- adminclickcars_cl:

function playermenu ( ) 
    if ( not isElement ( mainwindow ) ) then 
        victimemt = getElementData ( getRootElement(), "adminclickselplayer" ) 
        mainwindow = guiCreateWindow ( 750, 250, 240, 180, "Car menu", false ) 
        -- 
        fixveh = guiCreateButton ( 0.05, 0.15, 0.4, 0.15, "Fix vehicle", true, mainwindow ) 
        blowveh = guiCreateButton ( 0.55, 0.15, 0.4, 0.15, "Blow up vehicle", true, mainwindow ) 
        -- 
        delveh = guiCreateButton ( 0.05, 0.35, 0.4, 0.15, "Delete vehicle", true, mainwindow ) 
        colveh = guiCreateButton ( 0.55, 0.35, 0.4, 0.15, "Colour vehicle", true, mainwindow ) 
        -- 
        upgveh = guiCreateButton ( 0.05, 0.55, 0.4, 0.15, "Upgrade vehicle", true, mainwindow ) 
        selowner = guiCreateButton ( 0.55, 0.55, 0.4, 0.15, "Select driver", true, mainwindow ) 
        -- 
        closebutton = guiCreateButton ( 0.30, 0.8, 0.4, 0.15, "Close", true, mainwindow ) 
        addEventHandler( "onClientGUIClick", delveh, vc, false ) 
        addEventHandler( "onClientGUIClick", closebutton, disable, false ) 
        addEventHandler( "onClientGUIClick", selowner, selectowner, false ) 
    end 
end 
addEvent ("carmenu", true) 
addEventHandler ("carmenu", getRootElement(), playermenu) 
  
function disable () 
    guiSetVisible ( mainwindow, false ) 
    setElementData ( localPlayer, "adminclickselplayer", nil ) 
    setElementData ( getRootElement(), "adminclickopen", false ) 
end 
  
function selectowner () 
    thecar = getElementData ( localPlayer, "adminclickselplayer" ) 
    occupant = getVehicleOccupant ( thecar ) 
    guiSetVisible ( mainwindow, false ) 
    if ( occupant ) then 
        setElementData ( localPlayer, "adminclickselplayer", occupant ) 
    else 
        outputChatBox ( "This vehicle does not have a driver", 255, 0, 0 ) 
    end 
end 
  
function vc ( ) 
    local thecar = getElementData ( localPlayer, "adminclickselplayer" ) 
    if ( thecar and isElement ( thecar ) ) then 
        triggerServerEvent ( "destroyVehicle", localPlayer, thecar ) 
    end 
end 

-- adminclick.lua:

setElementData (getRootElement(), "adminclickopen", false) 
setElementData (getRootElement(), "adminclickmousebind", false) 
  
function clickmenu (mouseButton, buttonState, clickedElement, worldPosX, worldPosY, worldPosZ, screenPosX, screenPosY) 
    if ( buttonState == "down" ) then 
        if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
            if ( not getElementData ( source, "adminclickopen" ) ) then 
                if ( getElementData ( source, "adminclickmousebind") ) then 
                    if ( mouseButton == "right" ) then 
                        if ( clickedElement ) then 
                            if ( getElementType (clickedElement) == "player" ) then 
                                name = getPlayerName (clickedElement) 
                                setElementData ( source, "adminclickselplayer", tostring(name) ) 
                                setElementData ( source, "adminclickopen", true) 
                                triggerClientEvent (source,"playermenu", getRootElement() ) 
                            elseif ( getElementType (clickedElement) == "vehicle" ) then 
                                thecar = clickedElement 
                                setElementData ( source, "adminclickselplayer", thecar ) 
                                triggerClientEvent (source,"carmenu", getRootElement() ) 
                            end 
                        end 
                    elseif ( mouseButton == "left" ) then 
                        --outputChatBox ( worldPosX .. "," .. worldPosY .. "," .. worldPosZ ) 
                        --[[ Random send cars & players flying, can be abused 
                        col = createColCircle ( worldPosX, worldPosY, 15) 
                        colelements = getElementsWithinColShape (col) 
                        for theKey,theElement in ipairs(colelements) do   
                            if ( getElementType (theElement) == "player" ) then 
                                setElementVelocity ( theElement, 2, 0, 5) 
                            elseif ( getElementType (theElement) == "vehicle" ) then 
                                setElementVelocity ( theElement, 2, 0, 1.5) 
                            end 
                        end 
                        --]] 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onPlayerClick", getRootElement(), clickmenu ) 
  
function onstart() 
players = getElementsByType ( "player" ) -- get a table of all the players in the server 
    for theKey,player in ipairs(players) do 
        if ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) then    
            setElementData ( player, "adminclickopen", false) 
            setElementData ( player, "adminclickmousebind", false) 
            bindKey (player, "o", "down", showmouse, player ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstart ) 
  
function showmouse ( player ) 
    showCursor ( player, not isCursorShowing ( player ) ) 
    setElementData ( player, "adminclickmousebind", isCursorShowing ( player ) ) 
end 
  
function bindmouse () 
    if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
        setElementData ( source, "adminclickopen", false ) 
        setElementData ( source, "adminclickmousebind", false ) 
        bindKey ( source, "o", "down", showmouse ) 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), bindmouse ) 
  
function killplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        killPed (victim) 
        outputChatBox ("You just killed " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ("You just admin killed!", victim, 125, 125, 125 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("killplayer", true) 
addEventHandler ("killplayer", getRootElement(), killplayer) 
  
function muteplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        if ( getElementData ( victim, "muted" ) == false ) then 
            setPlayerMuted ( victim, true ) 
            setElementData (victim, "muted", true) 
            outputChatBox ("You just muted " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got muted.", victim, 125, 125, 125 ) 
        elseif ( getElementData ( victim, "muted" ) == true ) then 
            setPlayerMuted ( victim, false ) 
            setElementData (victim, "muted", false) 
            outputChatBox ("You just unmuted " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got unmuted.", victim, 125, 125, 125 ) 
        end 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("mute", true) 
addEventHandler ("mute", getRootElement(), muteplayer) 
function freezeplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        if ( getElementData ( victim, "froozen" ) == false ) then 
            toggleAllControls ( victim, false, true, false ) 
            setElementData (victim, "froozen", true) 
            outputChatBox ("You just freezed " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got freezed.", victim, 125, 125, 125 ) 
        elseif ( getElementData ( victim, "froozen" ) == true ) then 
            toggleAllControls ( victim,true,true,true ) 
            setElementData (victim, "froozen", false) 
            outputChatBox ("You're now free to move " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got un-froozen.", victim, 125, 125, 125 ) 
        end 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("freeze", true) 
addEventHandler ("freeze", getRootElement(), freezeplayer) 
  
function banplayer (reason) 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        banPlayer ( victim, true, true, true, getRootElement(), tostring(reason), 20) 
        outputChatBox ("You just banned " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ( getPlayerName(source) .. " has just banned " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("ban", true) 
addEventHandler ("ban", getRootElement(), banplayer) 
  
function kickplayer (reason) 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        kickPlayer ( victim, getRootElement(), reason) 
        outputChatBox ("You just kicked " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ( getPlayerName(source) .. " has just kicked " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("kick", true) 
addEventHandler ("kick", getRootElement(), kickplayer) 
  
addEvent ( "destroyVehicle", true ) 
addEventHandler ( "destroyVehicle", root, 
    function ( theVehicle ) 
        if ( theVehicle ) then 
            destroyElement ( theVehicle ) 
            setElementData ( source, "adminclickselplayer", nil ) 
        end 
    end 
) 

That works, even when the script is a real mess.

Link to comment
-- adminclickcars_cl:
function playermenu ( ) 
    if ( not isElement ( mainwindow ) ) then 
        victimemt = getElementData ( getRootElement(), "adminclickselplayer" ) 
        mainwindow = guiCreateWindow ( 750, 250, 240, 180, "Car menu", false ) 
        -- 
        fixveh = guiCreateButton ( 0.05, 0.15, 0.4, 0.15, "Fix vehicle", true, mainwindow ) 
        blowveh = guiCreateButton ( 0.55, 0.15, 0.4, 0.15, "Blow up vehicle", true, mainwindow ) 
        -- 
        delveh = guiCreateButton ( 0.05, 0.35, 0.4, 0.15, "Delete vehicle", true, mainwindow ) 
        colveh = guiCreateButton ( 0.55, 0.35, 0.4, 0.15, "Colour vehicle", true, mainwindow ) 
        -- 
        upgveh = guiCreateButton ( 0.05, 0.55, 0.4, 0.15, "Upgrade vehicle", true, mainwindow ) 
        selowner = guiCreateButton ( 0.55, 0.55, 0.4, 0.15, "Select driver", true, mainwindow ) 
        -- 
        closebutton = guiCreateButton ( 0.30, 0.8, 0.4, 0.15, "Close", true, mainwindow ) 
        addEventHandler( "onClientGUIClick", delveh, vc, false ) 
        addEventHandler( "onClientGUIClick", closebutton, disable, false ) 
        addEventHandler( "onClientGUIClick", selowner, selectowner, false ) 
    end 
end 
addEvent ("carmenu", true) 
addEventHandler ("carmenu", getRootElement(), playermenu) 
  
function disable () 
    guiSetVisible ( mainwindow, false ) 
    setElementData ( localPlayer, "adminclickselplayer", nil ) 
    setElementData ( getRootElement(), "adminclickopen", false ) 
end 
  
function selectowner () 
    thecar = getElementData ( localPlayer, "adminclickselplayer" ) 
    occupant = getVehicleOccupant ( thecar ) 
    guiSetVisible ( mainwindow, false ) 
    if ( occupant ) then 
        setElementData ( localPlayer, "adminclickselplayer", occupant ) 
    else 
        outputChatBox ( "This vehicle does not have a driver", 255, 0, 0 ) 
    end 
end 
  
function vc ( ) 
    local thecar = getElementData ( localPlayer, "adminclickselplayer" ) 
    if ( thecar and isElement ( thecar ) ) then 
        triggerServerEvent ( "destroyVehicle", localPlayer, thecar ) 
    end 
end 

-- adminclick.lua:

setElementData (getRootElement(), "adminclickopen", false) 
setElementData (getRootElement(), "adminclickmousebind", false) 
  
function clickmenu (mouseButton, buttonState, clickedElement, worldPosX, worldPosY, worldPosZ, screenPosX, screenPosY) 
    if ( buttonState == "down" ) then 
        if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
            if ( not getElementData ( source, "adminclickopen" ) ) then 
                if ( getElementData ( source, "adminclickmousebind") ) then 
                    if ( mouseButton == "right" ) then 
                        if ( clickedElement ) then 
                            if ( getElementType (clickedElement) == "player" ) then 
                                name = getPlayerName (clickedElement) 
                                setElementData ( source, "adminclickselplayer", tostring(name) ) 
                                setElementData ( source, "adminclickopen", true) 
                                triggerClientEvent (source,"playermenu", getRootElement() ) 
                            elseif ( getElementType (clickedElement) == "vehicle" ) then 
                                thecar = clickedElement 
                                setElementData ( source, "adminclickselplayer", thecar ) 
                                triggerClientEvent (source,"carmenu", getRootElement() ) 
                            end 
                        end 
                    elseif ( mouseButton == "left" ) then 
                        --outputChatBox ( worldPosX .. "," .. worldPosY .. "," .. worldPosZ ) 
                        --[[ Random send cars & players flying, can be abused 
                        col = createColCircle ( worldPosX, worldPosY, 15) 
                        colelements = getElementsWithinColShape (col) 
                        for theKey,theElement in ipairs(colelements) do   
                            if ( getElementType (theElement) == "player" ) then 
                                setElementVelocity ( theElement, 2, 0, 5) 
                            elseif ( getElementType (theElement) == "vehicle" ) then 
                                setElementVelocity ( theElement, 2, 0, 1.5) 
                            end 
                        end 
                        --]] 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onPlayerClick", getRootElement(), clickmenu ) 
  
function onstart() 
players = getElementsByType ( "player" ) -- get a table of all the players in the server 
    for theKey,player in ipairs(players) do 
        if ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) then    
            setElementData ( player, "adminclickopen", false) 
            setElementData ( player, "adminclickmousebind", false) 
            bindKey (player, "o", "down", showmouse, player ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstart ) 
  
function showmouse ( player ) 
    showCursor ( player, not isCursorShowing ( player ) ) 
    setElementData ( player, "adminclickmousebind", isCursorShowing ( player ) ) 
end 
  
function bindmouse () 
    if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
        setElementData ( source, "adminclickopen", false ) 
        setElementData ( source, "adminclickmousebind", false ) 
        bindKey ( source, "o", "down", showmouse ) 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), bindmouse ) 
  
function killplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        killPed (victim) 
        outputChatBox ("You just killed " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ("You just admin killed!", victim, 125, 125, 125 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("killplayer", true) 
addEventHandler ("killplayer", getRootElement(), killplayer) 
  
function muteplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        if ( getElementData ( victim, "muted" ) == false ) then 
            setPlayerMuted ( victim, true ) 
            setElementData (victim, "muted", true) 
            outputChatBox ("You just muted " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got muted.", victim, 125, 125, 125 ) 
        elseif ( getElementData ( victim, "muted" ) == true ) then 
            setPlayerMuted ( victim, false ) 
            setElementData (victim, "muted", false) 
            outputChatBox ("You just unmuted " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got unmuted.", victim, 125, 125, 125 ) 
        end 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("mute", true) 
addEventHandler ("mute", getRootElement(), muteplayer) 
function freezeplayer () 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        if ( getElementData ( victim, "froozen" ) == false ) then 
            toggleAllControls ( victim, false, true, false ) 
            setElementData (victim, "froozen", true) 
            outputChatBox ("You just freezed " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got freezed.", victim, 125, 125, 125 ) 
        elseif ( getElementData ( victim, "froozen" ) == true ) then 
            toggleAllControls ( victim,true,true,true ) 
            setElementData (victim, "froozen", false) 
            outputChatBox ("You're now free to move " .. victimemt, source, 125, 125, 125 ) 
            outputChatBox ("You just got un-froozen.", victim, 125, 125, 125 ) 
        end 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("freeze", true) 
addEventHandler ("freeze", getRootElement(), freezeplayer) 
  
function banplayer (reason) 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        banPlayer ( victim, true, true, true, getRootElement(), tostring(reason), 20) 
        outputChatBox ("You just banned " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ( getPlayerName(source) .. " has just banned " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("ban", true) 
addEventHandler ("ban", getRootElement(), banplayer) 
  
function kickplayer (reason) 
victimemt = getElementData ( source, "adminclickselplayer" ) 
victim = getPlayerFromName (tostring(victimemt)) 
    if ( isElement(victim) ) then 
        kickPlayer ( victim, getRootElement(), reason) 
        outputChatBox ("You just kicked " .. victimemt, source, 125, 125, 125 ) 
        outputChatBox ( getPlayerName(source) .. " has just kicked " .. victimemt .. " for: " .. tostring(reason), source, 255, 0, 0 ) 
    else 
        outputChatBox ("This player is no longer connected.", source, 255, 0, 0 ) 
    end 
end 
addEvent("kick", true) 
addEventHandler ("kick", getRootElement(), kickplayer) 
  
addEvent ( "destroyVehicle", true ) 
addEventHandler ( "destroyVehicle", root, 
    function ( theVehicle ) 
        if ( theVehicle ) then 
            destroyElement ( theVehicle ) 
            setElementData ( source, "adminclickselplayer", nil ) 
        end 
    end 
) 

That works, even when the script is a real mess.

He worked to delete the vehicle but the window to not show selection another vehicle also actions the player not show the window

Link to comment
setElementData (getRootElement(), "adminclickopen", false) 
setElementData (getRootElement(), "adminclickmousebind", false) 
  
function clickmenu (mouseButton, buttonState, clickedElement, worldPosX, worldPosY, worldPosZ, screenPosX, screenPosY) 
    if ( buttonState == "down" ) then 
        if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
            if ( not getElementData ( source, "adminclickopen" ) ) then 
                if ( getElementData ( source, "adminclickmousebind") ) then 
                    if ( mouseButton == "right" ) then 
                        if ( clickedElement ) then 
                            if ( getElementType (clickedElement) == "player" ) then 
                                name = getPlayerName (clickedElement) 
                                setElementData ( source, "adminclickselplayer", tostring(name) ) 
                                setElementData ( source, "adminclickopen", true) 
                                triggerClientEvent (source,"playermenu", getRootElement() ) 
                            elseif ( getElementType (clickedElement) == "vehicle" ) then 
                                thecar = clickedElement 
                                setElementData ( source, "adminclickselplayer", thecar ) 
                                triggerClientEvent (source,"carmenu", getRootElement() ) 
                            end 
                        end 
                    elseif ( mouseButton == "left" ) then 
                        --outputChatBox ( worldPosX .. "," .. worldPosY .. "," .. worldPosZ ) 
                        --[[ Random send cars & players flying, can be abused 
                        col = createColCircle ( worldPosX, worldPosY, 15) 
                        colelements = getElementsWithinColShape (col) 
                        for theKey,theElement in ipairs(colelements) do   
                            if ( getElementType (theElement) == "player" ) then 
                                setElementVelocity ( theElement, 2, 0, 5) 
                            elseif ( getElementType (theElement) == "vehicle" ) then 
                                setElementVelocity ( theElement, 2, 0, 1.5) 
                            end 
                        end 
                        --]] 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onPlayerClick", getRootElement(), clickmenu ) 
  
function onstart() 
players = getElementsByType ( "player" ) -- get a table of all the players in the server 
    for theKey,player in ipairs(players) do 
        if ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) then    
            setElementData ( player, "adminclickopen", false) 
            setElementData ( player, "adminclickmousebind", false) 
            bindKey (player, "o", "down", showmouse, player ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstart ) 
  
function showmouse ( player ) 
    showCursor ( player, not isCursorShowing ( player ) ) 
    setElementData ( player, "adminclickmousebind", isCursorShowing ( player ) ) 
end 
  
function bindmouse () 
    if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
        setElementData ( source, "adminclickopen", false ) 
        setElementData ( source, "adminclickmousebind", false ) 
        bindKey ( source, "o", "down", showmouse ) 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), bindmouse ) 
  
addEvent ( "destroyVehicle", true ) 
addEventHandler ( "destroyVehicle", root, 
    function ( theVehicle ) 
        if ( theVehicle ) then 
            destroyElement ( theVehicle ) 
            setElementData ( source, "adminclickselplayer", nil ) 
        end 
    end 
) 

function playermenu () 
    if ( guiGetVisible (mainwindow) == false ) then 
        victimemt = getElementData ( getRootElement(), "adminclickselplayer" ) 
        mainwindow = guiCreateWindow ( 750, 250, 240, 180, "Car menu", false ) 
        -- 
        fixveh = guiCreateButton ( 0.05, 0.15, 0.4, 0.15, "Fix vehicle", true, mainwindow ) 
        blowveh = guiCreateButton ( 0.55, 0.15, 0.4, 0.15, "Blow up vehicle", true, mainwindow ) 
        -- 
        delveh = guiCreateButton ( 0.05, 0.35, 0.4, 0.15, "Delete vehicle", true, mainwindow ) 
        colveh = guiCreateButton ( 0.55, 0.35, 0.4, 0.15, "Colour vehicle", true, mainwindow ) 
        -- 
        upgveh = guiCreateButton ( 0.05, 0.55, 0.4, 0.15, "Upgrade vehicle", true, mainwindow ) 
        selowner = guiCreateButton ( 0.55, 0.55, 0.4, 0.15, "Select driver", true, mainwindow ) 
        -- 
        closebutton = guiCreateButton ( 0.30, 0.8, 0.4, 0.15, "Close", true, mainwindow ) 
         addEventHandler( "onClientGUIClick", closebutton, disable, false) 
         addEventHandler( "onClientGUIClick", selowner, selectowner, false) 
         addEventHandler( "onClientGUIClick", delveh, vc, false) 
--       addEventHandler( "onClientGUIClick", mutebutton, mute, false) 
--       addEventHandler( "onClientGUIClick", freezebutton, freeze, false) 
--       addEventHandler( "onClientGUIClick", banbutton, ban, false) 
--       addEventHandler( "onClientGUIClick", kickbutton, kick, false) 
    end 
end 
addEvent ("carmenu", true) 
addEventHandler ("carmenu", getRootElement(), playermenu) 
function disable () 
guiSetVisible ( mainwindow, false) 
setElementData ( source, "adminclickselplayer", "none" ) 
setElementData (getRootElement(), "adminclickopen", false) 
end 
function selectowner () 
thecar = getElementData ( getRootElement(), "adminclickselplayer" ) 
occupant = getVehicleOccupant ( thecar ) 
guiSetVisible ( mainwindow, false) 
    if ( occupant ) then  
        setElementData ( getRootElement(), "adminclickselplayer", getPlayerName(occupant) ) 
        triggerEvent ("playermenu", occupant) 
    else 
        outputChatBox ("This vehicle does not have a driver", 255, 0, 0 ) 
    end 
end 
function vc ( ) 
    local thecar = getElementData ( localPlayer, "adminclickselplayer" ) 
    if ( thecar and isElement ( thecar ) ) then 
        triggerServerEvent ( "destroyVehicle", localPlayer, thecar ) 
    end 
end 

I have tried this but the player menu do not show to me !!

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