Jump to content

[REL] In-Game Map Editor


Recommended Posts

OK, I have fixed the script to work on Windows Servers. It was a file reading error, checked it over quite a bit, and did some extensive testing on my Windows test server. Everything appears to be working. Theres still a problem with throwing warnings when trying to delete a marker, but other then that I have removed nearly all of the warnings and errors it throws.

http://www.mtabeta.com/index.php?p=reso ... ils&id=110

Version 1.1

Yes XML might be easier but I'm still a complete newb at scripting. I'm amazed I got this script working at all. I may invest into XML loading and saving for the next version.

Thanks Xeta for all the support! Hope this version works better for you! :)

Link to comment

Yyeeaaa it works PERFECT!!

its all so nice now! the saving time is away, no lagging, no extrem CPU occupancy rate, the map saves good now, i can load maps, all working perfect ans smoothly 8)

Thanks Xeta for all the support!

no, i thank you so mutch, for give a perfect Support!

Link to comment

Updated, made stuff a little bit smoother, upped the object limit, and added 2 new functions with the created objects.

mtascreen0020rx7.th.jpg

http://www.mtabeta.com/index.php?p=reso ... ils&id=110

New in 1.2

/mclone x y z rx ry rz - Clones currently selected object with the distance you specify (if no values given, will be created in the same spot)

/mstack num x y z rx ry rz - Clones currently selected object the specified ammount of times, with the specified distance away from the original

Link to comment

Yeah I will make a new version of the saving and loading at some point. Just trying to get all the functions and everything working for now. You can use delux map converter (Link) for to convert to MTA:DM Map Format until I update it, then just save it as a new file that loads in the meta.

I just updated it again to fix mstack's object limit also, I was trying to do a stack function and it kept failing and I didn't know why, it was because I was trying to do more then 25 stacks, I upped it to 50, and made it tell you if you try to do over 50 so you can find out why it isn't working.

Edit: Updated again to include a /minfo feature to get the map info of the item your currently editing, giving you model number, position, and rotation.

Link to comment

Bump: Updated to include an /mloop feature thats kinda hard to use but if you figure out how to do it it works good for making anything into a loop.

Also, made it admin only. You do /guestb name to guest someone and let them able to build. They cannot use /mclear /loadmap /savemap, that is only for permanent builders, and admins. Permanent builders are set in the offedit.lua file under the if/then statement for on player join, and on resource start, if you want to add someone, put it in there.

New in 1.4

/mloop pieces radius width rotaxis loops rotation - Makes a loop with currently selected piece. Example: /mloop 50 30 20 -y - If you use this with an object ID of 18450 (flat road) it makes a loop out of 50 pieces, the loops radius is 30, diameter 60, and from the first piece to the last there is a gap of 20 units, the object rotation axis for a 18450 is -y, if it is not set as that the loop will not be made right. This is a more advanced command, and takes a lot of trial and error to get correct.

/guestb name - Guest someone with a building pass. Gives them the ability to build, but not to loadmap, mclear, and savemap. To do that put their name in offedit.lua.

Link: http://www.mtabeta.com/index.php?p=reso ... ils&id=110

Link to comment
  • 1 month later...

nice, but now we use a other metode to give permissions: we have a Forum-area and the users want to build, need to post their account-username in a new thread (accounts can be make with /register USERNAME PASSWORD). then we go to the resourcemanager and add their usernames in a new-maked offEdit group :D and when anybody make crap with the editor, we remove the them from the group.

easy, isnt it? :D

but i have found some very strange bugs:

when i move a object in another object, there will be disappeared without a trace*

sometimes the object a rotating a little bit when i make /oy 1 or /ox 1 etc.

sometimes the objects a rotating forward when i make /rz -1, only when i make /rz -10 the object rotate backward!

sometimes the object is very laggy when i rotating it

*but the most worst bug is: when i move a object in another object, there will be disappeared without a trace

i am realy wondering about this bugs, on my home server (windows XP) it works perfect, but on our server (win server 2003) we have this bugs

