omarhossam Posted July 29, 2013 Share Posted July 29, 2013 i am creating my first script and i got a problem i scripted a gui appears when i hit the marker and its appear and scripted the exit button and it hide the gui but when i hit the marker again it doesn't appear again unless i restart the resource .....Help please Link to comment
Lloyd Logan Posted July 29, 2013 Share Posted July 29, 2013 i am creating my first script and i got a problem i scripted a gui appears when i hit the marker and its appear and scripted the exit button and it hide the gui but when i hit the marker again it doesn't appear again unless i restart the resource .....Help please Could you either, post your code here, or PM it to me! Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 function gui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end function rent (button,state) if button == "left" and state == "up" then takeCash ( thePlayer, amount ) takePlayerMoney ( thePlayer, 100 ) end end local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) gui() if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end Link to comment
Cruze Posted July 29, 2013 Share Posted July 29, 2013 function gui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) guiSetVisible ( gui, false) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end function rent (button,state) if button == "left" and state == "up" then takeCash ( thePlayer, amount ) takePlayerMoney ( thePlayer, 100 ) end end local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) gui() if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end Should work now (I added guiSetVisible in line 5) Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 it doesnt.... still appears one time Link to comment
Cruze Posted July 29, 2013 Share Posted July 29, 2013 local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) function gui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) guiSetVisible ( gui, false) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end function rent (button,state) if button == "left" and state == "up" then takeCash ( thePlayer, amount ) takePlayerMoney ( thePlayer, 100 ) end end addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) gui() if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end Try this.. Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 still appears one time........ -.- .... BTW you know how to mkae the ped dont die? Link to comment
Cruze Posted July 29, 2013 Share Posted July 29, 2013 (edited) hmm maybe... addEventHandler ("onClientPedDamage",thepedname, function () cancelEvent() end Edited July 29, 2013 by Guest Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 DONT WORK TOO.....!!! Are you sure that you can script? Link to comment
Cruze Posted July 29, 2013 Share Posted July 29, 2013 DONT WORK TOO.....!!! Are you sure that you can script? ROFL forgot this " in eventhandler also create a ped ._. Link to comment
iPrestege Posted July 29, 2013 Share Posted July 29, 2013 addEventHandler('onClientPedDamage',ped,cancelEvent) Link to comment
DNL291 Posted July 29, 2013 Share Posted July 29, 2013 still appears one time........ Try this: function gui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiSetVisible(gui, false) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end function rent (button,state) if button == "left" and state == "up" then takeCash ( thePlayer, amount ) takePlayerMoney ( thePlayer, 100 ) end end local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 still appears one time........ Try this: function gui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiSetVisible(gui, false) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end function rent (button,state) if button == "left" and state == "up" then takeCash ( thePlayer, amount ) takePlayerMoney ( thePlayer, 100 ) end end local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end this time the cursor appears only... Link to comment
DNL291 Posted July 29, 2013 Share Posted July 29, 2013 function createGui () gui = guiCreateWindow( 300, 100, 265, 500, "Bike Rent Shop", false) guiSetInputEnabled ( false ) guiSetVisible(gui, false) guiWindowSetMovable( gui, false ) guiWindowSetSizable( gui, false ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, false, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn1 = guiCreateButton( 149, 430, 99, 45, "Leave", false, gui ) guiSetFont( btn1, "default-bold-small" ) List = guiCreateGridList ( 0.04, 0.05, 0.95, 0.75, true, gui ) column = guiGridListAddColumn( List, "Bikes", 0.85 ) btn2 = guiCreateButton(18,430,99,45,"Rent 50$",false, gui) guiSetProperty( btn1, "HoverTextColour", "FFFF0000" ) guiSetProperty( btn2, "HoverTextColour", "FFFFFF00" ) row = guiGridListAddRow (List) guiGridListSetItemText ( List, row, column, "Mountain Bike", false, false ) row2 = guiGridListAddRow (List) guiGridListSetItemText (List, row2, column, "BMX", false, false ) row3 = guiGridListAddRow (List) guiGridListSetItemText (List, row3, column, "Bike", false, false ) addEventHandler("onClientGUIClick", btn1, close, false) addEventHandler("onClientGUIClick", btn2, rent, false) end addEventHandler("onClientResourceStart", resourceRoot, createGui) function rent (button,state) if button == "left" and state == "up" then takeCash ( amount ) takePlayerMoney ( 100 ) end end local marker = createMarker (1220, -1415.5,12, "cylinder", 1.5, 0, 0, 225, 225) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible( gui, true) showCursor( true) outputChatBox( "Bike shop : Welcome to the Rent Shop", 255, 255, 5) end end ) function close(button,state) if button == "left" and state == "up" then guiSetVisible ( lol, false) guiSetInputEnabled(false) guiSetVisible(gui, false) showCursor(false) end end Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 wooooooooooooooow...... ty Bro finally its worked :D:D Btw can you tell me the code that make the ped dont die ???? ty, again Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 and what was the wrong?? with mine? Link to comment
denny199 Posted July 29, 2013 Share Posted July 29, 2013 https://wiki.multitheftauto.com/wiki/OnClientPedDamage function cancelPedDamage ( attacker ) cancelEvent() -- cancel any damage done to peds end addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) (© wiki ) edit: If you only want it for one ped use: addEventHandler ( "onClientPedDamage", getRootElement(), function ( attacker ) if source == pedElement then cancelEvent() end end) Link to comment
omarhossam Posted July 29, 2013 Author Share Posted July 29, 2013 how to spawn the bikes when i hit rent button and take 50 $ from the player money ... the last thing please Link to comment
DNL291 Posted July 29, 2013 Share Posted July 29, 2013 Client: addEventHandler "onClientGUIClick" guiGridListGetSelectedItem guiGridListGetItemText triggerServerEvent server: addEvent addEventHandler createVehicle warpPedIntoVehicle takePlayerMoney Link to comment
xXMADEXx Posted July 29, 2013 Share Posted July 29, 2013 use 'takePlayerMoney' on server side. Link to comment
Cruze Posted July 29, 2013 Share Posted July 29, 2013 use 'takePlayerMoney' on server side. rofl what you see then?! Link to comment
xXMADEXx Posted July 29, 2013 Share Posted July 29, 2013 use 'takePlayerMoney' on server side. rofl what you see then?! What? 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