Jump to content

what should I do?


Recommended Posts

Hello, I was creating missions for my server and seeing that addEvent   and AddEventHadler  worked, but it did not activate the others that are within the function

function startZedMission ()
	outputChatBox ( "Your Get Mission" )
	addEventHandler ( "onClientPedWasted", root, ZedMissionCheckKill )
	addEventHandler ( "onClientRender", root, createText )
end
addEvent ("zombies", true) 
addEventHandler ("zombies", getRootElement(), startZedMission)

could anyone help me with this?

Link to comment

"server" I'll send you the complete script for you to see it.

Server

--mission 3--

zombiesKilled = 0

function ZedMissionWin ()
	zombiesKilled = 0
	outputChatBox( "Good job, mission completed!" )
	givePlayerMoney ( 50000 )
	removeEventHandler("onClientPedWasted",root,ZedMissionCheckKill)
	removeEventHandler ( "onClientRender",root, createText )
end

function ZedMissionCheckKill ( killer )
	
	if ( killer and getElementType(killer) == "player" and getElementType(source) == "ped" ) then 
		zombiesKilled = zombiesKilled+1 
	end
	
	if zombiesKilled >= 300 then 
		ZedMissionWin () 
	end
end

function createText ()
    dxDrawText("Killed Zombies 300/"..(zombiesKilled).."", 348, 4, 582, 30, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top" )
end

function startZedMission ()
	outputChatBox ( "Your Get Mission" )
end
addEventHandler ( "onClientPedWasted", root, ZedMissionCheckKill )
addEventHandler ( "onClientRender", root, createText )
addEvent ("zombies", true) 
addEventHandler ("zombies", getRootElement(), startZedMission)

Client

GUIEditor = {
    button = {},
    window = {},
    memo = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        windowMission = guiCreateWindow(298, 124, 705, 328, "Mission ZHP", false)
        guiWindowSetSizable(windowMission, false)
        guiSetAlpha(windowMission, 1.00)
		guiSetVisible (windowMission, false)

        FistButton = guiCreateButton(10, 24, 219, 15, "@", false, windowMission)
        SecondButton = guiCreateButton(10, 49, 219, 15, "@", false, windowMission)
        ThirdButton = guiCreateButton(10, 74, 219, 15, "@", false, windowMission)
        GUIEditor.button[4] = guiCreateButton(10, 99, 219, 15, "@", false, windowMission)
        GUIEditor.button[5] = guiCreateButton(10, 124, 219, 15, "@", false, windowMission)
        GUIEditor.button[6] = guiCreateButton(10, 149, 219, 15, "@", false, windowMission)
        GUIEditor.button[7] = guiCreateButton(10, 174, 219, 15, "@", false, windowMission)
        GUIEditor.button[8] = guiCreateButton(10, 199, 219, 15, "@", false, windowMission)
        GUIEditor.button[9] = guiCreateButton(10, 224, 219, 15, "@", false, windowMission)
        GUIEditor.button[10] = guiCreateButton(10, 249, 219, 15, "@", false, windowMission)
        ExitButton = guiCreateButton(10, 275, 219, 43, "EXIT", false, windowMission)
        GUIEditor.memo[1] = guiCreateMemo(239, 24, 456, 294, "@", false, windowMission)    
    end
)

--if you want add Marker# {},
Mark = {
{209.04536, 1871.57690, 12},
}
--Marker
local Marker1 = createMarker(209.04536, 1871.57690, 12, "cylinder", 1.5, 250,250,0)

for k,v in ipairs (Mark) do
z = v[3] -1
Marker = createMarker ( v[1], v[2], z, "cylinder", 1.5,  255, 255, 0, 255 )
addEventHandler('onClientMarkerHit', Marker,
    function ( hitPlayer )
        if ( hitPlayer == localPlayer ) then
            guiSetVisible (windowMission, true )
            showCursor( true )
        end
    end
)
end

addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY)
	local me = not guiGetVisible (windowMission)
	if (source == ExitButton) then
		guiSetVisible (windowMission, me)
		showCursor (me)
	elseif (source == FistButton) then
		triggerServerEvent ("iniciaJob", localPlayer) -- Inicia o evento "iniciarJob" que estiver no script server. E manda o localPlayer como elemento ativador.
		guiSetVisible(windowMission, false)
		showCursor( false )
	elseif (source == SecondButton) then
		triggerServerEvent ("iniciaJob2", localPlayer) -- Inicia o evento "iniciarJob" que estiver no script server. E manda o localPlayer como elemento ativador.
		guiSetVisible(windowMission, false)
		showCursor( false )
	elseif (source == ThirdButton ) then
		triggerServerEvent ("zombies", localPlayer) -- Inicia o evento "iniciarJob" que estiver no script server. E manda o localPlayer como elemento ativador.
		guiSetVisible(windowMission, false)
		showCursor( false )
	end
end)

 

Edited by kevincouto6
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...