top sniper Posted March 10, 2012 Share Posted March 10, 2012 i have a problem with onhitmarker function server side : marker1 = createMarker ( 131, 68, 2 ) addEventHandler("onMarkerHit",root, function () if ( source == marker1 ) then triggerClientEvent("marker11",getRootElement()) end end ) client side : addEvent("marker11",true) addEventHandler("marker11",getLocalPlayer, function() guiSetVisible (shopWindow, true) end ) Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 Server-side: local marker1 = createMarker ( 131, 68, 2 ) addEventHandler ( 'onMarkerHit', root, function ( player, marker ) if ( isElementWithinMarker ( player, marker1 ) ) then triggerClientEvent ( 'onMarker1Hit', localPlayer ) end end ) Client-side: addEvent ( 'onMarker1Hit', true ) addEventHandler ( 'onMarker1Hit', root, function ( ) guiSetVisible ( shopWindow, true ) end ) If not work, please explain what. Link to comment
top sniper Posted March 10, 2012 Author Share Posted March 10, 2012 Server-side: local marker1 = createMarker ( 131, 68, 2 ) addEventHandler ( 'onMarkerHit', root, function ( player, marker ) if ( isElementWithinMarker ( player, marker1 ) ) then triggerClientEvent ( 'onMarker1Hit', localPlayer ) end end ) Client-side: addEvent ( 'onMarker1Hit', true ) addEventHandler ( 'onMarker1Hit', root, function ( ) guiSetVisible ( shopWindow, true ) end ) If not work, please explain what. its not working Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 What is not working? You get any error? Show meta.xml too. Link to comment
top sniper Posted March 10, 2012 Author Share Posted March 10, 2012 What is not working?You get any error? Show meta.xml too. I did not get any error .. and no error with meta . and this is the full code root = getRootElement() localPlayer = getLocalPlayer() myBlip = createBlip ( 131, 69, 2,6 ) shopWindow = guiCreateWindow(170,50,530,510,"shop panel by MOJRM-511 edited bt TopSniper ",false) guiSetVisible (shopWindow, false) guiWindowSetSizable(shopWindow,false) guiWindowSetMovable(shopWindow,true) tabPanel = guiCreateTabPanel(11,23,599,499,false,shopWindow) addEvent ( 'onMarker1Hit', true ) addEventHandler ( 'onMarker1Hit', root, function ( ) guiSetVisible (shopWindow, true) end ) ------------------------------------------------------------------------------------------------------- tab2 = guiCreateTab("buy weapons",tabPanel) --------- ????? 1 -line 1 ------------------------------------------------------------------------------------ guiCreateStaticImage( 10,10,90,75, "weapon/24.png", false,tab2 ) weapButton_1 = guiCreateButton(10,80,90,30,"$150 deagle",false,tab2) guiCreateStaticImage( 110,10,90,75, "weapon/31.png", false,tab2 ) weapButton_2 = guiCreateButton(110,80,90,30,"$250 M4",false,tab2) --------------------------------- guiCreateStaticImage( 210,10,90,75, "weapon/16.png", false,tab2 ) weapButton_3 = guiCreateButton(210,80,90,30,"$1500 Grenade ",false,tab2) --------------------------------- guiCreateStaticImage( 310,10,90,75, "weapon/30.png", false,tab2 ) weapButton_4 = guiCreateButton(310,80,90,30,"$200 AK-47",false,tab2) -------------------------------- guiCreateStaticImage( 410,10,90,75, "weapon/29.png", false,tab2 ) weapButton_5 = guiCreateButton(410,80,90,30,"$150 mp5",false,tab2) -------------------------2 ?????----------------------------------------------------------------------------------------------------------- guiCreateStaticImage( 10,110,90,80, "weapon/32.png", false,tab2 ) weapButton_6 = guiCreateButton(10,190,90,30,"$450 TEC-9",false,tab2 ) guiCreateStaticImage( 110,110,90,80, "weapon/34.png", false,tab2 ) weapButton_7 = guiCreateButton(110,190,90,30,"$250 Sniper",false,tab2) guiCreateStaticImage( 210,110,90,80, "weapon/28.png", false,tab2 ) weapButton_8 = guiCreateButton(210,190,90,30,"$400 Uzi",false,tab2) guiCreateStaticImage( 310,110,90,80, "weapon/46.png", false,tab2 ) weapButton_9 = guiCreateButton(310,190,90,30,"$250 Parachute ",false,tab2) guiCreateStaticImage( 410,110,90,80, "weapon/25.png", false,tab2 ) weapButton_10 = guiCreateButton(410,190,90,30,"$200 ShotGun",false,tab2) -------------------------------------------------------------------------- line 3 guiCreateStaticImage( 10,220,90,80, "weapon/26.png", false,tab2 ) weapButton_11 = guiCreateButton(10,300,90,30,"$700 Sawn-Off",false,tab2 ) guiCreateStaticImage( 110,220,90,80, "weapon/27.png", false,tab2 ) weapButton_12 = guiCreateButton(110,300,90,30,"$650 Combat",false,tab2 ) guiCreateStaticImage( 210,220,90,80, "weapon/4.png", false,tab2 ) weapButton_13 = guiCreateButton(210,300,90,30,"$500 Knif",false,tab2 ) guiCreateStaticImage( 310,220,90,80, "weapon/22.png", false,tab2 ) weapButton_14 = guiCreateButton(310,300,90,30,"$200 Pistol",false,tab2 ) guiCreateStaticImage( 410,220,90,80, "weapon/9.png", false,tab2 ) weapButton_15 = guiCreateButton(410,300,90,30,"$400 Chainsaw",false,tab2 ) --------------------------------------------------------------------------------------line 4 guiCreateStaticImage( 10,330,90,80, "weapon/17.png", false,tab2 ) weapButton_16 = guiCreateButton(10,410,90,30,"$1200 Tear Gas",false,tab2 ) guiCreateStaticImage( 110,330,90,80, "weapon/42.png", false,tab2 ) weapButton_17 = guiCreateButton(110,410,90,30,"$400 Fire Extinguisher",false,tab2 ) guiCreateStaticImage( 210,330,90,80, "weapon/23.png", false,tab2 ) weapButton_18 = guiCreateButton(210,410,90,30,"$100 Silenced Pistol",false,tab2 ) guiCreateStaticImage( 310,330,90,80, "weapon/39.png", false,tab2 ) weapButton_19 = guiCreateButton(310,410,90,30,"$1800 Satchel Charges",false,tab2 ) guiCreateStaticImage( 410,330,90,80, "weapon/38.png", false,tab2 ) weapButton_20 = guiCreateButton(410,410,90,30,"$3000 minigun",false,tab2 ) --------------------------------------الشوب-------------------------------------------------3tab tab3 = guiCreateTab("shop",tabPanel) --------------------------------------------------------------------------------------------------------- -------------------------------- ----------------------------------------------------------------------------------------------------------- bindKey ( "F2" , "down" , function() if ( guiGetVisible ( shopWindow ) == true ) then guiSetVisible ( shopWindow ,false ) showCursor (false ) guiSetInputEnabled(false) elseif ( guiGetVisible ( shopWindow ) == false ) then guiSetVisible ( shopWindow ,true ) showCursor (false ) guiSetInputEnabled(true) playSound("MOJRM-511.mp3") end end ) ------------------------------------------------------------------------------------------------------ -------------------------------------------------------------------بدايه ربط الازرار بالسيرفر server---------- addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_1 ) then triggerServerEvent("gived",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_2 ) then triggerServerEvent("givem4",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_3 ) then triggerServerEvent("givegrn",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_4 ) then triggerServerEvent("givemk",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_5 ) then triggerServerEvent("givemp5",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_6 ) then triggerServerEvent("TEC-9",getLocalPlayer()) end end ) Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 (edited) Hmm why you need trigger server event? Use onClientMarkerHit. local marker1 = createMarker ( 131, 68, 2 ) addEventHandler ( 'onClientMarkerHit', root, function ( ) if ( source == marker1 ) then guiSetVisible ( shopWindow, true ) end end ) Edited March 10, 2012 by Guest Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 (edited) Sorry for double post myBlip = createBlip ( 131, 69, 2,6 ) shopWindow = guiCreateWindow(170,50,530,510,"shop panel by MOJRM-511 edited bt TopSniper ",false) guiSetVisible (shopWindow, false) guiWindowSetSizable(shopWindow,false) guiWindowSetMovable(shopWindow,true) tabPanel = guiCreateTabPanel(11,23,599,499,false,shopWindow) local marker1 = createMarker ( 131, 68, 2 ) addEventHandler ( 'onClientMarker1Hit', root, function ( ) if ( source == marker1 ) then guiSetVisible (shopWindow, true) end end ) ------------------------------------------------------------------------------------------------------- tab2 = guiCreateTab("buy weapons",tabPanel) --------- ????? 1 -line 1 ------------------------------------------------------------------------------------ guiCreateStaticImage( 10,10,90,75, "weapon/24.png", false,tab2 ) weapButton_1 = guiCreateButton(10,80,90,30,"$150 deagle",false,tab2) guiCreateStaticImage( 110,10,90,75, "weapon/31.png", false,tab2 ) weapButton_2 = guiCreateButton(110,80,90,30,"$250 M4",false,tab2) --------------------------------- guiCreateStaticImage( 210,10,90,75, "weapon/16.png", false,tab2 ) weapButton_3 = guiCreateButton(210,80,90,30,"$1500 Grenade ",false,tab2) --------------------------------- guiCreateStaticImage( 310,10,90,75, "weapon/30.png", false,tab2 ) weapButton_4 = guiCreateButton(310,80,90,30,"$200 AK-47",false,tab2) -------------------------------- guiCreateStaticImage( 410,10,90,75, "weapon/29.png", false,tab2 ) weapButton_5 = guiCreateButton(410,80,90,30,"$150 mp5",false,tab2) -------------------------2 ?????----------------------------------------------------------------------------------------------------------- guiCreateStaticImage( 10,110,90,80, "weapon/32.png", false,tab2 ) weapButton_6 = guiCreateButton(10,190,90,30,"$450 TEC-9",false,tab2 ) guiCreateStaticImage( 110,110,90,80, "weapon/34.png", false,tab2 ) weapButton_7 = guiCreateButton(110,190,90,30,"$250 Sniper",false,tab2) guiCreateStaticImage( 210,110,90,80, "weapon/28.png", false,tab2 ) weapButton_8 = guiCreateButton(210,190,90,30,"$400 Uzi",false,tab2) guiCreateStaticImage( 310,110,90,80, "weapon/46.png", false,tab2 ) weapButton_9 = guiCreateButton(310,190,90,30,"$250 Parachute ",false,tab2) guiCreateStaticImage( 410,110,90,80, "weapon/25.png", false,tab2 ) weapButton_10 = guiCreateButton(410,190,90,30,"$200 ShotGun",false,tab2) -------------------------------------------------------------------------- line 3 guiCreateStaticImage( 10,220,90,80, "weapon/26.png", false,tab2 ) weapButton_11 = guiCreateButton(10,300,90,30,"$700 Sawn-Off",false,tab2 ) guiCreateStaticImage( 110,220,90,80, "weapon/27.png", false,tab2 ) weapButton_12 = guiCreateButton(110,300,90,30,"$650 Combat",false,tab2 ) guiCreateStaticImage( 210,220,90,80, "weapon/4.png", false,tab2 ) weapButton_13 = guiCreateButton(210,300,90,30,"$500 Knif",false,tab2 ) guiCreateStaticImage( 310,220,90,80, "weapon/22.png", false,tab2 ) weapButton_14 = guiCreateButton(310,300,90,30,"$200 Pistol",false,tab2 ) guiCreateStaticImage( 410,220,90,80, "weapon/9.png", false,tab2 ) weapButton_15 = guiCreateButton(410,300,90,30,"$400 Chainsaw",false,tab2 ) --------------------------------------------------------------------------------------line 4 guiCreateStaticImage( 10,330,90,80, "weapon/17.png", false,tab2 ) weapButton_16 = guiCreateButton(10,410,90,30,"$1200 Tear Gas",false,tab2 ) guiCreateStaticImage( 110,330,90,80, "weapon/42.png", false,tab2 ) weapButton_17 = guiCreateButton(110,410,90,30,"$400 Fire Extinguisher",false,tab2 ) guiCreateStaticImage( 210,330,90,80, "weapon/23.png", false,tab2 ) weapButton_18 = guiCreateButton(210,410,90,30,"$100 Silenced Pistol",false,tab2 ) guiCreateStaticImage( 310,330,90,80, "weapon/39.png", false,tab2 ) weapButton_19 = guiCreateButton(310,410,90,30,"$1800 Satchel Charges",false,tab2 ) guiCreateStaticImage( 410,330,90,80, "weapon/38.png", false,tab2 ) weapButton_20 = guiCreateButton(410,410,90,30,"$3000 minigun",false,tab2 ) --------------------------------------الشوب-------------------------------------------------3tab tab3 = guiCreateTab("shop",tabPanel) --------------------------------------------------------------------------------------------------------- -------------------------------- ----------------------------------------------------------------------------------------------------------- bindKey ( 'F2', 'down', function ( ) guiSetVisible ( shopWindow, not guiGetVisible ( shopWindow ) ) showCursor ( not isCursorShowing ( ) ) guiSetInputEnabled ( not guiGetInputEnabled ( ) ) end ) ----------------------------------------------------------------------------------------------------- -------------------------------------------------------------------بدايه ربط الازرار بالسيرفر server---------- addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_1 ) then triggerServerEvent("gived",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_2 ) then triggerServerEvent("givem4",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_3 ) then triggerServerEvent("givegrn",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_4 ) then triggerServerEvent("givemk",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_5 ) then triggerServerEvent("givemp5",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_6 ) then triggerServerEvent("TEC-9",getLocalPlayer()) end end ) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == weapButton_7 ) then triggerServerEvent("givesnip",getLocalPlayer()) end end Edited March 10, 2012 by Guest Link to comment
top sniper Posted March 10, 2012 Author Share Posted March 10, 2012 Hmm why you need trigger server event? Use onClientMarkerHit. local marker1 = createMarker ( 131, 68, 2 ) addEventHandler ( 'onClientMarkerHit', root, function ( player, marker ) if ( source == marker1 ) then guiSetVisible ( shopWindow, true ) end end ) now it works thanks for helping me Link to comment
top sniper Posted March 10, 2012 Author Share Posted March 10, 2012 i toke this code from mtasa wiki function setFriendlyFireOn ( ) -- For each team, for index, theTeam in ipairs ( getElementsByType("team") ) do -- if friendly fire is off, if ( getTeamFriendlyFire ( theTeam ) == false ) then -- switch it on. setTeamFriendlyFire ( theTeam, true ) end end end -- Add console command 'setFF' addCommandHandler ( "setFF", setFriendlyFireOn ) but it didn't work Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 And next time tabulate your code and put in [lua] tags. 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