Jump to content

Need Help.


Vanlot

Recommended Posts

Hi Guys Actually I Don't Understand Much in Scripting.I Want To Add To A Label But I Don't Know Where I Must Put The Label Line. & I Think That it's Like That :

GUIEditor_Label[1] = guiCreateLabel(x,y,z,a,"By:Lavand",true,Spawn) 

I Don't Know if the Label Function Correct. & Plz Tell me Where I Must Pu tIt In This Script:

function createVehGui () 
    MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) 
    guiWindowSetSizable ( MainGui, false ) 
    VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
    guiGridListSetSelectionMode(VehGrid,2) 
    _bikes = guiGridListAddColumn(VehGrid,"Bikes",0.85) 
    Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) 
    guiSetFont(Spawn,"clear-normal") 
    Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) 
    guiSetFont(Cancel,"clear-normal") 
    for index, vehicle in ipairs(vehicles) do 
        local row = guiGridListAddRow (VehGrid) 
        guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) 
    end 
end 
local marker = createMarker(1064.5, 1752.9000244141, 9.3000001907349, 'cylinder', 1.5, 255, 255, 255, 255) 
local vehicles = {"BMX", "Bike", "Infernus", "NRG-500"} 
    addEventHandler("onClientMarkerHit", marker,     
    function spawnBike(hitElement) 
         if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
              if not guiGetVisible(MainGui) then 
                   guiSetVisible(MainGui, true) 
                   showCursor(true) 
              end 
         end 
    end 
) 
        if ( isElement ( vehicles [ source ] ) ) then 
            destroyElement ( vehicles [ source ] ) 
        end  
vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) 
        if ( vehicles [ source ] ) then 
            setVehicleColor ( vehicles [ source ], 255, 255, 255 ) 
        end 
        setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
addEvent ( "spawnVehicle", true ) 
addEventHandler ( "spawnVehicle", root, 
    function ( vehID, hitElement ) 
............. 
end) 
local vehicles = { } 
addEventHandler("onClientGUIClick", root,  
function () 
if (source == Spawn) then 
            local row,col = guiGridListGetSelectedItem(VehGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
        elseif vehicleName == "Bike" then 
            triggerServerEvent("spawnvehicle",localPlayer,481) 
                end  
            else 
                outputChatBox("Error: Please, select a vehicle of list.",255,0,0) 
            elseif (source == Cancel) then 
                triggerEvent("closeWindow", root ) 
         
end 
end 
) 
addEventHandler("onClientGUIDoubleClick", root,  
function () 
            if ( source == VehGrid ) then 
      local row,col = guiGridListGetSelectedItem(VehGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
        elseif vehicleName == "Bike" then 
            triggerServerEvent("spawnvehicle",localPlayer,481) 
                end  
            end 
        end 
end 
) 
addEventHandler("onClientMarkerLeave", marker, 
function () 
        triggerEvent("closeWindow", root ) 
end 
) 
addEvent("closeWindow", true) 
addEventHandler("closeWindow", root,  
function () 
            guiSetVisible(MainGui, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
            setElementFrozen(localPlayer, false) 
end 
) 

Link to comment

The Server Side:

local vehicles = { } 
  
addEvent ( "spawnvehicle", true ) 
addEventHandler ( "spawnvehicle", root, 
    function ( vehID ) 
     if ( isElement ( vehicles [ source ] ) ) then 
            destroyElement ( vehicles [ source ] ) 
        end  
     vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) 
        if ( vehicles [ source ] ) then 
            setVehicleColor ( vehicles [ source ], 255, 255, 255 ) 
        end 
      setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
end 
) 

Link to comment

fixed a lots and a lots of erros in your script ,

function createVehGui () 
    MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) 
    guiWindowSetSizable ( MainGui, false ) 
    VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
    guiGridListSetSelectionMode(VehGrid,2) 
    _bikes = guiGridListAddColumn(VehGrid,"Bikes",0.85) 
    Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) 
    guiSetFont(Spawn,"clear-normal") 
    Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) 
    GUIEditor_Label[1] = guiCreateLabel(x,y,z,a,"By:Lavand",true,MainGui) 
    guiSetFont(Cancel,"clear-normal") 
    for index, vehicle in ipairs(vehicles) do 
        local row = guiGridListAddRow (VehGrid) 
        guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) 
    end 
