SkullBreaker Posted November 5, 2011 Share Posted November 5, 2011 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
TAPL Posted November 5, 2011 Share Posted November 5, 2011 wtf is this?!! triggerServerEvent (StartKnop, true) addEventHandler("onClientMarkerHit", dutyMarker, Link to comment
FatalTerror Posted November 5, 2011 Share Posted November 5, 2011 Your script makes no sense Link to comment
SkullBreaker Posted November 5, 2011 Author Share Posted November 5, 2011 A gui to create a marker if you press a button Link to comment
Jaysds1 Posted November 5, 2011 Share Posted November 5, 2011 So, when the gui pops up, and the player presses the button "Start", you want to close the gui and create 2 markers? Link to comment
SkullBreaker Posted November 5, 2011 Author Share Posted November 5, 2011 So, when the gui pops up, and the player presses the button "Start", you want to close the gui and create 2 markers? yes Link to comment
Jaysds1 Posted November 5, 2011 Share Posted November 5, 2011 (edited) 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 November 5, 2011 by Guest Link to comment
TAPL Posted November 5, 2011 Share Posted November 5, 2011 this addEvent("Event", true) addEventHandler("Event", root, should be addEvent("StartKnop", true) addEventHandler("StartKnop", root, Link to comment
Jaysds1 Posted November 5, 2011 Share Posted November 5, 2011 I wasn't shore if he had another trigger event handler but, ok, thanks Link to comment
TAPL Posted November 5, 2011 Share Posted November 5, 2011 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
SkullBreaker Posted November 6, 2011 Author Share Posted November 6, 2011 It now shows this error: Error: Bad argument @ serverside line 8 and 16. [Expected element at argument 2, got nill] What to do about this? Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 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
SkullBreaker Posted November 6, 2011 Author Share Posted November 6, 2011 The same error Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 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
SkullBreaker Posted November 6, 2011 Author Share Posted November 6, 2011 Still the same error, this time on line 15 and 24.. Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 Hm. That's pretty strange. There shouldn't be any errors. The syntax is correct. Link to comment
TAPL Posted November 6, 2011 Share Posted November 6, 2011 --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
Jaysds1 Posted November 6, 2011 Share Posted November 6, 2011 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
TAPL Posted November 6, 2011 Share Posted November 6, 2011 @Jaysds1 i've tested what i am post and it's work 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