i don´t tested the new version, because we give now permision with the resourcemanager, and i find it pleasanter :wink:

do you know what the problem is? are you interested to see it yourself on our server? then send me a PM pleas

//EDIT: i found the problem: my DSL is to slow :) i have DSL 2000, and i get this problems sometimes. other users with DSL 6000 don´t have any problems with this editor :D

Thanks.

//edit2: A bumb button?! :o sorry my mistake. I don´t wanted to press it.... My mouse made it itself, i wanted to open a tab in the windows taskbar and pressed the button :oops:

Link to comment
  • 1 month later...
"You do not have permission to build" Why i cant build?

Learn to read a bit before posting.

Permanent builders are set in the offedit.lua file under the if/then statement for on player join, and on resource start, if you want to add someone, put it in there.

You have to be an admin or permanent builder in order to use it.

Link to comment
Im having a prob i want to Map But I dont got the permissions What Do i have to do now?

Do you get paid for spamming? Read before you post.

"You do not have permission to build" Why i cant build?

Learn to read a bit before posting.

Permanent builders are set in the offedit.lua file under the if/then statement for on player join, and on resource start, if you want to add someone, put it in there.

You have to be an admin or permanent builder in order to use it.

Link to comment

wasup my niga offroader, Ive been using your editor for a long time now I love it.

I am the one and only Dr.PhillyBlunt and I am not afraid to raise the great hand and fall down on a haters face
Mr. Philly here can be called the great pwner. Next week Im gonna go into kentucky and take fort knox with a phukn sling shot :)
Link to comment
  • 4 months later...

Hi all, i know this thread is rreeaallyy old, but i have a problem with a little modification.

Currently i try´s to modify the editor a little bit, i want to save the Nickname and Account Name from the object creators in the map file.

But i´m only able to save the Nickname and Account name from the user, wo have SAVES the MAP FILE, with /savemap

I modifies this (see line 11 and 12, its new):

  
function saveThisMap ( player, cmd, mapname ) 
    if mapname then 
        local madeFile = fileCreate("" ..mapname.. ".o23")                -- attempt to create a new file             
        fileWrite(madeFile, "--File Generated with OffRoader23's In-Game MTA DatchMatch Map Editor! \r\n \r\n") 
        for i=0,maxobjects do 
            if objectid[i] then 
                local model = getObjectModel (objectid[i]) 
                local x, y, z = getElementPosition(objectid[i]) 
                local rx, ry, rz = getObjectRotation(objectid[i]) 
                local creator = getClientName ( player ) 
                local creatorUser = getAccountName ( getClientAccount ( player )  ) 
                fileWrite (madeFile, "objectid[" ..i.. "] [user: " .. creatorUser .. " ] [Nick: " .. creator .. " ] = createObject(" .. model .. ", " .. x .. ", " .. y .. ", " .. z .. ", " .. rx .. ", " .. ry .. ", " .. rz .. ") \r\n") 
            end 
        end 
        outputChatBox ( "Map saved as: " ..mapname.. "", player ) 
        fileClose ( madeFile ) 
    else 
        outputChatBox ( "No map name specified.  Please use /savemap <name>", player ) 
    end 
end 
addCommandHandler( "savemap", saveThisMap ) 
  

but - i think you can see it - this saves only the Player Name and Account Name from the person who has writen /savemap.

But i want to save every single object along with the creator names, so it looks like this:

objectid[0] [user: SomeGuy ] [Nick: FireMan ] = createObject(2000, 2045.3319091797, 1057.2769775391, 10.785163879395, 90, 0, 49)

objectid[1] [user: Smiley ] [Nick: Smiley ] = createObject(5000, 2047.2116699219, 1053.2243554688, 9.758836746216, 0, 0, 0)

