Jump to content

Need help!!


Mark0

Recommended Posts

what's Wrong :

1-evry one can take vehicles but i make it only for Medic

2-when i take a vehicle i spown out of the vehicle

local vehicles = { } 
  
addEvent ( "spawnvehicle", true ) 
addEventHandler ( "spawnvehicle", root, 
    function ( vehID ) 
    local team = getPlayerTeam(source) 
    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 
        if(isPedInVehicle(source)) then return end 
     if (team and getTeamName(team) == "Medic") then 
      setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
end 
end 
) 

Link to comment
  • Other Languages Moderators
local vehicles = { } 
  
addEvent("spawnvehicle", true) 
addEventHandler("spawnvehicle", root, 
function(vehID) 
     local team = getPlayerTeam(source) 
     if (team and getTeamName(team) == "Medic") then 
          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) 
               setTimer(warpPedIntoVehicle, 200, 1, source, vehicles[source]) 
               triggerClientEvent(source, "closeWindow", root) 
          end 
     end 
end) 

Link to comment

local marker = createMarker(1183.9000244141, -1331, 12.5, 'cylinder', 1.5, 255, 255, 255, 155)

local vehicles = {"BMX", "Bike", "Mountain Bike", "Faggio"}

function createVehGui ()

wnd = guiCreateWindow(0.39,0.1633,0.21,0.55,"Free Vehicles",true)

guiSetAlpha(CIGwnd,1)

guiWindowSetSizable(CIGwnd,false)

VehGrid = guiCreateGridList(0.0536,0.1394,0.8869,0.6273,true,wnd)

guiGridListSetSelectionMode(VehGrid,2)

_bikes = guiGridListAddColumn(VehGrid,"Vehicles name:",0.8)

Spownbtn = guiCreateButton(0.1667,0.7939,0.6905,0.0727,"Spown",true,wnd)

guiSetFont(Spownbtn,"clear-normal")

closebtn = guiCreateButton(0.1667,0.9,0.6905,0.0727,"Close",true,wnd)

guiSetFont(closebtn,"clear-normal")

for index, vehicle in ipairs(vehicles) do

local row = guiGridListAddRow (VehGrid)

guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false )

end

end

function markerspown( hitElement )

if ( hitElement == localPlayer ) then

createVehGui ( hitElement )

if ( wnd ~= nil ) then

guiSetVisible ( wnd, true )

showCursor ( true )

guiSetInputEnabled ( true )

setElementFrozen ( hitElement, true )

end

end

end

addEventHandler ( "onClientMarkerHit", marker, markerspown)

addEventHandler("onClientGUIClick", root,

function ()

if (source == Spownbtn) 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,481)

elseif vehicleName == "Bike" then

triggerServerEvent("spawnvehicle",localPlayer,509)

elseif vehicleName == "Mountain Bike" then

triggerServerEvent("spawnvehicle",localPlayer,510)

elseif vehicleName == "Faggio" then

triggerServerEvent("spawnvehicle",localPlayer,462)

end

else

outputChatBox("Please,select a vehicle of the list.",255,0,0)

end

elseif (source == closebtn) 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(wnd, false)

showCursor(false)

guiSetInputEnabled(false)

setElementFrozen(localPlayer, false)

end

)

Edited by Guest
Link to comment
  • Other Languages Moderators
I think this should work:
function testing() 
if getPlayerTeam( getTeamFromName( 'Medic' ) then 
guiSetVisible( window, true ) 
else 
guiSetVisible( window, false )  
--Note: you need to change few pieces like in the "GuiSetVisible" the window 

function testing() 
if getPlayerTeam( localPlayer ) == getTeamFromName( 'Medic' ) then 
guiSetVisible( window, true ) 
else 
guiSetVisible( window, false ) 
--Note: you need to change few pieces like in the "GuiSetVisible" the window 

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