Jump to content

Panel Help


damien111

Recommended Posts

I am trying to make a panel that spawns objects and deletes them :) I cant get it to work, it is suppose to work on /stpanel

here is my code

CLIENT:

 GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Edit = {} 
  
GUIEditor_Window[1] = guiCreateWindow(550,134,249,462,"State Trooper Panel",false) 
GUIEditor_TabPanel[1] = guiCreateTabPanel(9,19,231,434,false,GUIEditor_Window[1]) 
GUIEditor_Tab[1] = guiCreateTab("Basic Controls",GUIEditor_TabPanel[1]) 
GUIEditor_Button[1] = guiCreateButton(14,9,200,36,"Turn On Blipless",false,GUIEditor_Tab[1]) 
GUIEditor_Button[2] = guiCreateButton(14,51,199,35,"Turn Off Blipless",false,GUIEditor_Tab[1]) 
GUIEditor_Button[3] = guiCreateButton(16,149,200,36,"Locate Player",false,GUIEditor_Tab[1]) 
GUIEditor_Edit[1] = guiCreateEdit(14,116,200,31,"",false,GUIEditor_Tab[1]) 
GUIEditor_Tab[2] = guiCreateTab("Road Block Tools",GUIEditor_TabPanel[1]) 
GUIEditor_Button[4] = guiCreateButton(8,17,215,38,"Small Roadblock",false,GUIEditor_Tab[2]) 
GUIEditor_Button[5] = guiCreateButton(7,61,219,37,"Large Roadblock",false,GUIEditor_Tab[2]) 
GUIEditor_Button[6] = guiCreateButton(5,102,221,37,"Yellow Roadblock",false,GUIEditor_Tab[2]) 
GUIEditor_Button[7] = guiCreateButton(9,144,216,40,"Detour Sign",false,GUIEditor_Tab[2]) 
GUIEditor_Button[8] = guiCreateButton(7,188,219,42,"Traffic Cone",false,GUIEditor_Tab[2]) 
GUIEditor_Button[9] = guiCreateButton(11,233,213,45,"Warning Fence",false,GUIEditor_Tab[2]) 
GUIEditor_Button[10] = guiCreateButton(11,280,212,47,"Stinger",false,GUIEditor_Tab[2]) 
GUIEditor_Button[11] = guiCreateButton(10,346,211,53,"Delete All",false,GUIEditor_Tab[2]) 
  
  
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , turnOnBlipless, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , turnOffBlipless, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , locPlayer, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBSMALL, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBLARGE, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBYELLOW, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBSIGN, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBCONE, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBSTINGER, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBFENCE, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , RBDEL, false) 
  
function showgui ( ) 
  
         guiSetVisible(GUIEditor_Window[1], true) 
         showCursor(true) 
  
end 
  
addCommandHandler("stpanel", showgui) 
  
rbs = { } 
  
function RBDEL(source,command) 
  
            for index, roadb in ipairs( rbs ) do 
                destroyElement( roadb ) 
            end 
            outputChatBox("*ROADBLOCK* Deleted all roadblocks.",source,255,255,0) 
  
end 
  
  
  
  
  
function RBSMALL(source) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(978,x,y,z-0.15,0,0,rotZ) ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
  
  
  
function RBLARGE(source) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(981,x,y,z,0,0,rotZ+180) ) 
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
  
function RBYELLOW(source) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3578,x,y,z-0.2,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
  
  
  
function RBSIGN(source) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(3091,x,y,z-0.38,0,0,rotZ+180) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
  
  
function RBCONE(source) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1238,x,y,z-0.65,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
  
  
  
function fence(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(1459,x,y,z-0.4,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
  
function line(source,command) 
  
            local x,y,z = getElementPosition(source) 
  
            local rotX,rotY,rotZ = getElementRotation(source) 
  
            table.insert(rbs,  createObject(2957,x,y,z-2.6,0,0,rotZ) ) 
  
        setElementID ( roadblockobject, rbo ) 
            setElementPosition ( source, x, y, z+1 ) 
  
            outputChatBox("*ROADBLOCK* Added.",source,255,255,0) 
  
end 
  
function turnOnBlipless ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
  
  
end 
  
function turnOffBlipless ( thePlayer ) 
for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                setElementVisibleTo ( element, root, ( not isElementVisibleTo ( element ) ) ) 
            end 
        end 
  
end 
  
function locPlayer( ) 
    local myPlayer = GUIEditor_Edit[1] ( ) 
outputChatBox ( getPlayerName ( myPlayer ).." is now being tracked!" ) 
createBlipAttachedTo ( myPlayer, [ 23, 2, 255,  0, 0, 255, 0, 99999.0] ) 
  
end 

and no server code :)

Edited by Guest
Link to comment

1: This does not make any sense:

function locPlayer( ) 
    local myPlayer = GUIEditor_Edit[1] ( ) 
outputChatBox ( getPlayerName ( myPlayer ).." is now being tracked!" ) 
createBlipAttachedTo ( myPlayer, [ 23, 2, 255,  0, 0, 255, 0, 99999.0] ) 
  
end 

2: setElementVisibleTo is a server side only function, your script is client side.

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