Can anybody help me pleas :(

Link to comment
objectid[0] [user: SomeGuy ] [Nick: FireMan ] = createObject(2000, 2045.3319091797, 1057.2769775391, 10.785163879395, 90, 0, 49)

objectid[1] [user: Smiley ] [Nick: Smiley ] = createObject(5000, 2047.2116699219, 1053.2243554688, 9.758836746216, 0, 0, 0)

Won't work for as far as I know.

objectid[0] ["User: SomeGuy"] ["Nick: FireMan"] = createObject(2000, 2045.3319091797, 1057.2769775391, 10.785163879395, 90, 0, 49)

objectid[1] ["User: Smiley"] ["Nick: Smiley"] = createObject(5000, 2047.2116699219, 1053.2243554688, 9.758836746216, 0, 0, 0)

Probably will.

But what's the exact problem?

Link to comment

What?

objectid[0] [user: SomeGuy ] [Nick: FireMan ] = createObject(2000, 2045.3319091797, 1057.2769775391, 10.785163879395, 90, 0, 49)

Work´s! (Its a exact copy from my map file)

I already scripted it, but the Problem is, that the script writes the SAME Username and Nickname on every object - because it gets the Username and Nickname with the function to let /savemap working.

Its difficult to explain, but, for example, when there three users who build a little bit around with the editor, and i saves it, there is writen my username and nickname on EVERY object - because i typed /savemap

But i want to saves the usernames and nicknames for every single object, and not for the final user who saves the map.

Link to comment

I doesn´t know what do you mean exacly.

But the idea is good, i tried it, but it doesn´t work.

I added the element data to the function that gets fired with /msave, and loaded them in the /savemap function to get and save the player account-name in the file.

setElementData (line 15, 16, 17 are new):

  
  
function saveObjID ( player, cmd ) 
    if playerobj[player] then 
        for i=0,maxobjects do 
            if objectid[i] == playerobj[player] then  
                if marker[player] then destroyElement(marker[player]) end 
                local numstr = tostring(i) 
                outputChatBox ( "Object saved as ID: " ..numstr.. "", player ) 
                playerobj[player] = nil 
                break 
            elseif objectid[i] then  
            --do nothing 
            else 
                creator = player 
                creatorUser = getAccountName ( getClientAccount ( player )  ) 
                setElementData ( creator, creatorUser, true ) 
                objectid[i] = playerobj[player] 
                if marker[player] then destroyElement(marker[player]) end 
                local numstr = tostring(i) 
                outputChatBox ( "Object saved as ID: " ..numstr.. "", player ) 
                playerobj[player] = nil 
                break 
            end 
        end 
    else 
        outputChatBox ( "No object selected to be saved.", player ) 
    end 
end 
addCommandHandler( "msave", saveObjID ) 
  
  

getElementData (line 12 are new, 13 are modified):

  
  
function saveThisMap ( player, cmd, mapname ) 
    if mapname then 
        local madeFile = fileCreate("" ..mapname.. ".o23")                -- attempt to create a new file             
        fileWrite(madeFile, "--File Generated with OffRoader23's In-Game MTA DatchMatch Map Editor! \r\n \r\n") 
        for i=0,maxobjects do 
            if objectid[i] then 
                local model = getObjectModel (objectid[i]) 
                local x, y, z = getElementPosition(objectid[i]) 
                local rx, ry, rz = getObjectRotation(objectid[i]) 
                local creatorUserLoad = getElementData ( creator, creatorUser ) 
                fileWrite (madeFile, "objectid[" ..i.. "] [user: " .. creatorUserLoad .. " ] = createObject(" .. model .. ", " .. x .. ", " .. y .. ", " .. z .. ", " .. rx .. ", " .. ry .. ", " .. rz .. ") \r\n") 
            end 
        end 
        outputChatBox ( "Map saved as: " ..mapname.. "", player ) 
        fileClose ( madeFile ) 
    else 
        outputChatBox ( "No map name specified.  Please use /savemap <name>", player ) 
    end 
end 
addCommandHandler( "savemap", saveThisMap ) 
  
  

And i get this error:

http://d.imagehost.org/view/0604/error.png

I don´t want to upload the complete script on pastebin, because its not my script and i don´t know what OffRoader23 would think about it, so, just download the map-editor (I´m using version 1.3.0) when anybody want to see the whole script.

Possible other users are interesting in this idea too (to save the nickname and username)?

Link to comment

The setElementData should be set when the object is created. So you set the user/nick name to the object. Like:

setElementData( theObject, "creatorNick", creatorNickHere) 
setElementData( theObject, "creatorUser", creatorUserHere) 

So during saving or... Saving the map or something... You should use getElementData to call this back again. The problem with your script right now is that you are setting element data to true, so in outputChatBox, it'll give an error unless you do tostring(). But creator "true" would seem a little weird. :P

Link to comment

Hi :)

