dam034 Posted October 9, 2017 Posted October 9, 2017 Dear users, this is the file a.lua: lanciarazzi = { } basirazzi = { } sbarra = 0 function crealanciatori() sbarra = createObject(968, -1526.4400439453, 481.39999389648, 6.905, 0, 270, 0) sbarra.breakable = false lanciarazzi = { createObject(3884, -1496.8, 590.4, 42.05, 0, 0, 225), -- ponte ferroviario nuovo createObject(3884, -1225, 456, 7.05, 0, 0, 90), -- est nuovo } basirazzi = { createObject(3885, -1496.8, 590.4, 42, 0, 0, 0), -- ponte ferroviario nuova createObject(3885, -1225, 456, 7, 0, 0, 0), -- est nuova } end function nonrompere() for ch, v in ipairs(lanciarazzi) do setObjectBreakable(v, false) end for ch, v in ipairs(basirazzi) do setObjectBreakable(v, false) end end This is b.lua: function proteggi(nome, param) nonrompere() addEventHandler("onClientColShapeHit", basesf, inizia) sbarra.move(4000, -1526.4400439453, 481.39999389648, 6.905, 0, -90, 0, 'InOutQuad') outputChatBox("Attenzione: protezione sulla base di San Fierro abilitata.") end function nonproteggere(nome, param) removeEventHandler("onClientColShapeHit", basesf, inizia) sbarra.move(4000, -1526.4400439453, 481.39999389648, 6.905, 0, 90, 0, 'InOutQuad') outputChatBox("Attenzione: protezione sulla base di San Fierro disabilitata.") end addEventHandler("onClientResourceStart", resourceRoot, proteggi) addEventHandler("onClientResourceStop", resourceRoot, nonproteggere) addCommandHandler("sibasesf", proteggi) addCommandHandler("nobasesf", nonproteggere) And this is meta.xml: <meta> <oop>true</oop> <script src="a.lua" type="shared" /> <script src="b.lua" type="client" /> </meta> In function proteggi() and nonproteggere() I can't read the variable sbarra, furthermore the function nonrompere() doesn't work. Where did I go wrong? Thanks
Moderators IIYAMA Posted October 9, 2017 Moderators Posted October 9, 2017 Add this to line 17(this code). crealanciatori()
dam034 Posted October 9, 2017 Author Posted October 9, 2017 Where do I have to call the function crealanciatori()? Thanks
Moderators IIYAMA Posted October 9, 2017 Moderators Posted October 9, 2017 7 hours ago, IIYAMA said: Add this to line 17(this code). crealanciatori() Just after you created the function.
dam034 Posted October 10, 2017 Author Posted October 10, 2017 Thanks, now it works. And I let to execute a.lua clientside, not shared. Now I have a.lua: basesf = createColPolygon(-1543, 480, -1559, 451, -1597, 399, -1726, 261, -1446, 261, -1446, 293, -1342, 293, -1329, 306, -1329, 435, -1227, 435, -1227, 519, -1515, 519, -1515, 480) lanciarazzi = { } basirazzi = { } sbarra = 0 removeWorldModel(968, 15, -1526, 481, 7) -- sbarra sbarra = createObject(968, -1526.4400439453, 481.39999389648, 6.905, 0, 270, 0) lanciarazzi = { createObject(3884, -1496.8, 590.4, 42.05, 0, 0, 225), -- ponte ferroviario nuovo createObject(3884, -1225, 456, 7.05, 0, 0, 90), -- est nuovo } basirazzi = { createObject(3885, -1496.8, 590.4, 42, 0, 0, 0), -- ponte ferroviario nuova createObject(3885, -1225, 456, 7, 0, 0, 0), -- est nuova } function nonrompere() setObjectBreakable(sbarra, false) for ch, v in ipairs(lanciarazzi) do setObjectBreakable(v, false) end for ch, v in ipairs(basirazzi) do setObjectBreakable(v, false) end end b.lua: function proteggi() nonrompere() addEventHandler("onClientColShapeHit", basesf, inizia) moveObject(sbarra, 4000, -1526.4400439453, 481.39999389648, 6.905, 0, -90, 0, 'InOutQuad') outputChatBox("Attenzione: protezione sulla base di San Fierro abilitata.") end function nonproteggere() removeEventHandler("onClientColShapeHit", basesf, inizia) moveObject(sbarra, -1526.4400439453, 481.39999389648, 6.905, 0, 90, 0, 'InOutQuad') outputChatBox("Attenzione: protezione sulla base di San Fierro disabilitata.") end addEventHandler("onClientResourceStart", resourceRoot, proteggi) addEventHandler("onClientResourceStop", resourceRoot, nonproteggere) addCommandHandler("sibasesf", proteggi) addCommandHandler("nobasesf", nonproteggere) and meta.xml: <meta> <script src="a.lua" type="client" /> <script src="b.lua" type="client" /> </meta> And I removed the OOP because it doesn't work, I don't know why. But I have another problem: when I execute nonproteggere() via the nobasesf command, the function moveObject() isn't executed, it is a simple rotation, why? Thanks
Moderators IIYAMA Posted October 10, 2017 Moderators Posted October 10, 2017 Line 4 moveObject(sbarra, 4000, -1526.4400439453, 481.39999389648, 6.905, 0, -90, 0, 'InOutQuad') Line 10 moveObject(sbarra, -1526.4400439453, 481.39999389648, 6.905, 0, 90, 0, 'InOutQuad') You forgot to fill in the time.
dam034 Posted October 10, 2017 Author Posted October 10, 2017 Yeah, it's true. I wonder where I left my head. Thanks 1
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