end 
local marker = createMarker(1064.5, 1752.9000244141, 9.3000001907349, 'cylinder', 1.5, 255, 255, 255, 255) 
local vehicles = {"BMX", "Bike", "Infernus", "NRG-500"} 
    addEventHandler("onClientMarkerHit", marker,     
    function (hitElement) 
         if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
              if not guiGetVisible(MainGui) then 
                   guiSetVisible(MainGui, true) 
                   showCursor(true) 
              end 
        if ( isElement ( vehicles [ source ] ) ) then 
            destroyElement ( vehicles [ source ] ) 
        end 
vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) 
        if ( vehicles [ source ] ) then 
            setVehicleColor ( vehicles [ source ], 255, 255, 255 ) 
        end 
        setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
addEvent ( "spawnVehicle", true ) 
addEventHandler ( "spawnVehicle", root, 
    function ( vehID, hitElement ) 
end) 
local vehicles = { } 
addEventHandler("onClientGUIClick", root,  
function () 
if (source == Spawn) then 
            local row,col = guiGridListGetSelectedItem(VehGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
        elseif vehicleName == "Bike" then 
            triggerServerEvent("spawnvehicle",localPlayer,481) 
            else 
                outputChatBox("Error: Please, select a vehicle of list.",255,0,0) 
            if (source == Cancel) then  
                triggerEvent("closeWindow", root) 
                end 
                end 
                end 
         
addEventHandler("onClientGUIDoubleClick", root,  
function () 
     if ( source == VehGrid ) then 
      local row,col = guiGridListGetSelectedItem(VehGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
        elseif vehicleName == "Bike" then 
            triggerServerEvent("spawnvehicle",localPlayer,481) 
                end  
            end 
        end 
end 
) 
addEventHandler("onClientMarkerLeave", marker, 
function () 
        triggerEvent("closeWindow", root ) 
end 
) 
addEvent("closeWindow", true) 
addEventHandler("closeWindow", root,  
function () 
            guiSetVisible(MainGui, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
            setElementFrozen(localPlayer, false) 
            end) 
            end 
            end) 
            end 
            end) 

Link to comment

-- Client Side --

MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) 
guiWindowSetSizable(MainGui, false) 
guiSetVisible(MainGui, false) 
VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
guiGridListSetSelectionMode(VehGrid,2) 
_bikes = guiGridListAddColumn(VehGrid,"Bikes",0.85) 
Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) 
guiSetFont(Spawn,"clear-normal") 
Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) 
Label = guiCreateLabel(x,y,z,a,"By:Lavand",false,MainGui) 
guiSetFont(Cancel,"clear-normal") 
  
local vehicles = {"BMX", "Bike", "Infernus", "NRG-500"} 
  
for index, vehicle in ipairs(vehicles) do 
     local row = guiGridListAddRow (VehGrid) 
     guiGridListSetItemText(VehGrid, row, _bikes, tostring(vehicle), false, false) 
end 
  
local marker = createMarker(1064.5, 1752.9000244141, 9.3000001907349, 'cylinder', 1.5, 255, 255, 255, 255) 
  
addEventHandler("onClientMarkerHit", marker,     
function (hitElement) 
     if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
          if not guiGetVisible(MainGui) then 
               guiSetVisible(MainGui, true) 
               showCursor(true) 
          end 
     end 
end 
  
addEventHandler("onClientGUIClick", root, 
function () 
     if (source == Spawn) then 
          local row,col = guiGridListGetSelectedItem(VehGrid) 
               if (row and col and row ~= -1 and col ~= -1) then 
                    local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                    if vehicleName == "BMX" then 
                         triggerServerEvent("spawnvehicle",localPlayer,509) 
                    elseif vehicleName == "Bike" then 
                           triggerServerEvent("spawnvehicle",localPlayer,481) 
                    else 
                         outputChatBox("Error: Please, select a vehicle of list.",255,0,0) 
                    end 
               if (source == Cancel) then 
                    triggerEvent("closeWindow", root) 
               end 
          end 
     end 
end) 
  
addEventHandler("onClientGUIDoubleClick", root, 
function () 
     if (source == VehGrid) then 
          local row,col = guiGridListGetSelectedItem(VehGrid) 
          if (row and col and row ~= -1 and col ~= -1) then 
               local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
               if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
               elseif vehicleName == "Bike" then 
                    triggerServerEvent("spawnvehicle",localPlayer,481) 
               end 
          end 
     end 
end) 
  
addEventHandler("onClientMarkerLeave", marker, 
function () 
     triggerEvent("closeWindow", root) 
end) 
  
addEvent("closeWindow", true) 
addEventHandler("closeWindow", root, 
function () 
     guiSetVisible(MainGui, false) 
     showCursor(false) 
     guiSetInputEnabled(false) 
     setElementFrozen(localPlayer, false) 
end) 

-- Server Side --

local vehicles = { } 
  
addEvent("spawnvehicle", true) 
addEventHandler("spawnvehicle", root, 
function(vehID) 
     if isElement(vehicles[source]) then 
          destroyElement(vehicles[source]) 
          local x,y,z = getElementPosition(source) 
          vehicles[source] = createVehicle(vehID,x,y,z) 
          if vehicles[source] then 
               setVehicleColor(vehicles[source],255,255,255) 
               setTimer(warpPedIntoVehicle, 200,1,source,vehicles[source]) 
               triggerClientEvent(source, "closeWindow", source) 
          end 
     end 
end) 

Link to comment

Fixed + Tested.

-- Client Side --

MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) 
guiWindowSetSizable(MainGui, false) 
guiSetVisible(MainGui, false) 
VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
guiGridListSetSelectionMode(VehGrid,2) 
_bikes = guiGridListAddColumn(VehGrid,"Bikes",0.85) 
Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) 
guiSetFont(Spawn,"clear-normal") 
Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) 
Label = guiCreateLabel(x,y,z,a,"By:Lavand",false,MainGui) 
guiSetFont(Cancel,"clear-normal") 
  
