Jump to content

Little problem pls help me!


TheIceman

Recommended Posts

I made car spawn script and i cant spawn car who can help me?

function openGUI() 
window = guiCreateWindow (0.3,0.2,0.3,0.6,"SACR Car spawn",true) 
gridlist = guiCreateGridList (0.1,0.1,0.8,0.7,true,window) 
column = guiGridListAddColumn( gridlist, "Vehicles:", 0.85 ) 
row = guiGridListAddRow ( gridlist ) 
guiGridListSetItemText ( gridlist, row, column, "Patriot", false, false ) 
button = guiCreateButton (0.8,0.8,0.2,0.2,"Patriot",true,window) 
close = guiCreateButton(0,0.85,0.45,0.1,"Close",true,window) 
  
    showCursor (true) 
end 
addEvent ("openGUI",true) 
addEventHandler ("openGUI",getRootElement(getThisResource()),openGUI) 
  
function destroyGUI() 
     destroyElement(window) 
 window = false 
     showCursor (false) 
end 
  
  
function buttonClick() 
   if source == row then 
triggerServerEvent ("vehicle",getLocalPlayer()) 
destroyGUI () 
   elseif source == close then 
destroyGUI () 
    end 
end 
addEventHandler("onClientGUIClick",getRootElement(),buttonClick) 
  
  

Please help me!!

Link to comment
local vehicles = 
    { 
        "Patriot" 
    } 
  
function openGUI ( ) 
    window = guiCreateWindow (0.3,0.2,0.3,0.6,"SACR Car spawn",true) 
    gridlist = guiCreateGridList (0.1,0.1,0.8,0.7,true,window) 
    column = guiGridListAddColumn( gridlist, "Vehicles:", 0.85 ) 
    for index, vehicle in ipairs ( vehicles ) do 
        local row = guiGridListAddRow ( gridlist ) 
        guiGridListSetItemText ( gridlist, row, column, tostring ( vehicle ), false, false ) 
    end 
    button = guiCreateButton (0.8,0.8,0.2,0.2,"Spawn",true,window) 
    close = guiCreateButton(0,0.85,0.45,0.1,"Close",true,window) 
    showCursor ( true ) 
end 
addEvent ( "openGUI", true ) 
addEventHandler ( "openGUI", root, openGUI ) 
  
function destroyGUI() 
    destroyElement(window) 
    showCursor (false) 
    window = nil 
end 
  
function buttonClick ( ) 
   if ( source == button ) then -- "row" is not a GUI element. 
        local row, col = guiGridListGetSelectedItem ( gridlist ) -- Get the selected item from the grid list. 
        if ( row and col and row ~= -1 and col ~= -1 ) then -- If he has a selected item. 
            local vehicleName = guiGridListGetItemText ( gridlist, row, col ) -- Get the text of it. 
            triggerServerEvent ( "vehicle", localPlayer, getVehicleModelFromName ( vehicleName ) ) -- Trigger the "vehicle" event with a vehicle model argument. 
            destroyGUI () 
        end 
   elseif ( source == close ) then 
        destroyGUI () 
    end 
end 
addEventHandler ( "onClientGUIClick", getRootElement(), buttonClick ) 

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