Gamekiller Posted October 7, 2012 Share Posted October 7, 2012 (edited) Hello, Me and a friend made a little arms dealer job but there is one problem if my friend walk's into the marker the gui dont shows up - Server side marker1 = createMarker (295.239,-37.58,1000.515,"cylinder",1.5,0,0,225,100) marker2 = createMarker (295.48,-80.38,1000.51,"cylinder",1.5,0,0,225,100) marker3 = createMarker (290.28,-109.35,1000.51,"cylinder",1.5,0,0,225,100) setElementFrozen(pedammusf,true) setElementInterior (marker2,4) setElementInterior (marker1,1) setElementInterior (marker3,6) function sellWeapons(pla, cmd) if not getElementData(pla, "sellingArms") then local x, y, z = getElementPosition(pla) local rotz = getPedRotation(pla) local x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 1) local y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 1) local marker = createMarker(x, y, z-1, "cylinder", 1, 255, 128, 0, 170) setElementData(pla, "sellingArms", true) setElementData(marker, "creator", pla) setElementFrozen(pla, true) toggleControl(pla, "forwards", false) toggleControl(pla, "backwards", false) toggleControl(pla, "left", false) toggleControl(pla, "right", false) toggleControl(pla, "enter_exit", false) else for k, v in ipairs(getElementsByType("marker")) do if getElementData(v, "creator") and getElementData(v, "creator") == pla then destroyElement( v ) end removeElementData(pla, "sellingArms") setElementFrozen(pla, false) toggleControl(pla, "forwards", true) toggleControl(pla, "backwards", true) toggleControl(pla, "left", true) toggleControl(pla, "right", true) toggleControl(pla, "enter_exit", true) end end end addCommandHandler("sell", sellWeapons) function (jugador) if (source == marker1) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker2) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker3) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) if source == marker then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) end end end ) addEventHandler ("onMarkerHit",getRootElement(), function give45 () giveWeapon (source,22,51,true) end addEvent("give45",true) addEventHandler("give45",getRootElement(),give45) function givesilenced () giveWeapon (source,23,51,true) end addEvent("givesilenced",true) addEventHandler("givesilenced",getRootElement(),givesilenced) function givedeagle () giveWeapon (source,24,21,true) end addEvent("givedeagle",true) addEventHandler("givedeagle",getRootElement(),givedeagle) function givesh () giveWeapon (source,25,50,true) end addEvent("givesh",true) addEventHandler("givesh",getRootElement(),givesh) function giveso () giveWeapon (source,26,25,true) end addEvent("giveso",true) addEventHandler("giveso",getRootElement(),giveso) function giveSP () giveWeapon (source,27,35,true) end addEvent("giveSP",true) addEventHandler("giveSP",getRootElement(),giveSP) function givetec () giveWeapon (source,32,200,true) end addEvent("givetec",true) addEventHandler("givetec",getRootElement(),givetec) function giveuzi () giveWeapon (source,28,200,true) end addEvent("giveuzi",true) addEventHandler("giveuzi",getRootElement(),giveuzi) function givemp5 () giveWeapon (source,29,120,true) end addEvent("givemp5",true) addEventHandler("givemp5",getRootElement(),givemp5) function givem4 () giveWeapon (source,31,200,true) end addEvent("givem4",true) addEventHandler("givem4",getRootElement(),givem4) function giveak () giveWeapon (source,30,120,true) end addEvent("giveak",true) addEventHandler("giveak",getRootElement(),giveak) function givecs () giveWeapon (source,33,40,true) end addEvent("givecs",true) addEventHandler("givecs",getRootElement(),givecs) function gives () giveWeapon (source,34,40,true) end addEvent("gives",true) addEventHandler("gives",getRootElement(),gives) function giveheat () giveWeapon (source,36,10,true) end addEvent("giveheat",true) addEventHandler("giveheat",getRootElement(),giveheat) function giveflame () giveWeapon (source,37,200,true) end addEvent("giveflame",true) addEventHandler("giveflame",getRootElement(),giveflame) function giverpg () giveWeapon (source,35,20,true) end addEvent("giverpg",true) addEventHandler("giverpg",getRootElement(),giverpg) function givemin () giveWeapon (source,38,500,true) end addEvent("givemin",true) addEventHandler("givemin",getRootElement(),givemin) function givenade () giveWeapon (source,16,20,true) end addEvent("givenade",true) addEventHandler("givenade",getRootElement(),givenade) function givesat () giveWeapon (source,40,1,true) giveWeapon (source,39,10,true) end addEvent("givesat",true) addEventHandler("givesat",getRootElement(),givesat) function givecoc () giveWeapon (source,18,20,true) end addEvent("givecoc",true) addEventHandler("givecoc",getRootElement(),givecoc) function givegas () giveWeapon (source,17,10,true) end addEvent("givegas",true) addEventHandler("givegas",getRootElement(),givegas) function givekatana () giveWeapon (source,8,1,true) end addEvent("givekatana",true) addEventHandler("givekatana",getRootElement(),givekatana) function giveknife () giveWeapon (source,4,1,true) end addEvent("giveknife",true) addEventHandler("giveknife",getRootElement(),giveknife) function givemoto () giveWeapon (source,9,1,true) end addEvent("givemoto",true) addEventHandler("givemoto",getRootElement(),givemoto) function givex () giveWeapon (source,42,1000,true) end addEvent("givex",true) addEventHandler("givex",getRootElement(),givex) function givenv () giveWeapon (source,44,1,true) end addEvent("givenv",true) addEventHandler("givenv",getRootElement(),givenv) function showGUI () guiSetVisible (GUIEditor_Window[1],true) showCursor (true) end addEvent ("showGUI",true) addEventHandler ("showGUI",getRootElement(),showGUI) Edited October 7, 2012 by Guest Link to comment
Musamba Posted October 7, 2012 Share Posted October 7, 2012 addEventHandler ("onMarkerHit",getRootElement(), function (jugador) if (source == marker1) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker2) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) elseif (source == marker3) then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) if source == marker then triggerClientEvent (jugador,"showGUI",getRootElement(),jugador) end end end ) Link to comment
Gamekiller Posted October 7, 2012 Author Share Posted October 7, 2012 That wont work:S I tryed that as last and dint work:S Link to comment
GTX Posted October 7, 2012 Share Posted October 7, 2012 Show us showGui function in client-side script. Link to comment
Gamekiller Posted October 7, 2012 Author Share Posted October 7, 2012 function() guiSetVisible (GUIEditor_Window[1],true) showCursor (true) end ) addEvent ("showGUI",true) addEventHandler ("showGUI",getRootElement(), this is the client Link to comment
TwiX! Posted October 7, 2012 Share Posted October 7, 2012 function showGUI_Client() guiSetVisible (GUIEditor_Window[1],true) showCursor (true) end addEvent ("showGUI",true) addEventHandler ("showGUI",getRootElement(),showGUI_Client) Link to comment
Gamekiller Posted October 7, 2012 Author Share Posted October 7, 2012 Still dont works Am i suppose to change the Marker Showgui 2? Link to comment
TwiX! Posted October 8, 2012 Share Posted October 8, 2012 Server local markers = { ["showGui1"] = createMarker (295.239,-37.58,1000.515,"cylinder",1.5,0,0,225,100), ["showGui2"] = createMarker (295.48,-80.38,1000.51,"cylinder",1.5,0,0,225,100), ["showGui3"] = createMarker (290.28,-109.35,1000.51,"cylinder",1.5,0,0,225,100); }; setElementInterior (markers["showGui1"],1); setElementInterior (markers["showGui2"],4); setElementInterior (markers["showGui3"],6); function onMarketHit(jugador) if (source == markers["showGui1"]) then triggerClientEvent ("showGUI",jugador); elseif (source == markers["showGui2"]) then triggerClientEvent ("showGUI",jugador); elseif (source == markers["showGui3"]) then triggerClientEvent ("showGUI",jugador); if source == marker then triggerClientEvent ("showGUI",jugador); end end end addEventHandler ("onMarkerHit",getRootElement(),onMarketHit) Client: function showGUIbyClient() guiSetVisible (GUIEditor_Window[1],true); showCursor(true); end addEvent ("showGUI",true) addEventHandler ("showGUI",getRootElement(),showGUIbyClient) Link to comment
panos144 Posted March 6, 2013 Share Posted March 6, 2013 (edited) try this Server: function openshop(source,command) selling = createMarker (getElementPosition ( source ) , "Cylinder", 4.0, 255, 0, 0, 255 ) end function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then triggerClientEvent("showGUI",localPlayer) guiSetVisible(windowjob, true) showCursor(true) end end sellingPlayers = { } function getbuyer () sellingPlayers [ markerOwner ] = thePlayerWhoHitTheMarker end addCommandHandler("sell", openshop) function BuyAK47 ( ) givePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 200, false ) end function BuyCOLT ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 22, 200, false ) end function BuySHOTTY ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 25, 200, false ) end function BuyMOLOTOV ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 18, 200, false ) end function BuySAWNOFF ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 26, 200, false ) end function BuyUZI ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 28, 200, false ) end function BuyTEC9 ( ) givePlayerMoney ( source, 1500 ) giveWeapon ( source, 32, 200, false ) end function BuyCBSHOTTY ( ) givePlayerMoney ( source, 3000 ) giveWeapon ( source, 27, 200, false ) end --server addEvent("buyAK", true) addEventHandler("buyAK",root,BuyAK47) addEvent("buyCOLT", true) addEventHandler("buyCOLT",root,BuyCOLT) addEvent("buySHOTTY", true) addEventHandler("buySHOTTY",root,BuySHOTTY) addEvent("buyMolotov", true) addEventHandler("buyMolotov",root,BuyMOLOTOV) addEvent("buySAWNOFF", true) addEventHandler("buySAWNOFF",root,BuySAWNOFF) addEvent("buyUZI", true) addEventHandler("buyUZI",root,BuyUZI) addEvent("buyTEC9", true) addEventHandler("buyTEC9",root,BuyTEC9) addEvent("buyCBSHOTTY", true) addEventHandler("buyCBSHOTTY",root,BuyCBSHOTTY) Client: --Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(170,126,498,328,"Gun Menu",false) GUIEditor_Button[1] = guiCreateButton(16,30,219,44,"AK47 - 2000",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(15,84,222,42,"Colt - 500",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(15,135,223,42,"Molotov - 500",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(14,188,224,40,"Sawn Off Shotgun - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[5] = guiCreateButton(14,240,225,40,"Shotgun - 500",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(258,28,219,44,"Uzi - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(258,82,219,42,"Tec9 - 1500",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(255,135,225,42,"Combat Shotgun - 3000",false,GUIEditor_Window[1]) GUIEditor_Button[9] = guiCreateButton(309,279,178,38,"Close",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , buyAK47, false) addEventHandler("onClientGUIClick", GUIEditor_Button[9] , showGUI, false) function showGUI ( ) --markerhit guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end addEvent("showGUI", true) addEventHandler("showGUI",root,BuyAK47) function closeGUI ( ) --cancle button guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end function buyAK47 () triggerServerEvent("buyAK",localPlayer) end function buyCOLT () triggerServerEvent("buyCOLT",localPlayer) end function buySHOTTY () triggerServerEvent("buySHOTTY",localPlayer) end function buyMolotov () triggerServerEvent("buyMolotov" localPlayer) end function buySAWNOFF () triggerServerEvent("buySAWNOFF",localPlayer) end function buyUZI () triggerServerEvent("buyUZI",localPlayer) end function buyTEC9 () triggerServerEvent("buyTEC9",localPlayer) end function buyCBSHOTTY () triggerServerEvent("buyCBSHOTTY",localPlayer) end you can also find here https://forum.multitheftauto.com/viewtopic.php?f=91&t=46762 Edited March 16, 2013 by Guest Link to comment
PaiN^ Posted March 8, 2013 Share Posted March 8, 2013 The first argument of triggerClientEvent is the event name, And you should use or instead of triggering the same event 4 times, To much triggers cause lag . addEventHandler ( "onMarkerHit", root, function ( jugador ) if ( source == marker1 ) or ( source == marker2 ) or ( source == marker3 ) then triggerClientEvent ("showGUI", localPlayer, jugador) end end ) Link to comment
X-SHADOW Posted March 8, 2013 Share Posted March 8, 2013 (edited) Fixed All Errors ClientSide -- --Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(170,126,498,328,"Gun Menu",false) GUIEditor_Button[1] = guiCreateButton(16,30,219,44,"AK47 - 2000",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(15,84,222,42,"Colt - 500",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(15,135,223,42,"Molotov - 500",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(14,188,224,40,"Sawn Off Shotgun - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[5] = guiCreateButton(14,240,225,40,"Shotgun - 500",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(258,28,219,44,"Uzi - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(258,82,219,42,"Tec9 - 1500",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(255,135,225,42,"Combat Shotgun - 3000",false,GUIEditor_Window[1]) GUIEditor_Button[9] = guiCreateButton(309,279,178,38,"Close",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , buyAK47, false) addEventHandler("onClientGUIClick", GUIEditor_Button[9] , showGUI, false) function showGUI ( ) --markerhit guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end addEvent("showGUI", true) addEventHandler("showGUI",root,BuyAK47) function closeGUI ( ) --cancle button guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end function buyAK47 () triggerServerEvent("buyAK",localPlayer) end function buyCOLT () triggerServerEvent("buyCOLT",localPlayer) end function buySHOTTY () triggerServerEvent("buySHOTTY",localPlayer) end function buyMolotov () triggerServerEvent("buyMolotov" ,localPlayer) end function buySAWNOFF () triggerServerEvent("buySAWNOFF",localPlayer) end function buyUZI () triggerServerEvent("buyUZI",localPlayer) end function buyTEC9 () triggerServerEvent("buyTEC9",localPlayer) end function buyCBSHOTTY () triggerServerEvent("buyCBSHOTTY",localPlayer) end ServerSide--- function openshop(source,command) selling = createMarker (getElementPosition ( source ) , "cylinder", 4.0, 255, 0, 0, 255 ) end function spawnveh ( hitElement, matchingDimension ) if(getElementType( hitElement ) == 'player' ) then triggerClientEvent("showGUI",source) end end sellingPlayers = { } function getbuyer () sellingPlayers [ markerOwner ] = thePlayerWhoHitTheMarker end addCommandHandler("sell", openshop) function BuyAK47 ( ) givePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 200, false ) end function BuyCOLT ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 22, 200, false ) end function BuySHOTTY ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 25, 200, false ) end function BuyMOLOTOV ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 18, 200, false ) end function BuySAWNOFF ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 26, 200, false ) end function BuyUZI ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 28, 200, false ) end function BuyTEC9 ( ) givePlayerMoney ( source, 1500 ) giveWeapon ( source, 32, 200, false ) end function BuyCBSHOTTY ( ) givePlayerMoney ( source, 3000 ) giveWeapon ( source, 27, 200, false ) end --server addEvent("buyAK", true) addEventHandler("buyAK",root,BuyAK47) addEvent("buyCOLT", true) addEventHandler("buyCOLT",root,BuyCOLT) addEvent("buySHOTTY", true) addEventHandler("buySHOTTY",root,BuySHOTTY) addEvent("buyMolotov", true) addEventHandler("buyMolotov",root,BuyMOLOTOV) addEvent("buySAWNOFF", true) addEventHandler("buySAWNOFF",root,BuySAWNOFF) addEvent("buyUZI", true) addEventHandler("buyUZI",root,BuyUZI) addEvent("buyTEC9", true) addEventHandler("buyTEC9",root,BuyTEC9) addEvent("buyCBSHOTTY", true) addEventHandler("buyCBSHOTTY",root,BuyCBSHOTTY) Thank's Fhode Edited March 8, 2013 by Guest Link to comment
iPrestege Posted March 8, 2013 Share Posted March 8, 2013 source it's right ( = but Cylinder must be cylinder Link to comment
panos144 Posted April 28, 2013 Share Posted April 28, 2013 if and this doesn't work try: Server function openshop(source,command) selling = createMarker (getElementPosition ( source ) , "cylinder", 4.0, 255, 0, 0, 255 ) end function spawnveh ( hitElement, matchingDimension ) if(getElementType( hitElement ) == 'player' ) then triggerClientEvent("showGUI",source) end end sellingPlayers = { } function getbuyer () sellingPlayers [ markerOwner ] = thePlayerWhoHitTheMarker end addCommandHandler("sell", openshop) function BuyAK47 ( ) givePlayerMoney ( source, 2000 ) giveWeapon ( source, 30, 200, false ) end function BuyCOLT ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 22, 200, false ) end function BuySHOTTY ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 25, 200, false ) end function BuyMOLOTOV ( ) givePlayerMoney ( source, 500 ) giveWeapon ( source, 18, 200, false ) end function BuySAWNOFF ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 26, 200, false ) end function BuyUZI ( ) givePlayerMoney ( source, 1000 ) giveWeapon ( source, 28, 200, false ) end function BuyTEC9 ( ) givePlayerMoney ( source, 1500 ) giveWeapon ( source, 32, 200, false ) end function BuyCBSHOTTY ( ) givePlayerMoney ( source, 3000 ) giveWeapon ( source, 27, 200, false ) end --server addEvent("buyAK", true) addEventHandler("buyAK",root,BuyAK47) addEvent("buyCOLT", true) addEventHandler("buyCOLT",root,BuyCOLT) addEvent("buySHOTTY", true) addEventHandler("buySHOTTY",root,BuySHOTTY) addEvent("buyMolotov", true) addEventHandler("buyMolotov",root,BuyMOLOTOV) addEvent("buySAWNOFF", true) addEventHandler("buySAWNOFF",root,BuySAWNOFF) addEvent("buyUZI", true) addEventHandler("buyUZI",root,BuyUZI) addEvent("buyTEC9", true) addEventHandler("buyTEC9",root,BuyTEC9) addEvent("buyCBSHOTTY", true) addEventHandler("buyCBSHOTTY",root,BuyCBSHOTTY) Client --Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(170,126,498,328,"Gun Menu",false) guiWindowSetSizable(GUIEditor_Window[1], false) guiSetVisible(GUIEditor_Window[1], false) GUIEditor_Button[1] = guiCreateButton(16,30,219,44,"AK47 - 2000",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(15,84,222,42,"Colt - 500",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(15,135,223,42,"Molotov - 500",false,GUIEditor_Window[1]) GUIEditor_Button[4] = guiCreateButton(14,188,224,40,"Sawn Off Shotgun - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[5] = guiCreateButton(14,240,225,40,"Shotgun - 500",false,GUIEditor_Window[1]) GUIEditor_Button[6] = guiCreateButton(258,28,219,44,"Uzi - 1000",false,GUIEditor_Window[1]) GUIEditor_Button[7] = guiCreateButton(258,82,219,42,"Tec9 - 1500",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(255,135,225,42,"Combat Shotgun - 3000",false,GUIEditor_Window[1]) GUIEditor_Button[9] = guiCreateButton(309,279,178,38,"Close",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , buyAK47, false) addEventHandler("onClientGUIClick", GUIEditor_Button[9] , showGUI, false) function showGUI ( ) --markerhit guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end addEvent("showGUI", true) addEventHandler("showGUI",root,BuyAK47) function hidegui() guiSetVisible(GUIEditor_Window[1], false) showCursor ( false ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[9], hidegui, false ) function buyAK47 () triggerServerEvent("buyAK",localPlayer) end function buyCOLT () triggerServerEvent("buyCOLT",localPlayer) end function buySHOTTY () triggerServerEvent("buySHOTTY",localPlayer) end function buyMolotov () triggerServerEvent("buyMolotov" ,localPlayer) end function buySAWNOFF () triggerServerEvent("buySAWNOFF",localPlayer) end function buyUZI () triggerServerEvent("buyUZI",localPlayer) end function buyTEC9 () triggerServerEvent("buyTEC9",localPlayer) end function buyCBSHOTTY () triggerServerEvent("buyCBSHOTTY",localPlayer) end i hope to help. 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