local vehicles = {"BMX", "Bike", "Infernus", "NRG-500"} 
  
for index, vehicle in ipairs(vehicles) do 
     local row = guiGridListAddRow (VehGrid) 
     guiGridListSetItemText(VehGrid, row, _bikes, tostring(vehicle), false, false) 
end 
  
local marker = createMarker(1064.5, 1752.9000244141, 9.3000001907349, 'cylinder', 1.5, 255, 255, 255, 255) 
  
addEventHandler("onClientMarkerHit", marker, 
function (hitElement) 
     if getElementType(hitElement) == "player" and (hitElement == localPlayer) and not isPedInVehicle(hitElement) then 
          if not guiGetVisible(MainGui) then 
               guiSetVisible(MainGui, true) 
               showCursor(true) 
          end 
     end 
end) 
  
addEventHandler("onClientGUIClick", root, 
function () 
     if (source == Spawn) then 
          local row,col = guiGridListGetSelectedItem(VehGrid) 
               if (row and col and row ~= -1 and col ~= -1) then 
                    local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                    if vehicleName == "BMX" then 
                         triggerServerEvent("spawnvehicle",localPlayer,509) 
                    elseif vehicleName == "Bike" then 
                           triggerServerEvent("spawnvehicle",localPlayer,481) 
                    elseif vehicleName == "Infernus" then 
                           triggerServerEvent("spawnvehicle",localPlayer,411) 
                    elseif vehicleName == "NRG-500" then 
                           triggerServerEvent("spawnvehicle",localPlayer,522) 
                    end 
               else 
                    outputChatBox("Error: Please, select a vehicle of list.",255,0,0) 
               end 
     elseif (source == Cancel) then 
          triggerEvent("closeWindow", root) 
     end 
end) 
  
addEventHandler("onClientGUIDoubleClick", root, 
function () 
     if (source == VehGrid) then 
          local row,col = guiGridListGetSelectedItem(VehGrid) 
          if (row and col and row ~= -1 and col ~= -1) then 
               local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
               if vehicleName == "BMX" then 
                    triggerServerEvent("spawnvehicle",localPlayer,509) 
               elseif vehicleName == "Bike" then 
                    triggerServerEvent("spawnvehicle",localPlayer,481) 
               elseif vehicleName == "Infernus" then 
                    triggerServerEvent("spawnvehicle",localPlayer,411) 
               elseif vehicleName == "NRG-500" then 
                    triggerServerEvent("spawnvehicle",localPlayer,522) 
               end 
          end 
     end 
end) 
  
addEventHandler("onClientMarkerLeave", marker, 
function () 
     triggerEvent("closeWindow", root) 
end) 
  
addEvent("closeWindow", true) 
addEventHandler("closeWindow", root, 
function () 
     guiSetVisible(MainGui, false) 
     showCursor(false) 
     guiSetInputEnabled(false) 
end) 

-- Server Side --

local vehicles = { } 
  
addEvent("spawnvehicle", true) 
addEventHandler("spawnvehicle", root, 
function(vehID) 
     if isElement(vehicles[source]) then 
          destroyElement(vehicles[source]) 
     end 
          local x,y,z = getElementPosition(source) 
          vehicles[source] = createVehicle(vehID,x,y,z) 
     if vehicles[source] then 
          setVehicleColor(vehicles[source],255,255,255) 
          setTimer(warpPedIntoVehicle, 200,1,source,vehicles[source]) 
          triggerClientEvent(source, "closeWindow", source) 
     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...