I tested it now.

Unfortunately, it doesn´t work too.

setElementData works, but, not realy.

/msave function:

  
function saveObjID ( player, cmd ) 
    if playerobj[player] then 
        for i=0,maxobjects do 
            if objectid[i] == playerobj[player] then  
                if marker[player] then destroyElement(marker[player]) end 
                local numstr = tostring(i) 
                outputChatBox ( "Object saved as ID: " ..numstr.. "", player ) 
                playerobj[player] = nil 
                break 
            elseif objectid[i] then  
            --do nothing 
            else 
                creator = player 
                creatorNick = getClientName ( player ) 
                creatorUser = getAccountName ( getClientAccount ( player )  ) 
                setElementData ( creator, "creatorUserSave", creatorUser ) 
                setElementData ( creator, "creatorNickSave", creatorNick ) 
                objectid[i] = playerobj[player] 
                if marker[player] then destroyElement(marker[player]) end 
                local numstr = tostring(i) 
                outputChatBox ( "Object saved as ID: " ..numstr.. "", player ) 
                playerobj[player] = nil 
                break 
            end 
        end 
    else 
        outputChatBox ( "No object selected to be saved.", player ) 
    end 
end 
addCommandHandler( "msave", saveObjID ) 
  

/savemap function:

  
function saveThisMap ( player, cmd, mapname ) 
    if mapname then 
        local madeFile = fileCreate("" ..mapname.. ".o23")                -- attempt to create a new file             
        fileWrite(madeFile, "--File Generated with OffRoader23's In-Game MTA DatchMatch Map Editor! \r\n \r\n") 
        for i=0,maxobjects do 
            if objectid[i] then 
                local model = getObjectModel (objectid[i]) 
                local x, y, z = getElementPosition(objectid[i]) 
                local rx, ry, rz = getObjectRotation(objectid[i]) 
                local creatorUserLoad = getElementData ( creator, "creatorUserSave" ) 
                local creatorNickLoad = getElementData ( creator, "creatorNickSave" ) 
                fileWrite (madeFile, "objectid[" ..i.. "] [user: " .. creatorUserLoad .. " ] [Nick: " .. creatorNickLoad .. " ] = createObject(" .. model .. ", " .. x .. ", " .. y .. ", " .. z .. ", " .. rx .. ", " .. ry .. ", " .. rz .. ") \r\n") 
            end 
        end 
        outputChatBox ( "Map saved as: " ..mapname.. "", player ) 
        fileClose ( madeFile ) 
    else 
        outputChatBox ( "No map name specified.  Please use /savemap <name>", player ) 
    end 
end 
addCommandHandler( "savemap", saveThisMap ) 
  

It saves all objects under the same player: The player who finaly saves the map.

So it looks like this:

--File Generated with OffRoader23's In-Game MTA DatchMatch Map Editor!

objectid[0] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(5000, 2047.9760742188, 1556.8345947266, 11.671875, 0, 0, 0)

objectid[1] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(978, 2050.9030761719, 1559.8597412109, 9.671875, 0, 0, 0)

objectid[2] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(1391, 2052.4416503906, 1568.8868408203, 9.671875, 0, 0, 0)

objectid[3] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(1502, 2050.552734375, 1561.6640625, 9.671875, 0, 0, 0)

objectid[4] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(1782, 2053.1984863281, 1560.9890136719, 9.671875, 0, 0, 0)

