kieran Posted June 7, 2017 Share Posted June 7, 2017 Hello, I am trying to edit a script I found from a YouTube tutorial, it almost works, except it doesn't like the EventHandlers I have in it..... Here's the code. Server Error Message [2017-06-07 17:08:08] Resources: 203 loaded, 0 failed [2017-06-07 17:08:08] Starting resources... [2017-06-07 17:08:36] Server minclientversion is now 1.5.4-9.11324.0 [2017-06-07 17:08:55] WARNING: 1892\gate.lua:13: Bad argument @ 'addEventHandler' [Expected element at argument 2, got function] [2017-06-07 17:08:55] WARNING: 1892\gate.lua:19: Bad argument @ 'addEventHandler' [Expected element at argument 2, got function] [2017-06-07 17:08:55] Gamemode 'Under Maintenance' started. Lua Code object = createObject(980, 2539.5, 1343.2998046875, 12.60000038147) marker = createMarker(2539.5, 1343.2998046875, 12.60000038147, "cylinder", 2, 100, 0, 0, 100) function gateopen(player) local data = getElementData(Player,"job") if (data=="Admin") then moveObject(object, 500, 980, 2539.5, 1343.2998046875, 15.60000038147) else outputChatBox("Message") end end addEventHandler("onMarkerHit",gateopen) function gateclose(player) moveObject(object, 2539.5, 1343.2998046875, 12.60000038147) end addEventHandler("onMarkerLeave",gateclose) Any help at all is appreciated, I know what's wrong, I just have no idea how to fix it (I am learning slowly, only been 2 days since I started) Link to comment
AE. Posted June 7, 2017 Share Posted June 7, 2017 object = createObject(980, 2539.5, 1343.2998046875, 12.60000038147) marker = createMarker(2539.5, 1343.2998046875, 12.60000038147, "cylinder", 2, 100, 0, 0, 100) function gateopen(player) local data = getElementData(Player,"job") if (data=="Admin") then moveObject(object, 500, 980, 2539.5, 1343.2998046875, 15.60000038147) else outputChatBox("Message") end end addEventHandler("onMarkerHit",getRootElement(),gateopen) function gateclose(player) moveObject(object, 2539.5, 1343.2998046875, 12.60000038147) end addEventHandler("onMarkerLeave",getRootElement(),gateclose) 1 Link to comment
aka Blue Posted June 7, 2017 Share Posted June 7, 2017 object = createObject(980, 2539.5, 1343.2998046875, 12.60000038147) marker = createMarker(2539.5, 1343.2998046875, 12.60000038147, "cylinder", 2, 100, 0, 0, 100) function gateopen(player) local data = getElementData(Player,"job") if (data=="Admin") then moveObject(object, 500, 980, 2539.5, 1343.2998046875, 15.60000038147) else outputChatBox("Message") end end addEventHandler("onMarkerHit",object,gateopen) function gateclose(player) moveObject(object, 2539.5, 1343.2998046875, 12.60000038147) end addEventHandler("onMarkerLeave",object,gateclose) 1 Link to comment
keymetaphore Posted June 7, 2017 Share Posted June 7, 2017 1 hour ago, aka Blue said: object = createObject(980, 2539.5, 1343.2998046875, 12.60000038147) marker = createMarker(2539.5, 1343.2998046875, 12.60000038147, "cylinder", 2, 100, 0, 0, 100) function gateopen(player) local data = getElementData(Player,"job") if (data=="Admin") then moveObject(object, 500, 980, 2539.5, 1343.2998046875, 15.60000038147) else outputChatBox("Message") end end addEventHandler("onMarkerHit",object,gateopen) function gateclose(player) moveObject(object, 2539.5, 1343.2998046875, 12.60000038147) end addEventHandler("onMarkerLeave",object,gateclose) shouldn't the handler be attached to marker, not object? 1 Link to comment
kieran Posted June 7, 2017 Author Share Posted June 7, 2017 Thanks for the replies! I tried it but they don't work..... Do I need to make groups? I was just trying to use default Admin group from ACL.xml, but failed... Link to comment
AE. Posted June 7, 2017 Share Posted June 7, 2017 @kieran to move the object the player who enter the marker have to have the data local data = getElementData(Player,"job") Link to comment
kieran Posted June 7, 2017 Author Share Posted June 7, 2017 5 minutes ago, 3laa33 said: @kieran to move the object the player who enter the marker have to have the data local data = getElementData(Player,"job") I have only started scripting 2 days ago and know almost nothing about MTA's lua format... I know a little about C++ as I had a month of C# as part of a course but nothing really helpful such as what should be client or serverside. (script is of course server side) but my question was, do I need to make another script client side so that the server can pull the information from it? Link to comment
AE. Posted June 7, 2017 Share Posted June 7, 2017 i'm confused right now the code is working and you have a question or the code is not working + you don't need client side if you won't use client side only functions like gui function Link to comment
kieran Posted June 7, 2017 Author Share Posted June 7, 2017 Code does not work, it should, but it's not.... Thanks for help, I'll keep looking on forums and cross my fingers bro. That or download a resource..... Link to comment
kieran Posted June 8, 2017 Author Share Posted June 8, 2017 @Gourmet. was right, I was trying to make a gate move when I was hitting a marker... code is below, improve it, use it, do as you wish, is as basic as it gets, but proud of my first script (That I kinda stole from YouTube) object = createObject(980, 2337.3999023438, 1573, 12.60000038147, 0, 0, 90) marker = createMarker(2339.3999023438, 1573, 9, "cylinder", 7, 100, 0, 0, 100) function gateopen(player) moveObject(object, 3000, 2337.3999023438, 1583.400390625, 12.60000038147) end addEventHandler("onMarkerHit",marker,gateopen) function gateclose(player) moveObject(object, 3000, 2337.3999023438, 1573, 12.60000038147) end addEventHandler("onMarkerLeave",marker,gateclose) Note that the gate is inside of an MTA building, so you will need to fiddle with cords before it works! Link to comment
keymetaphore Posted June 8, 2017 Share Posted June 8, 2017 7 hours ago, kieran said: @Gourmet. was right, I was trying to make a gate move when I was hitting a marker... code is below, improve it, use it, do as you wish, is as basic as it gets, but proud of my first script (That I kinda stole from YouTube) object = createObject(980, 2337.3999023438, 1573, 12.60000038147, 0, 0, 90) marker = createMarker(2339.3999023438, 1573, 9, "cylinder", 7, 100, 0, 0, 100) function gateopen(player) moveObject(object, 3000, 2337.3999023438, 1583.400390625, 12.60000038147) end addEventHandler("onMarkerHit",marker,gateopen) function gateclose(player) moveObject(object, 3000, 2337.3999023438, 1573, 12.60000038147) end addEventHandler("onMarkerLeave",marker,gateclose) Note that the gate is inside of an MTA building, so you will need to fiddle with cords before it works! Remember, that if it's in an interior / dimension, you have to do setElementDimension() / setElementInterior() good luck 1 Link to comment
aka Blue Posted June 8, 2017 Share Posted June 8, 2017 Yes it was marker, my mistake, sorry 1 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