Mark0 Posted November 11, 2012 Share Posted November 11, 2012 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 TAPL Posted November 11, 2012 Other Languages Moderators Share Posted November 11, 2012 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
Mark0 Posted November 11, 2012 Author Share Posted November 11, 2012 it work but if ur not Medic u can see the Window Link to comment
Other Languages Moderators TAPL Posted November 11, 2012 Other Languages Moderators Share Posted November 11, 2012 it work but if ur not Medic u can see the Window Post client side. Link to comment
Mark0 Posted November 11, 2012 Author Share Posted November 11, 2012 (edited) 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. 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 November 12, 2012 by Guest Link to comment
manve1 Posted November 11, 2012 Share Posted November 11, 2012 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 Link to comment
Other Languages Moderators TAPL Posted November 11, 2012 Other Languages Moderators Share Posted November 11, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now