Deep thinker Posted October 16, 2016 Share Posted October 16, 2016 every time the script be like this i can see the spawner but i can't control the buttons local marker = createMarker ( 1615.48865,-1506.98303,13.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(0.5399,0.6794,0.4063,0.456,"Drug Delivery System ",true) -- Add this under create window function : guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(317,345,68,40,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(245,346,68,39,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(18,33,438,102,"Deliver the Car to the blip on the radar in LV .\nIf there is any bugs report it to the owners.",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) so after adding this part i can't see the spawner and it's fully on the client side local marker = createMarker ( 1615.48865,-1506.98303,13.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(0.5399,0.6794,0.4063,0.456,"Drug Delivery System ",true) -- Add this under create window function : guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(317,345,68,40,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(245,346,68,39,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(18,33,438,102,"Deliver the Car to the blip on the radar in LV .\nIf there is any bugs report it to the owners.",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) elseif source == 'onClientGUIClick' then if (source == GUIEditor_Button[2]) then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) addEventHandler("onClientGUIClick",marker,ToggleDDMenu) Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 You are using the event 'onClientGUIClick' with wrong way marker is not a gui element anyway you should make a new function with the 'onClientGUIClick' and check every button is the button you want to be clicked and do what ever you want . Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 I did i have created the function under the GUI creation like this : local marker = createMarker ( 1615.48865,-1506.98303,12.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(0.5399,0.6794,0.4063,0.456,"Drug Delivery System ",true) -- Add this under create window function : guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(317,345,68,40,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(245,346,68,39,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(18,33,438,102,"Deliver the Car to the blip on the radar in LV .\nIf there is any bugs report it to the owners.",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) function buttons elseif source == 'onClientGUIClick' then if (source == GUIEditor_Button[2]) then guiSetVisible ( GUIEditor_Window[1],false ) end please answer as soon as possible Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 local marker = createMarker ( 1615.48865,-1506.98303,12.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(0.5399,0.6794,0.4063,0.456,"Drug Delivery System ",true) guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(317,345,68,40,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(245,346,68,39,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(18,33,438,102,"Deliver the Car to the blip on the radar in LV .\nIf there is any bugs report it to the owners.",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) addEventHandler ('onClientGUIClick',GUIEditor_Button[2], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end,false ) Try this. Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 it worked perfectly ,thank you but now i wanna create a vehicle and warp the player into this vehicle and when he is in a vehicle he see a blip and if he left the vehicle ,the vehicle get destroied. Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 So make a trigger to server and create vehicle for the player using tables use these functions : -- addEventHandler ('onClientGUIClick') -- For button you want the player to get vehicle for triggerServerEvent -- trigger after clicking the button to the server side for create vehicle and blip addEvent -- add the event server side and make sure that it's true addEventHandler -- add the event handler in the server side after making a trigger table -- table createVehicle -- create vehicle for player using tables createBlip -- create blip for player using tables addEventHandler ( 'onPlayerVehicleExit' ) -- on the player exit do your destroy isElement -- check the vehicle and the blip destroyElement -- to destroy the vehicle and the blip addEventHandler ( 'onPlayerQuit' ) -- if the vehicle and the blip still exists destroy it Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 thank you i will be working on it but i want to know how to tigger it ,can you tell me? Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 (edited) Do it like this : -- On Client Side addEventHandler ( 'onClientGUIClick',gButton, function ( ) triggerServerEvent( 'MyEvent',localPlayer ) end,false ) -- On Server Side addEvent ( 'MyEvent',true ) addEventHandler ( 'MyEvent',root, function ( ) -- To Do end ) Edited October 17, 2016 by FaHaD Mistake Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 i did like this but i want to warp the player in the vehicle that i have created can you add to this part -- server side addEvent("MyEvent",true) addEventHandler("MyEvent",root, function ( ) local newVehicle = createVehicle ( 413, 1603.34717, -1459.95898, 13.68424, 0, 0, rotZ ) warpPedIntoVehicle ( localPlayer, newVehicle ) local myBlip = createBlip( 1019.93677, 2373.41040, 10.93885, 51, 0, 0, 0, 255, myPlayer ) local marker = createMarker ( 1019.93677, 2373.41040, 10.93885,"cylinder",2,0,255,0,255 ) end --client side local marker = createMarker ( 1615.48865,-1506.98303,13.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(0.3663,0.2905,0.2821,0.4502,"Drug Delivery Request",true) guiSetAlpha(GUIEditor_Window[1],1) guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(176,338,96,26,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(41,338,96,26,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Image[1] = guiCreateStaticImage(0.3811,0.3866,0.2257,0.1944,"images/target.png",true) GUIEditor_Memo[1] = guiCreateMemo(15,24,294,45,"Follow the blue line on this map or the car blip in radar you will be rewarded with 10000$ .",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) elseif eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Image[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Image[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) addEventHandler ('onClientGUIClick',GUIEditor_Button[2], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end,false ) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) addEventHandler ('onClientGUIClick',GUIEditor_Button[2], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end,false ) addEventHandler ('onClientGUIClick',GUIEditor_Button[1], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) triggerServerEvent ("MyEvent",localPlayer) end,false ) when i press accept nothing happens and it just hides the GUI, wait i have fixed the accept button bug expect warping into the vehicle Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 Try this on client : -- Client local marker = createMarker ( 1615.48865,-1506.98303,13.20866,"cylinder",2,255,0,0,255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(0.3663,0.2905,0.2821,0.4502,"Drug Delivery Request",true) guiSetAlpha(GUIEditor_Window[1],1) guiSetVisible ( GUIEditor_Window[1],false ) GUIEditor_Button[1] = guiCreateButton(176,338,96,26,"Accept",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(41,338,96,26,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Image[1] = guiCreateStaticImage(0.3811,0.3866,0.2257,0.1944,"images/target.png",true) GUIEditor_Memo[1] = guiCreateMemo(15,24,294,45,"Follow the blue line on this map or the car blip in radar you will be rewarded with 10000$ .",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) function ToggleDDMenu ( hit ) if ( hit and hit == localPlayer ) then if eventName == 'onClientMarkerHit' then guiSetVisible ( GUIEditor_Window[1],true ) showCursor ( true ) elseif eventName == 'onClientMarkerLeave' then guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end end end addEventHandler("onClientMarkerHit",marker,ToggleDDMenu) addEventHandler("onClientMarkerLeave",marker,ToggleDDMenu) addEventHandler ('onClientGUIClick',GUIEditor_Button[2], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) end,false ) addEventHandler ('onClientGUIClick',GUIEditor_Button[1], function ( ) guiSetVisible ( GUIEditor_Window[1],false ) showCursor ( false ) triggerServerEvent ("MyEvent",localPlayer) end,false ) On server : local newVehicle = { } local myBlip = { } local marker = { } addEvent('MyEvent',true) addEventHandler('MyEvent',root, function ( ) if newVehicle [ source ] and isElement ( newVehicle [ source ] ) then return false end newVehicle [ source ] = createVehicle ( 413,1603.34717,-1459.95898,13.68424 ) warpPedIntoVehicle ( source,newVehicle [ source ] ) myBlip [ source ] = createBlip( 1019.93677,2373.41040,10.93885,51,2,255,0,0,255,0 ) setElementVisibleTo( myBlip [ source ],root,false ) setElementVisibleTo( myBlip [ source ],source,true ) marker [ source ] = createMarker ( 1019.93677,2373.41040,10.93885,'cylinder',2,0,255,0,255,source ) end ) And please complete your code on your own open the wiki and learn how to destroyElement and how when the player leave the vehicle or quit the server or exploded i'm not going to make a script for you and use /debugscript 3 to found errors warnings. Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 it worked but i wanted to destroy the vehicle on the marker hit and if he left the vehicle before reaching also destroing the other elements ,marker,blip and give him 10000$ check this local newVehicle = { } local myBlip = { } local marker = { } addEvent('MyEvent',true) addEventHandler('MyEvent',root, function ( ) if newVehicle [ source ] and isElement ( newVehicle [ source ] ) then return false end newVehicle [ source ] = createVehicle ( 413,1603.34717,-1459.95898,13.68424 ) warpPedIntoVehicle ( source,newVehicle [ source ] ) myBlip [ source ] = createBlip( 1019.93677,2373.41040,10.93885,51,2,255,0,0,255,0 ) setElementVisibleTo( myBlip [ source ],root,false ) setElementVisibleTo( myBlip [ source ],source,true ) marker [ source ] = createMarker ( 1019.93677,2373.41040,9.93885,'cylinder',2,0,255,0,255,source ) end ) function destory local checkedPlayer = getPlayerFromName ( checkedPlayerName ) if ( checkedPlayer ) then if isPedInVehicle ( checkedPlayer ) then getVehicleID ( theVehicle ) else destroyElement( newVehicle [ source ] ) outPutChatBox("You have been suspended for leaving the Pony"255,0,0) end addEventHandler("onPlayerVehicleExit", getRootElement(),destroy) addEventHandler("onMarkerHit",root, function() if isElement(newVehicle [ source ]) then destroyElement(newVehicle [ source ]) if isElement(myBlip [ source ]) then destroyElement(myBlip [ source ]) if isElement(marker [ source ]) then destroyElement(marker [ source ]) givePlayerMoney ( thePlayer, 10000 ) end ) after adding this i can't create the vehicle or do anything from the new functions i know that i have asked you a lot about that script but this is my first script of all i have read wiki tons of times ,you have taught me new things i have never knew but thanks for what you have done ,also this is the last part of the script ,i swear i tried to script it on my own ,but please forgive me because i asked a lot Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 -- Server Side local newVehicle = { } local myBlip = { } local marker = { } addEvent('MyEvent',true) addEventHandler('MyEvent',root, function ( ) if newVehicle [ source ] and isElement ( newVehicle [ source ] ) then return false end newVehicle [ source ] = createVehicle ( 413,1603.34717,-1459.95898,13.68424 ) warpPedIntoVehicle ( source,newVehicle [ source ] ) myBlip [ source ] = createBlip( 1019.93677,2373.41040,10.93885,51,2,255,0,0,255,0 ) setElementVisibleTo( myBlip [ source ],root,false ) setElementVisibleTo( myBlip [ source ],source,true ) marker [ source ] = createMarker ( 1019.93677,2373.41040,9.93885,'cylinder',2,0,255,0,255,source ) end ) addEventHandler ( 'onMarkerHit',resourceRoot, function ( hit ) if ( hit and getElementType ( hit ) == 'vehicle' ) then local player = getVehicleController ( hit ) if ( source == marker [ player ] )then if isElement ( newVehicle [ player ] ) then if ( hit == newVehicle [ player ] ) then destroyElement ( newVehicle [ player ] ) destroyElement ( myBlip [ player ] ) destroyElement ( marker [ player ] ) newVehicle [ player ] = nil myBlip [ player ] = nil marker [ player ] = nil givePlayerMoney ( player,10000 ) end end end end end ) addEventHandler ( 'onPlayerVehicleExit',root, function ( vehicle ) if ( vehicle == newVehicle [ source ] ) then if isElement ( newVehicle [ source ] ) then destroyElement( newVehicle [ source ] ) newVehicle [ source ] = nil end if isElement ( myBlip [ source ] ) then destroyElement( myBlip [ source ] ) myBlip [ source ] = nil end if isElement ( marker [ source ] ) then destroyElement( marker [ source ] ) marker [ source ] = nil end end end ) addEventHandler ( 'onPlayerQuit',root, function ( ) if isElement ( newVehicle [ source ] ) then destroyElement( newVehicle [ source ] ) newVehicle [ source ] = nil end if isElement ( myBlip [ source ] ) then destroyElement( myBlip [ source ] ) myBlip [ source ] = nil end if isElement ( marker [ source ] ) then destroyElement( marker [ source ] ) marker [ source ] = nil end end ) Try this. Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 thank you very much,and i am sorry for annoying you Link to comment
Deep thinker Posted October 17, 2016 Author Share Posted October 17, 2016 now i started to make a script on my own with the functions you have taught me. thank you again 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