DarkLink Posted June 13, 2011 Share Posted June 13, 2011 My question is: Does map editor can define how much vehicles is possible to put according to the gamemode? Example: On my gamemode named "X" i want to be only possible 4 cars ! so map editor user can only put 4 cars on that map of gamemode X. did u guys understand? If map editor user try to put the 5th car map editor says: "gamemode doesnt permit more than 4 cars". Is it possible? thanks Link to comment
karlis Posted June 13, 2011 Share Posted June 13, 2011 you cant do that without map editor plugin, you can, however, just reject/modify the map when the gamemode is started. Link to comment
DarkLink Posted June 13, 2011 Author Share Posted June 13, 2011 is there some plugin for mat editor that does that ? thanks Link to comment
DarkLink Posted June 16, 2011 Author Share Posted June 16, 2011 no and no one is thinking of made on ? :b Link to comment
Wojak Posted June 16, 2011 Share Posted June 16, 2011 addEvent("onClientElementCreate",true) addEventHandler("onClientElementCreate", root, function() if getElementType(source) == "vehicle" then local vehicles = getElementsByType(vehicle) if table.getn(vehicles) > 4 then exports.editor_main:destroySelectedElement() -- client only function outputChatBox("gamemode doesnt permit more than 4 cars") end end end) not tested, but should work save it in a file called edf.lua, and add to your resource edf file Link to comment
DarkLink Posted June 16, 2011 Author Share Posted June 16, 2011 thanks alot bro, i will test tonight . cya Link to comment
eAi Posted June 19, 2011 Share Posted June 19, 2011 Support for this could be added to EDF, if someone wanted to do it... Link to comment
DarkLink Posted June 19, 2011 Author Share Posted June 19, 2011 didnt had time yet to test ur code wojak, but I will. thanks. Support for this could be added to EDF, if someone wanted to do it... that would be awesome eAi !! I would be very good function. So I could use my gamemode better If you guys could do it, I would be grateful Thanks. Link to comment
DarkLink Posted July 24, 2011 Author Share Posted July 24, 2011 Hey wojak I tryed what you said but doesnt work, tryed with my custom elements that are passage elements. doing this: addEvent("onClientElementCreate",true) addEventHandler("onClientElementCreate", root, function() if getElementType(source) == "passage" then local passages = getElementsByType(passage) if table.getn(passages) > 4 then exports.editor_main:destroySelectedElement() -- client only function outputChatBox("gamemode doesnt permit more than 4 cars") end end end) But doesnt say nothing, and I can have the element on map editor, its not destroyed. I add this on my borderpatrol.edf file: Maybe because you made an event but we are not triggering it ? Its just a client side event, dont u need a triggerClientEvent? Thanks in advance bro. Cya. Link to comment
Wojak Posted July 25, 2011 Share Posted July 25, 2011 this is a working script, and a exemple how to debug scripts local passages = getElementsByType("passage") local npasages = table.getn(passages) addEvent("onClientElementCreate",true) addEventHandler("onClientElementCreate", root, function() outputChatBox("create: "..tostring(getElementType(source))) if getElementType(source) == "passage" then npasages = npasages + 1 outputChatBox(npasages) if npasages > 4 then setTimer(function() exports.editor_main:destroySelectedElement() end,100,1) outputChatBox("gamemode doesnt permit more than 4 teleports") end end end) addEvent("onClientElementDestroyed",true) addEventHandler("onClientElementDestroyed", root, function() outputChatBox("destroy: "..tostring(getElementType(source))) if getElementType(source) == "passage" then npasages = npasages - 1 outputChatBox(npasages) end end) note that there still may be a problem when you statr a new map... the table npasages should be reseted when the new map starts but "onNewMap" and "onMapOpened" are server only events (but you may trigger a clientside event from the server) edit: btw - you may use events triggered by other resources in youre script, you just need to know if a resource trigger something and what is the name of the event Link to comment
DarkLink Posted July 25, 2011 Author Share Posted July 25, 2011 Thanks for your reply, but I still cant understand where that source cames from? I mean there that is a custom event right? its not on the wiki. and you are not triggering it, so what will be the source? Thanks. Maybe I am doing things wrong? I open map editor at mtasa, then add definitions for the borderpatrol.edf which have this line on the edf file: So its everything okay? should it give me messages on the chatbox when I try to make more than 4 passages? Thanks. Link to comment
Wojak Posted July 25, 2011 Share Posted July 25, 2011 events are triggered by editor_main resouce. You may use events triggered by other resources in youre script (this is a very awesome MTA feature) As for the script- i tested it and it works Link to comment
DarkLink Posted July 25, 2011 Author Share Posted July 25, 2011 events are triggered by editor_main resouce. You may use events triggered by other resources in youre script (this is a very awesome MTA feature)As for the script- i tested it and it works Yes its working now! Thanks alot bro! By the way, I understand now what you were talking about the events of which resource, that I can use on other resources ! Thats amazing! And so I did u know about those "onNewMap" and "onMapOpen" ? Is there any documentation about editor_main resource? I can't find it on mta wiki bro. And one more question its not possible to put more than 4 passages right? But a mapper can cheat and go right on .map file, and add one more right? this scripts doesnt prevent from that "cheating", right? What I must do is when I am getting those elements I only get 4 of them not more, right? its the solution? Thanks alot in advance, you helped me alot! Link to comment
Wojak Posted July 26, 2011 Share Posted July 26, 2011 And so I did u know about those "onNewMap" and "onMapOpen" ? Is there any documentation about editor_main resource?I can't find it on mta wiki bro. bad news is, that there is no documentation on the wiki, or anywhere else by that mater... good news is that the source cod of edf and editor_main is not compiled this is the edf resource meta.xml, you may find list of exported functiond here: http://code.google.com/p/mtasa-resource ... f/meta.xml this is editor_main meta.xml with the list of expotred functions: http://code.google.com/p/mtasa-resource ... n/meta.xml you use expotred functions like this: exports.resource:function if you not shute how a function works, check it in the lua file... this is a search result of "edf trigger", pages should contain all events triggered by resource edf: http://www.google.com/codesearch#search ... -resources\.googlecode\.com this is a search result of "editor_main trigger", pages should contain all event triggered by resource editor_main: http://www.google.com/codesearch#search ... -resources\.googlecode\.com exemple: triggerClientEvent(rootElement, "onClientElementCreate", self.element) this is a 123 line in the editor_main/server/undoredo_action.lua the file is serverside and the function "triggerClientEvent" is used, so the event will be accessible client side, rootElement means: "for all clients", "onClientElementCreate" suggests that event will be triggerd when a element is created and self.element means that the source will be a element that was created of course you may check the context in the source code to be shure And one more question its not possible to put more than 4 passages right? But a mapper can cheat and go right on .map file, and add one more right? this scripts doesnt prevent from that "cheating", right?What I must do is when I am getting those elements I only get 4 of them not more, right? its the solution? yes mapers can cheat... to prevent thet you may start by using this method: viewtopic.php?p=359450#p359450 in the edf script you must check ow many teleports there are (on edf load and on map load) if more then 4 you should decrease the number of teleprts by 4 an use the loop break method to destroy aditional teleports... Link to comment
DarkLink Posted July 26, 2011 Author Share Posted July 26, 2011 Ye thanks alot bro, I forgot about those pages on google ! I will read it after when I have some time, thanks! And yes Jacob teach me how to do it I can prevent map cheating ^^ And I will make those verifications on edf file, I need onMapOpen, onNewMap and .. what is the one for load edf? onLoadEdf ? Thanks alot mate! 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