Jump to content

there is a bug in this script


Deep thinker

Recommended Posts

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

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
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

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

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 by FaHaD
Mistake
Link to comment

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

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

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
-- 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...