MelloD Posted May 23, 2010 Posted May 23, 2010 hello I want something with addeventhandlercommand or addeventcommand example: I state in area-51 (Admin Base by me) I want so that a gate opens and I want a command that I am so busy at t, then / and then the name of the command and if I do it then the gate opens Who will help me sorry for my bad english i am from Netherlands sorry for my bad English i am Dutch....
Dark Dragon Posted May 23, 2010 Posted May 23, 2010 the function you're looking for is addCommandHandler Loads of fun for free! Also a lot of fun for free!
MelloD Posted May 23, 2010 Author Posted May 23, 2010 I've got a script and it works but if I want to do the same but I'll put a 1 behind so I got this in the first: openMyGate and this in the 2: 1 openMyGate1 then he opens not with the first command but he opened it with two commands are really Help me please function createTheGate () myGate = createObject ( 969, 209.0489654541, 1875.4265136719, 12.140625 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) function openMyGate ( ) moveObject ( myGate, 3000, 200.65399169922, 1875.3364257813, 12.140625 ) end addCommandHandler("open",openMyGate) function movingMyGateBack () moveObject ( myGate, 3000, 209.0489654541, 1875.4265136719 + 0, 12.140625 ) end addCommandHandler("close",movingMyGateBack) function createTheGate1 () myGate = createObject ( 3109, 226.6572265625, 1858.30859375, 14.64695930481 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) function openMyGate1 () moveObject ( myGate, 3000, 226.6572265625, 1858.30859375, 11.64695930481 ) end addCommandHandler("deur",openMyGate1) function movingMyGateBack1 () moveObject ( myGate, 3000, 226.6572265625, 1858.30859375, 14.64695930481 ) end addCommandHandler("deur1",movingMyGateBack1) what am I doing wrong sorry for my bad English i am Dutch....
dzek (varez) Posted May 23, 2010 Posted May 23, 2010 both of your gates is called "myGate".. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Jumba' Posted May 23, 2010 Posted May 23, 2010 Your lucky I got some exams tomorrow, this presents a perfect opportunity to procrastinate! Try this ... you add the objectID, ZYX, time to open, move to XYZ in the gates table, I've already added your own two gates in it. So basically to open the first gate you do /open 1, and for the second /open 2, etc. Same with /close. I'd recommend adding a colcircle around the gate tho since it's a bit unrealistic to open a gate in SF while riding in LS , or just check the distance between GetDistanceBetweenPoints3D using the gate position as one point and the players position as the other. Oh, and I haven't tested it, but I suppose I'd work -- First thing is to create a table to hold all the coordinates for the gates. -- In the gates table there tables that contain the info for one gate -- { objectID, CoordX, CoordY, CoordZ, Time to move gate in ms, moveToCoordZ, moveToCoordY, moveToCoordZ ) local gates = { { 969, 209.0489654541, 1875.4265136719, 12.140625, 3000, 200.65399169922, 1875.3364257813, 12.140625 }, { 3109, 226.6572265625, 1858.30859375, 14.64695930481, 3000, 226.6572265625, 1858.30859375, 11.64695930481 } } local gate = { } -- this is where we store the gate elements. addEventHandler ( "onResourceStart", getResourceRootElement(), function ( ) for i, tbl in ipairs ( gates ) do -- when the resource start we loop over the gates table gate[i] = createObject ( tbl[1], tbl[2], tbl[3], tbl[4] ) -- we create objects, the numbers 1-4 are the location of the objectID and the XYZ coords. ( see above ) end end ) addCommandHandler ( "open", function ( source, command, gate ) if tonumber ( gate ) then -- if its not a number we cant use it. local i = tonumber ( gate ) if gate[i] then -- if that gate exists we open it up moveObject ( gate[i], gates[i][5], gates[i][6], gates[i][7], gates[i][8] ) -- we open it to the XYZ coords in x amount of seconds, 5 - 8 in the table. else outputChatBox ( "Gate not found", source ) end else outputChatBox ( "Syntax is /" .. command .. " , with gate being a number.", source ) end end ) addCommandHandler ( "close", function ( source, command, gate ) if tonumber ( gate ) then local i = tonumber ( gate ) if gate[i] then moveObject ( gate[i], gates[i][5], gates[i][2], gates[i][3], gates[i][4] ) -- same as above, but since we're closing it (going back to begin position) we use the 2-4 XYZ. else outputChatBox ( "Gate not found", source ) end else outputChatBox ( "Syntax is /" .. command .. " , with gate being a number.", source ) end end )
MelloD Posted May 24, 2010 Author Posted May 24, 2010 ty for reply i have the /open command's now sorry for my bad English i am Dutch....
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