objectid[5] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(9134, 2056.2658691406, 1502.4489746094, 13.671875, 0, 0, 0)

Three objects are not created by me, but i saved the map using /savemap - and now stands my name on all objects

Any ideas pleas?

Link to comment

Oh yea, it WORKS! :D I thank you 50p and Gamesnert (you says it also)

Now, my map file looks like this (original copy):

objectid[0] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(2414, 2131.0314941406, 2137.0732421875, 9.671875, 0, 0, 0)

objectid[1] [user: test ] [Nick: dude ] = createObject(2000, 2136.3942871094, 2142.1547851563, 10.726048469543, 0, 0, 0)

objectid[2] [user: test ] [Nick: dude ] = createObject(4014, 2139.7043457031, 2139.876953125, 19.671875, 0, 0, 0)

objectid[3] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(9491, 2192.2116699219, 2143.3637695313, 9.671875, 0, 0, 0)

Now, i have a last problem, /loadmap doesn´t work.

When i write /loadmap, i get this two warnings and one error:

[20:35:28] WARNING: offedit.lua: Bad ´element´ pointer @ ´destroyElement´(1) - Line: 357

[20:35:28] WARNING: offedit.lua: Bad ´element´ pointer @ ´destroyElement´(1) - Line: 361

[20:35:28] ERROR: ...Server/mods/deathmatch/resources/offedit/offedit.lua:336: attempt to call a nil value

Note: I think the two warnings are not so serious, because there are at the original offedit release too! But the ERROR are the problem.

And here´s the function /loadmap:

  
function loadMapLua ( player, cmd, mapname ) 
    if mapname then 
        local mFile = fileOpen(""..mapname..".o23")   
        if mFile then    
            clearObjects (player) 
            objectid = nil 
            objectid = {} 
            outputChatBox ( "Map loaded: " ..mapname.. "", player )  --output success 
            local buffer                                -- temporary the whola lua file 
            local filessize = fileGetSize (mFile)       --get file size 
            buffer = fileRead(mFile, filessize)         -- read the file length 
            loadstring(buffer)()                        --load lua to string 
            fileClose(mFile)         -- close the file once we're done with it 
        else --if no such map 
            outputChatBox ( "Map " ..mapname.. " failed to load.  Perhaps it doesn't exist?", player ) --output fail 
        end  
    else 
        outputChatBox ( "No map name specified.  Please use /loadmap <name>", player ) 
    end 
end 
addCommandHandler( "loadmap", loadMapLua ) 
  

The ERROR line (336) are:

     loadstring(buffer)()   --load lua to string 

To be honest, i doesn´t know whats wrong with loadstring(buffer) :lol: Pleas help me :)

Link to comment

Any help pleas?

I get a error when i try to load the map:

[20:35:28] ERROR: ...Server/mods/deathmatch/resources/offedit/offedit.lua:336: attempt to call a nil value

But why?

should the script not just ignore the nickname and username letters?

Pleas help me! its my last problem i think

Link to comment
loadstring(buffer)()   --load lua to string 

What's the () doing behind (buffer)? =/ (I have it too in my offedit resource, but just wondering)

Anything else than that isn't really something I can't see... There must be something wrong over there though I guess... =/

Link to comment

loadstring() returns a functions and using () you call it to execute the string.

You could do something like this:

  
local executeCode = loadstring( "print( 'hello world' )" ) 
-------- 
executeCode() -- this will print "hello world" 
  

Link to comment

I wonder if it's loadstring, will the

objectid[0] [user: XetaQuake ] [Nick: [GP_A]XetaQuake ] = createObject(2414, 2131.0314941406, 2137.0732421875, 9.671875, 0, 0, 0)  

need user: XetaQuake defined before? and nick: gp_a...

Maybe it should work with

objectid[0]["User: XetaQuake"]["Nick: [GP_A]XetaQuake" ] = createObject(2414, 2131.0314941406, 2137.0732421875, 9.671875, 0, 0, 0)  

And with defining the tables before too..

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...