Jump to content

Help with "Event" script


SkullBreaker

Recommended Posts

Hi,

I made a gui for a event, if you press the button "Start!" 2 markers will be created.

But it shows a error about "Need a element at argument 2, got nill ( line 13 and 27 ) "

So I don't know how to fix this.

THis is my client:

  
local EvMarker = createMarker ( 1547.88953, -1681.53955, 12.5, 'arrow', 2, 255, 0, 0, 255 ) 
     
    function createEvGui () 
        GUIEditor_Window = {} 
        GUIEditor_TabPanel = {} 
        GUIEditor_Tab = {} 
        GUIEditor_Button = {} 
        GUIEditor_Memo = {} 
  
        EvGui = guiCreateWindow(333,326,185,220,"SARG Event panel 0.1",false) 
        EvTabPan = guiCreateTabPanel(10,20,166,191,false,GUIEditor_Window[1]) 
        EvTab = guiCreateTab("Rules",EvTabPan) 
        EvMemo = guiCreateMemo(6,4,155,182,"The rules of the event: There are 2 teams, armed with spray, the goal is to eliminate the enemy team with the spray, admins can stop the event by typing: /stop ()Events",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(EvMemo,true) 
        EvTab2 = guiCreateTab("START!",EvTabPanel) 
        Start = guiCreateButton(23,33,129,64,"START EVENT",false,EvTab2) 
    end 
  
addEventHandler("onClientMarkerHit", dutyMarker, 
  
 function(hitElement) 
  
            if hitElement == localPlayer then 
  
            createEvGui ( hitElement ) 
  
            if (EvGui ~= nil) then 
  
            guiSetVisible(EvGui, true) 
  
            showCursor(true) 
  
            guiSetInputEnabled(true) 
  
            else 
  
            outputChatBox ("The event is not ready yet.") 
  
            end 
  
        end 
  
    end 
  
) 
  
function Event(button,state) 
  if (source == Start) then 
    triggerServerEvent (StartKnop, true) 
    end 
end 
addEventHandler("onClientGuiClick", root, Event) 
  

and server:

  
function MarkerRed () 
    evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
end 
addEvent("Event", true) 
addEventHandler("Event", root, MarkerRed) 
  
function setPosRed ( hitElement ) 
    if getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) then 
    setElementPosition ( 2838.6000976563, -2527.6999511719, 19 ) 
    giveWeapon ( source, 41, 100000 ) 
    end 
end 
addEventHandler("onMarkerHit", evmarkerred, setPosRed) 
  
function MarkerBlue () 
    evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
end 
addEvent("Event", true) 
addEventHandler("Event", root, MarkerBlue) 
  
function setPosBlue ( hitElement ) 
    if getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) then 
    setElementPosition ( 2837.6999511719, -2333, 12 ) 
    giveWeapon ( source, 41, 100000 ) 
    end 
end 
addEventHandler("onMarkerHit", evmarkerblue, setPosBlue) 
  

thanks.

Link to comment

try this:

Client-Side

localplayer = getLocalPlayer() 
local EvMarker = createMarker ( 1547.88953, -1681.53955, 12.5, 'arrow', 2, 255, 0, 0, 255 )   
function createEvGui() 
    EvGui = guiCreateWindow(333,326,185,220,"SARG Event panel 0.1",false) 
    EvTabPanel= guiCreateTabPanel(10,20,166,191,false,EveGui) 
    EvTab = guiCreateTab("Rules",EvTabPan) 
    EvMemo = guiCreateMemo(6,4,155,182,"The rules of the event: There are 2 teams, armed with spray, the goal is to eliminate the enemy team with the spray, admins can stop the event by typing: /stop ()Events",false,EvTab) 
    guiMemoSetReadOnly(EvMemo,true) 
    EvTab2 = guiCreateTab("START!",EvTabPanel) 
    Start = guiCreateButton(23,33,129,64,"START EVENT",false,EvTab2) 
    guiSetVisible(EvGui,false) 
end 
  
addEventHandler("onClientMarkerHit", getRootElement(), 
 function(hitElement) 
    if (hitElement == localPlayer) then 
        if (dutyMarker) then 
            createEvGui() 
            if (EvGui ~= nil) then 
                guiSetVisible(EvGui, true) 
                showCursor(true) 
                guiSetInputEnabled(true) 
            else 
                outputChatBox ("The event is not ready yet.") 
            end 
        end 
    end 
 end) 
  
addEventHandler("onClientGuiClick", root,  
function(button,state) 
  if (source == Start) then 
    triggerServerEvent("StartKnop",getLocalPlayer()) 
    end 
end) 

Server-side:

addEvent("StartKnop", true) 
addEventHandler("StartKnop", root,   
function() 
    evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
    evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
end) 
  
 addEventHandler("onMarkerHit", evmarkerred,  
function( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
        setElementPosition ( hitElement,2838.6000976563, -2527.6999511719, 19 ) 
        giveWeapon ( hitElement, 41, 100000 ) 
    end 
end) 
  
 addEventHandler("onMarkerHit", evmarkerblue,  
function( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
    setElementPosition ( hitElement,2837.6999511719, -2333, 12 ) 
    giveWeapon ( hitElement, 41, 100000 ) 
    end 
end) 

Edited by Guest
Link to comment

i found another thing

addEventHandler("onClientGuiClick", root, 
function Event(button,state) 
  if (source == Start) then 
    triggerServerEvent("StartKnop",getLocalPlayer()) 
    end 
end) 

should be

addEventHandler("onClientGuiClick", root, 
function(button,state) 
  if (source == Start) then 
    triggerServerEvent("StartKnop",getLocalPlayer()) 
    end 
end) 

Edit:

this too

    EvMemo = guiCreateMemo(6,4,155,182,"The rules of the event: There are 2 teams, armed with spray, the goal is to eliminate the enemy team with the spray, admins can stop the event by typing: /stop ()Events",false,GUIEditor_Tab[1]) 

correct

    EvMemo = guiCreateMemo(6,4,155,182,"The rules of the event: There are 2 teams, armed with spray, the goal is to eliminate the enemy team with the spray, admins can stop the event by typing: /stop ()Events",false,EvTab) 

Link to comment
addEvent("StartKnop", true) 
addEventHandler("StartKnop", root,   
function() 
    local evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
    local evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
end) 
  
 addEventHandler("onMarkerHit", evmarkerred, 
function( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
        setElementPosition ( hitElement,2838.6000976563, -2527.6999511719, 19 ) 
        giveWeapon ( hitElement, 41, 100000 ) 
    end 
end) 
  
 addEventHandler("onMarkerHit", evmarkerblue, 
function( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
    setElementPosition ( hitElement,2837.6999511719, -2333, 12 ) 
    giveWeapon ( hitElement, 41, 100000 ) 
    end 
end) 

Link to comment
addEvent("StartKnop", true) 
addEventHandler("StartKnop", root,   
function() 
    local evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
    local evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
end) 
  
function mhit1 ( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
        setElementPosition ( hitElement,2838.6000976563, -2527.6999511719, 19 ) 
        giveWeapon ( hitElement, 41, 100000 ) 
    end 
end 
  
addEventHandler("onMarkerHit", evmarkerred, mhit1) 
  
function mhit2 ( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
    setElementPosition ( hitElement,2837.6999511719, -2333, 12 ) 
    giveWeapon ( hitElement, 41, 100000 ) 
    end 
end 
  
addEventHandler("onMarkerHit", evmarkerblue, mhit2) 
  

Link to comment

--Client Side--

local EvMarker = createMarker ( 1547.88953, -1681.53955, 12.5, 'arrow', 2, 255, 0, 0, 255 )   
  
    EvGui = guiCreateWindow(333,326,185,220,"SARG Event panel 0.1",false) 
    guiSetVisible(EvGui, false) 
    showCursor (false) 
    guiSetInputEnabled(false) 
    EvTabPan = guiCreateTabPanel(10,20,166,191,false,EvGui) 
    EvTab = guiCreateTab("Rules",EvTabPan) 
    EvMemo = guiCreateMemo(6,4,155,182,"The rules of the event: There are 2 teams, armed with spray, the goal is to eliminate the enemy team with the spray, admins can stop the event by typing: /stop ()Events",false,EvTab) 
    guiMemoSetReadOnly(EvMemo,true) 
    EvTab2 = guiCreateTab("START!",EvTabPan) 
    Start = guiCreateButton(23,33,129,64,"START EVENT",false,EvTab2) 
  
addEventHandler("onClientMarkerHit", EvMarker, 
 function(hitElement) 
    if (hitElement == localPlayer) then 
            if (guiGetVisible(EvGui) == false) then 
                guiSetVisible(EvGui, true) 
                showCursor(true) 
                guiSetInputEnabled(true) 
            else 
                outputChatBox ("The event is not ready yet.") 
            end 
       end 
 end) 
  
function ButtClick(button,state) 
    triggerServerEvent("StartKnop",localPlayer) 
    guiSetVisible(EvGui, false) 
    showCursor (false) 
    guiSetInputEnabled(false) 
end 
addEventHandler ( "onClientGUIClick", Start, ButtClick ) 

--Server Side--

local evmarkerred 
local evmarkerblue 
  
addEvent("StartKnop", true) 
addEventHandler("StartKnop", root,   
function() 
    evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
    evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
    addEventHandler("onMarkerHit", evmarkerred, mhit1) 
    addEventHandler("onMarkerHit", evmarkerblue, mhit2) 
end) 
  
function mhit1 ( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
    setElementPosition ( hitElement,2838.6000976563, -2527.6999511719, 19 ) 
    giveWeapon ( hitElement, 41, 100000 ) 
    removeEventHandler("onMarkerHit", evmarkerred, mhit1) 
    removeEventHandler("onMarkerHit", evmarkerblue, mhit2) 
    destroyElement (evmarkerred) 
    destroyElement (evmarkerblue) 
    end 
end 
  
function mhit2 ( hitElement ) 
    if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
    setElementPosition ( hitElement,2837.6999511719, -2333, 12 ) 
    giveWeapon ( hitElement, 41, 100000 ) 
    removeEventHandler("onMarkerHit", evmarkerred, mhit1) 
    removeEventHandler("onMarkerHit", evmarkerblue, mhit2) 
    destroyElement (evmarkerred) 
    destroyElement (evmarkerblue) 
    end 
end 

Link to comment

Actually, try this:

Server-side

addEvent("StartKnop", true) 
addEventHandler("StartKnop", root,   
function() 
    evmarkerred = createMarker ( 1547.88953, -1683, 12.5, 'cylinder', 2, 255, 0, 0, 255 ) 
    evmarkerblue = createMarker ( 1547.88953, -1686, 12.5, 'cylinder', 2, 0, 0, 255, 255 ) 
    addEventHandler("onMarkerHit", evmarkerred, 
        function( hitElement ) 
            if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
                setElementPosition ( hitElement,2838.6000976563, -2527.6999511719, 19 ) 
                giveWeapon ( hitElement, 41, 100000 ) 
            end 
        end) 
  
    addEventHandler("onMarkerHit", evmarkerblue, 
        function( hitElement ) 
            if (getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement )) then 
                setElementPosition ( hitElement,2837.6999511719, -2333, 12 ) 
                giveWeapon ( hitElement, 41, 100000 ) 
            end 
        end) 
end) 

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