Chronos Posted May 7, 2013 Posted May 7, 2013 i creat team (swat) and i want car spawner just for swat members in this location : x: 1603.6314697266 y: -1684.2104492188 z: 5.890625 this is my script but dosn't work i need help to fix it markerpv = createMarker( 1603.6314697266, -1684.2104492188, 5.890625, "cylinder", 2, 0, 0, 255, 255 ) local vehicles = {} local x, y, z = getElementPosition(source) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(id, x + 2, y, z) warpPedIntoVehicle(source, vehicles[source]) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp) addEventHandler("onPlayerQuit", root, function() if isElement(vehicles[source]) then destroyElement(vehicles[source]) vehicles[source] = nil end end function showGUIpv(hitPlayer) if hitPlayer and getElementType(hitPlayer) == "player" then if ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "Swat" ) ) then triggerClientEvent (hitPlayer,"showGUIpv",getRootElement(),hitPlayer) else warnText("vehicles for Swat members only!",hitPlayer) end end end addEventHandler("onMarkerHit",markerpv,showGUIpv) + Wnd1 = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Free Vehicles", true ) -- guiSetAlpha( Wnd1, 1 ) buttonv = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, Wnd1 ) button1v = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, Wnd1 ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "get free vehicle", true, Wnd1 ) showCursor(false) guiSetVisible( Wnd1, false ) guiWindowSetSizable( Wnd1, false ) guiWindowSetMovable( Wnd1, false ) vehicles = { {"S.W.A.T.", 601}, {"FBI Rancher", 490}, {"HPV1000", 523}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd1) guiGridListAddColumn(grid, "Vehicles", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end addEventHandler("onClientGUIClick", button1v, useP, false) function useP() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("CreVehicePv", localPlayer, model) guiSetVisible(Wnd1,false) showCursor(false) end end end addEventHandler("onClientGUIClick", buttonv, close) function showGUIpv() guiSetVisible(Wnd1,true) showCursor(true) end addEvent("showGUIpv",true) addEventHandler("showGUIpv", getRootElement(), showGUIpv) plz help
WASSIm. Posted May 7, 2013 Posted May 7, 2013 function showGUIp(hitPlayer) if hitPlayer and getElementType(hitPlayer) == "player" then if ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "Swat" ) ) then triggerClientEvent (hitPlayer,"showGUIpv",getRootElement(),hitPlayer) else warnText("vehicles for Swat members only!",hitPlayer) end end end addEventHandler("onMarkerHit",markerpv, showGUIp)
Chronos Posted May 7, 2013 Author Posted May 7, 2013 function showGUIp(hitPlayer) if hitPlayer and getElementType(hitPlayer) == "player" then if ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "Swat" ) ) then triggerClientEvent (hitPlayer,"showGUIpv",getRootElement(),hitPlayer) else warnText("vehicles for Swat members only!",hitPlayer) end end end addEventHandler("onMarkerHit",markerpv, showGUIp) don't work
iPrestege Posted May 7, 2013 Posted May 7, 2013 Hmm...You want to show the gui for swat team members only?
Chronos Posted May 7, 2013 Author Posted May 7, 2013 Hmm...You want to show the gui for swat team members only? yep just swat members can spawn from marker
Chronos Posted May 7, 2013 Author Posted May 7, 2013 ok i will post all script this is for swat team swatteam-c.lua local marker = createMarker( 1585.7399902344, -1689.7290039063, 6.21815, "Cylinder", 1.5, 0, 69, 139, 0) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"Swat") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,200,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,100,"To be a swat members, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) guiEditSetReadOnly(GUIEditor_Memo[1],true) function Swat_Team(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, Swat_Team) function Swatjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Swatjobleave) function joinTeam() triggerServerEvent("setSwat",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeSwatWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSwatWindow, false) swatteam-s.lua createBlip ( 1585.7399902344, -1689.7290039063, 6.21815, 6 ) function createSwatTeam () ArmedForcesteam = createTeam ("Swat",69,139,0) end addEventHandler ("onResourceStart", resourceRoot, createSwatTeam) function joinSwat() setPlayerTeam(source,Swat,team) setElementModel(source, 285) giveWeapon ( source, 3, 23, 31, 17, 46 ) setElementData( source, "Occupation", "Swatteam", true ) outputChatBox("You are now a Swat members.",source,69,139,0) end addEvent("setSwat", true) addEventHandler("setSwat",root,joinSwat) function policeJob ( attacker, attackerweapon, bodypart, loss ) theTeam = getPlayerTeam ( attacker ) if (attackerweapon == 3) and (loss > 2 ) then setElementPosition (source, 219, 110, 999, true) setTimer ( setElementPosition, 100000, 1, source, 236.32, 110.4, 1003.2) takePlayerMoney (source, 50) givePlayerMoney (attacker, 100) end end addEventHandler ("onPlayerDamage", getRootElement(), swat) and this for spawner server.lua markerpv = createMarker( 1603.6314697266, -1684.2104492188, 5.890625, "cylinder", 2, 0, 0, 255, 255 ) local vehicles = {} local x, y, z = getElementPosition(source) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(id, x + 2, y, z) warpPedIntoVehicle(source, vehicles[source]) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp) addEventHandler("onPlayerQuit", root, function() if isElement(vehicles[source]) then destroyElement(vehicles[source]) vehicles[source] = nil end end function showGUIpv(hitPlayer) if hitPlayer and getElementType(hitPlayer) == "player" then if ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "Swat" ) ) then triggerClientEvent (hitPlayer,"showGUIpv",getRootElement(),hitPlayer) else warnText("vehicles for Swat members only!",hitPlayer) end end end addEventHandler("onMarkerHit",markerpv,showGUIpv) gui.lua Wnd1 = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Free Vehicles", true ) -- guiSetAlpha( Wnd1, 1 ) buttonv = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, Wnd1 ) button1v = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, Wnd1 ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "get free vehicle", true, Wnd1 ) showCursor(false) guiSetVisible( Wnd1, false ) guiWindowSetSizable( Wnd1, false ) guiWindowSetMovable( Wnd1, false ) vehicles = { {"S.W.A.T.", 601}, {"FBI Rancher", 490}, {"HPV1000", 523}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd1) guiGridListAddColumn(grid, "Vehicles", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end addEventHandler("onClientGUIClick", button1v, useP, false) function useP() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("CreVehicePv", localPlayer, model) guiSetVisible(Wnd1,false) showCursor(false) end end end addEventHandler("onClientGUIClick", buttonv, close) function showGUIpv() guiSetVisible(Wnd1,true) showCursor(true) end addEvent("showGUIpv",true) addEventHandler("showGUIpv", getRootElement(), showGUIpv) meta.xml "chronos" name="swatteam" version="1.0" type="script"/>
xXMADEXx Posted May 7, 2013 Posted May 7, 2013 function showGUIpv(hitPlayer) if getElementType(hitPlayer) == "player" then if ( getTeamName ( getPlayerTeam ( hitPlayer ) ) == "Swat" ) then triggerClientEvent (hitPlayer,"showGUIpv",hitPlayer) else warnText("vehicles for Swat members only!",hitPlayer) end end end addEventHandler("onMarkerHit",markerpv,showGUIpv)
TAPL Posted May 8, 2013 Posted May 8, 2013 Did you forgot the fucnction spawnVehp or what? Did i just wasted my time in writing this reply? And the other replies in the topic, WTF?
Chronos Posted May 8, 2013 Author Posted May 8, 2013 Did you forgot the fucnction spawnVehp or what? Did i just wasted my time in writing this reply? And the other replies in the topic, WTF? sorry but i don't know why my script doesn't work ''
TAPL Posted May 9, 2013 Posted May 9, 2013 LoL? Don't you think that there is something missing here? local vehicles = {} local x, y, z = getElementPosition(source) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(id, x + 2, y, z) warpPedIntoVehicle(source, vehicles[source]) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp)
Blaawee Posted May 9, 2013 Posted May 9, 2013 the missing part : local vehicles = {} function spawnVehp( model ) local x, y, z = getElementPosition( source ) if isElement( vehicles[ source ] ) then destroyElement( vehicles[ source ] ) end vehicles[ source ] = createVehicle( model, x + 2, y, z ) warpPedIntoVehicle( source, vehicles[ source ] ) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp)
Chronos Posted May 10, 2013 Author Posted May 10, 2013 the missing part : local vehicles = {} function spawnVehp( model ) local x, y, z = getElementPosition( source ) if isElement( vehicles[ source ] ) then destroyElement( vehicles[ source ] ) end vehicles[ source ] = createVehicle( model, x + 2, y, z ) warpPedIntoVehicle( source, vehicles[ source ] ) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp) in gui or server ??
iPrestege Posted May 10, 2013 Posted May 10, 2013 On the server side just replace the missing part don't add the whole code .
Chronos Posted May 13, 2013 Author Posted May 13, 2013 On the server side just replace the missing part don't add the whole code . don't work
Moderators Citizen Posted May 13, 2013 Moderators Posted May 13, 2013 I think you don't really understand what TAPL was saying ... In your server.lua, you wrote this: local vehicles = {} local x, y, z = getElementPosition(source) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(id, x + 2, y, z) warpPedIntoVehicle(source, vehicles[source]) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp) And it should be like this: local vehicles = {} function spawnVehp( model ) local x, y, z = getElementPosition( source ) if isElement( vehicles[ source ] ) then destroyElement( vehicles[ source ] ) end vehicles[ source ] = createVehicle( model, x + 2, y, z ) warpPedIntoVehicle( source, vehicles[ source ] ) end addEvent("CreVehicePv",true) addEventHandler("CreVehicePv", root, spawnVehp) Next time, try to check errors in the server console, you should get some errors about this script. Best regards, Citizen
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