Jump to content

i can't find the bug


Deep thinker

Recommended Posts

hi all i have made a simple script but i have added a part to the script which allows only a team to use this marker but i can't see the marker ,here you are the script :

-- Server Side
local criminalsTeam = createTeam("Criminals",150,0,0)
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
)

function
local allowteam = getTeamFromName("Criminals") 
	if (allowteam) then 
	tiggerClientEvent( thePlayer,"show",thePlayer,root )
	else 
	then tiggerClientEvent( thePlayer,"dshow",thePlayer,root )
end

Client:

-- Client
local marker = createMarker ( 1616.44446,-1506.94568,13.20866,"cylinder",1,255,0,0,0 ) 
local ped = createPed ( 28,1616.44446, -1506.94568, 14.2066,90,0,0 )
setElementFrozen( ped,true )

GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}

GUIEditor_Window[1] = guiCreateWindow(0.3698,0.5208,0.2517,0.1863,"\"Drug Delivery Request\"",true)
    guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
guiSetAlpha(GUIEditor_Window[1],1)
guiWindowSetMovable(GUIEditor_Window[1],false)
guiWindowSetSizable(GUIEditor_Window[1],false)
GUIEditor_Button[1] = guiCreateButton(29,114,92,31,"Cancel",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(158,114,92,31,"Accept",false,GUIEditor_Window[1])
GUIEditor_Memo[1] = guiCreateMemo(11,26,264,79,"If you Pressed \"Accept\"Follow The Blip in the radar and you will gain 10000$ .If you Pressed Cancel or Leaved the Vehicle in the Delivery then your mission failed.",false,GUIEditor_Window[1])
guiMemoSetReadOnly(GUIEditor_Memo[1],true)




addEvent( "show",true )
addEventHandler("show",marker,
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("onClientRender", getRootElement(), 
function()
local x, y, z = getElementPosition(ped)
local x2, y2, z2 = getElementPosition(localPlayer)
if(isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) then
local sx, sy = getScreenFromWorldPosition(x, y, z+1.1)
if(sx) and (sy) then
local distance = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if(distance < 30) then
				dxDrawText("Drugs Dealer", sx+2, sy+2, sx, sy, tocolor(0,0,0), 2-(distance/20), "arial", "center", "center")
				dxDrawText("Drugs Dealer", sx, sy, sx, sy, tocolor(255,0,0), 2-(distance/20), "arial", "center", "center")
			end
		end
	end
end
)
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
    end,false
)

addEventHandler ('onClientGUIClick',GUIEditor_Button[2],
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            triggerServerEvent ("MyEvent",localPlayer)
    end,false
)
addEventHandler ( 'onClientPedDamage',ped,cancelEvent  )
addEvent("dshow",true)
addEventHandler("dshow",marker,
function dontshow
guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
		outPutChatBox("You Aren't a criminal to deliver drugs",150,0,0)
		end
	end
end
)

please answer as soon as possible ,thank you.

Link to comment

i made it like this 

-- Server Side
local criminalsTeam = createTeam("Criminals",150,0,0)
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
)

function
local allowteam = getTeamFromName("Criminals") 
	tiggerClientEvent( thePlayer,"dshow",thePlayer,root )
end
-- Client
local marker = createMarker ( 1616.44446,-1506.94568,13.20866,"cylinder",1,255,0,0,0 ) 
local ped = createPed ( 28,1616.44446, -1506.94568, 14.2066,90,0,0 )
setElementFrozen( ped,true )

GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Memo = {}

GUIEditor_Window[1] = guiCreateWindow(0.3698,0.5208,0.2517,0.1863,"\"Drug Delivery Request\"",true)
    guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
guiSetAlpha(GUIEditor_Window[1],1)
guiWindowSetMovable(GUIEditor_Window[1],false)
guiWindowSetSizable(GUIEditor_Window[1],false)
GUIEditor_Button[1] = guiCreateButton(29,114,92,31,"Cancel",false,GUIEditor_Window[1])
GUIEditor_Button[2] = guiCreateButton(158,114,92,31,"Accept",false,GUIEditor_Window[1])
GUIEditor_Memo[1] = guiCreateMemo(11,26,264,79,"If you Pressed \"Accept\"Follow The Blip in the radar and you will gain 10000$ .If you Pressed Cancel or Leaved the Vehicle in the Delivery then your mission failed.",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("onClientRender", getRootElement(), 
function()
local x, y, z = getElementPosition(ped)
local x2, y2, z2 = getElementPosition(localPlayer)
if(isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) then
local sx, sy = getScreenFromWorldPosition(x, y, z+1.1)
if(sx) and (sy) then
local distance = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if(distance < 30) then
				dxDrawText("Drugs Dealer", sx+2, sy+2, sx, sy, tocolor(0,0,0), 2-(distance/20), "arial", "center", "center")
				dxDrawText("Drugs Dealer", sx, sy, sx, sy, tocolor(255,0,0), 2-(distance/20), "arial", "center", "center")
			end
		end
	end
end
)
addEventHandler ('onClientGUIClick',GUIEditor_Button[1],
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
    end,false
)

addEventHandler ('onClientGUIClick',GUIEditor_Button[2],
    function (  )
            guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
            triggerServerEvent ("MyEvent",localPlayer)
    end,false
)
addEventHandler ( 'onClientPedDamage',ped,cancelEvent  )
addEvent("dshow",true)
addEventHandler("dshow",marker,
function dontshow
guiSetVisible ( GUIEditor_Window[1],false )
            showCursor ( false )
		 if getPlayerTeam = ( Criminals ) then                    
					guiSetVisible ( GUIEditor_Window[1],true )
                    showCursor ( true )
			else		
		outPutChatBox("You Aren't a criminal to deliver drugs",150,0,0)
		            guiSetVisible ( GUIEditor_Window[1],false )
                    showCursor ( false )
		end
	end
end
)

i still can't see the markers ,can you edit it to work?

Link to comment

[/lua]

addEvent('MyEvent',true)
addEventHandler('MyEvent',root,
    function  ( )
    if not getPlayerTeam(source) or getPlayerTeam(source) ~= getTeamFromName("Criminals") then return end
        if newVehicle [ source ] and isElement ( newVehicle [ source ] ) then return false end
             newVehicle [ source ] = createVehicle ( 482,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',5,255,53,53,53,source ) 
    end
)

[/lua]

use this instead of allowed teams

Edited by Jinx099
  • Like 1
Link to comment
15 hours ago, Jinx099 said:

[/lua]

addEvent('MyEvent',true)
addEventHandler('MyEvent',root,
    function  ( )
    if not getPlayerTeam(source) or getPlayerTeam(source) ~= getTeamFromName("Criminals") then return end
        if newVehicle [ source ] and isElement ( newVehicle [ source ] ) then return false end
             newVehicle [ source ] = createVehicle ( 482,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',5,255,53,53,53,source ) 
    end
)

[/lua]

use this instead of allowed teams

You have to use the new way of posting codes. See the '<>' (code) button, it will allow you to paste codes.

  • Like 2
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...