Jump to content

[REL] In-Game Map Editor


Recommended Posts

Script inspired by Mabakos SA-MP 0.2 medit script

Made by OffRoader23

197.png

Pic: I created an object 5002 and moved it up into the sky, it attaches an arrow so you know what your editing.

In-Game Map Editor - Commands

/mcreate - Creates object with specified model number

/msave - Saves object into script, and gives you that objects script ID

/mdestroy - Destroy currently selected object

/msel - Select object saved into script by objects script ID

/mclear - Clear all objects made with the map editor

/ox - Move object on X axis

/oy - Move object on Y axis

/oz - Move object on Z axis

/rx - Rotate object on X axis

/ry - Rotate object on Y axis

/rz - Rotate object on Z axis

/savemap - Save all current items into script folder with specified name

/loadmap - Load map from script folder with specified name

/saveobj - Saves currently selected object to objects.txt with description and creator

Download

It saves the maps into the offedit folder on your server as mapname.o23 and they just open up with notepad, and have the lua code inside with the object ID, and location. You can use the deLux map converter if you want to turn them into a .map file, or just copy/paste them into your lua script on resource start to add the objects into your server. To clear out /mclear usually works, if you use /saveobj it doesn't save the object to the table so /mclear will not clear it. Then you will just need to restart the offedit script.

I'm working now on an admin only version where you can give people guest building passes and without that only admins can build it. If anyone wants that one I'll release it once its completed.

Any other questions just post in here and I will answer them. Please report any bugs here also, or on the resource download page.

  • Like 1
Link to comment

Very nice!

i have tested it very long, and found 2 bugs and i have 2 desires :)

Bug 1: when i create a object, dont save them with /msave and create a new object, i cant select the old model again _AND!_ the object dont remove with /mclear :!:

Bug 2: i cant load the "map", i save them with /savemap [NAME], but when i clear all or restart the server and when i load the saved map with /loadmap [NAME] the objects dont spawn, or i dont see them.

Desire 1: when i save the map, all working very slowly and laggy for a moment, can you mending them?

Desire 2: the console becomes spammed with many errors and warnings, can you pleas try to mending them?

here a the errors and warnings from Desire 2:

  
[15:59:58] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 204 
[15:59:58] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 205 
[15:59:58] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:186: attempt to call a nil value 
[16:00:34] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:177: attempt to concatenate local 'mapname' (a nil value) 
[16:00:41] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 204 
[16:00:41] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 205 
[16:00:41] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:186: attempt to call a nil value 
[16:00:45] ERROR: fileOpen; unable to load file 
[16:01:20] WARNING: Bad model id passed to createObject 
[16:01:20] WARNING: offedit.lua: Bad argument @ 'attachElementToElement' - Line: 14 
[16:01:25] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:01:25] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:01:30] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:01:30] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:01:35] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:01:35] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:01:42] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:01:42] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:01:47] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:01:47] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:01:54] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 25 
[16:01:54] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:26: attempt to perform arithmetic on local 'x' (a boolean value) 
[16:02:03] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 69 
[16:02:09] WARNING: Bad model id passed to createObject 
[16:02:09] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 12 
[16:02:09] WARNING: offedit.lua: Bad argument @ 'attachElementToElement' - Line: 14 
[16:02:15] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:02:15] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:02:19] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:02:19] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:02:23] WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 69 
[16:02:33] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 12 
[16:06:16] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 12 
[16:06:52] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 120 
[16:07:28] WARNING: offedit.lua: Bad 'element' pointer @ 'getElementPosition'(1) - Line: 119 
[16:07:28] WARNING: offedit.lua: Bad argument @ 'createMarker' - Line: 121 
[16:07:28] WARNING: offedit.lua: Bad argument @ 'attachElementToElement' - Line: 122 
[16:08:27] WARNING: Bad model id passed to createObject 
[16:08:27] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 12 
[16:08:27] WARNING: offedit.lua: Bad argument @ 'attachElementToElement' - Line: 14 
[16:08:32] WARNING: offedit.lua: Bad argument @ 'getElementPosition' - Line: 19 
[16:08:32] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:20: attempt to perform arithmetic on local 'z' (a nil value) 
[16:09:46] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 120 
[16:10:42] ERROR: ERROR: Infinite/too long execution (offedit) 
[16:10:42] ERROR: Aborting; infinite running script 
[16:11:03] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 204 
[16:11:13] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 204 
[16:11:13] WARNING: offedit.lua: Bad 'element' pointer @ 'destroyElement'(1) - Line: 205 
[16:11:13] WARNING: offedit.lua: Bad 'number' pointer @ 'fileRead'(2) - Line: 185 
[16:11:13] ERROR: ...er/mods/deathmatch/resourcecache/offedit/offedit.lua:186: bad argument #1 to 'loadstring' (string expected, got nil) 
  

I'm working now on an admin only version where you can give people guest building passes and without that only admins can build it. If anyone wants that one I'll release it once its completed.

Yea pleas release a admin-version :) this editor rocks!

Link to comment

Yeah I know /saveobj doesn't put the object into the table, I can rewrite that so it does.

You'll need to give me an example of when /loadmap doesn't load the map. I have tested it many times and it has worked all the times I did it. Just don't use the /saveobj function for now because those objects are not saveable or loadable.

In theory yes it can take a while to make a map but once you learn the commands it gets a lot easier and quicker, and you can make sure your object is VERY precise. Also yes, hidden credits rock :D but /ox /oy /oz aren't made with o for that reason, thats just o for object.

I'll look at some of the warning, I believe I know how to fix most of them, just have to do a lot more error checking.

I may have a way to speed up the object saving, it works fine in my server, it just depends on the processor speed of the server because it runs the function 500 times. If you wanted to speed it up you can open the offedit.lua and change maxobjects to like 50-100, and then it will cut down the time by 1/5th, because it wont have to run the save function 500 times, only 100, or whatever you set it to.

I gotta go to work right now but when I get home I will work on getting saveobj to save it into the /msel table, and that will fix not being able to select it, and not being able to clear it. Make sure you /msave your object before you /savemap, and like I said just don't use saveobj, I guess until the next release.

Link to comment

yea thanks for support :)

here is a list, how i build a map and save it:

1. starting gamemode, the editor is in a in the gamemode (in mtaserver.conf It also does not work)

2. spawning a object like /mcreate 5002

3. moves the object a little bit with /oz /oy /ox and /rz /ry /rx

4. saves the object with /msave

5. saves the map with /savemap [NAME]

6. load the map with /loadmap [NAME]

and then, nothing happens and i get errors (posting in the last post)

i dont know what i make wrong, grr i need this editor :D:?:wink:

its a windows server

btw, I am glad to see next releases :D

Link to comment

Something to try -

Unzip the resource to a folder named offedit, put the offedit folder in your resources folder and delete the offedit.zip or rename it to something else. I think it can't load the files unless the lua is in the same folder as the saved files, which if it's a zip it doesn't work.

Link to comment

offedit is allready unziped and i have a offedit folder in the resource folder :?

////EDIT:

i think i know what the problem is:

when i save the map with a object but forgot to place the object correctly with /msave, i get a chattext "Map saved..."

but when i load this map, i see no object. yes that is right, because i dont have place the object correctly because i forgot /msave

BUT! when i place a object, and saves the object with /msave, and after that i save the map, i get this error in the console:

  
[00:13:28] ERROR: ERROR: Infinite/too long execution (offedit) 
[00:13:28] ERROR: Aborting; infinite running script 
  

i think that is the problem, because the map dont save correct.

(i hope you can understand what i mean, i am a little bit under stress at this time :wink: )

Link to comment

Well I'm not sure what the problem might be. I will have to look at the script when I get home because it worked great in all my testing on my server. I get off work in 2 hours and then will be able to error check everything to avoid the errors and warning and also will check into the script and see if i can reproduce any of your problems. Can you post an example of a file you saved with /savemap name, I mean, of what's in the file? Make sure you aren't using /saveobj, JUST /msave and /savemap name.

Sorry to anyone having problems with this script it seems to work fine on my server. :?

Edit: OK, I did a bunch of error checking in the script and looked it over. Now when you /savemap your JUST doing /savemap name, not /savemap name.o23 ? and same with /loadmap just /loadmap name NOT /loadmap name.o23 ?

I tried this again, restarted the script, deleted my map, and recreated a map, and it still worked just fine. I don't know why yours wouldn't be working. I updated the version in my post to 1.0.1, it fixes error checking and shouldn't spam the script as much with errors/warnings. Also, I turned down the max objects so it should cause less lag when saving/loading scripts.

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

Please tell me if this update helps you any, and post any error/warning logs as to what it's still sending.

Link to comment

hi OffRoader23

i thank you so mutch that you try to help me!

the new version is nice, some bugs a away and the spamming is a little bit lesser

Now when you /savemap your JUST doing /savemap name, not /savemap name.o23 ? and same with /loadmap just /loadmap name NOT /loadmap name.o23 ?

yea i write every time /savemap NAME and /loadmap NAME, i dont write NAME.o23

Make sure you aren't using /saveobj, JUST /msave and /savemap name

yea i dont use /saveobj, i only use , /msel, /savemap NAME and /loadmap NAME

but the save bug is not away :cry:

i have made a little movie that shows you all, pleas look it:

http://www.eatlime.com/download.lc?sid= ... 2D07C535DF

mirror: http://rapidshare.com/files/103117410/m ... .divx.html

and here is the map "TEST" from the movie:

http://www.eatlime.com/download.lc?sid= ... B0925156B5

mirror: http://rapidshare.com/files/103115039/TEST.o23.html

Link to comment
I see your problem. You have to use /mcreate 5002, move it to where you want, then /msave. Then use /savemap name.

i have it use, first mcreate than msave and than savemap, in the movie i use this way too :wink:

the two warnings:

  
WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 83 
WARNING: offedit.lua: Bad argument @ 'destroyElement' - Line: 84 
  

Link to comment

hi

OK, can you do a video where you /mcreate 5002 then /msave then /savemap name then /loadmap name ?

have you see the movie? in the movie a made exactly these four steps :)

just play it a little bit slower or so, the movie runs very fast

and have you test my map file? i think the map is damaged, you can see why i think it in the movie ;)

here a the links again:

Movie:

http://www.eatlime.com/download.lc?sid= ... 2D07C535DF

mirror: http://rapidshare.com/files/103117410/m ... .divx.html

Map:

http://www.eatlime.com/download.lc?sid= ... B0925156B5

mirror: http://rapidshare.com/files/103115039/TEST.o23.html

Edited by Guest
Link to comment

Well I haven't done any testing on a Windows server, which may possibly be the problem. I will do some more testing now, but like I said that video says /msel but you can't /msel when you haven't /msave.

The movie you did /msel not /msave like I had said. This may be causing your problem.

Link to comment

OH! nono, i have use /msave, but i have made a mistake on the movie editing and write /msel with the white font! :wink::D

a little question: have you try to load my "TEST" map on your server? i think the script dont save the map because i get this strange error: (to see on the movie too)

  
[01:04:06] ERROR: ERROR: Infinite/too long execution (offedit) 
[01:04:06] ERROR: Aborting; infinite running script 
  

and the map file shows very crap, there is only the credits and many spaces!

Just download the map (you find them on page 1) and open it, than you see it yourself ;)

i think the saving of the map takes to long, and was aborting!!

Link to comment

Lol... I don't have ICQ, only Xfire, MSN, and Google Talk.

It appears to NOT work in Windows server at all? I'm going to change some stuff and see exactly why...works perfect in my Linux server though. Will check on this when I get back from eating in about an hour. Thanks for the heads up about this, I didn't realize it would make a difference.

Link to comment

hehe, and i have not Xfire, MSN and google talk :D i only have ICQ and a old account on skype

but when you want to connect on my test server, i can send you the IP and PW with PM and you say me a time to starting the server

i hope you can fix this bug, and i hope this bug is not only by me :wink:

but i have made all totally correct i think, i dont have made any mistakes :D

Link to comment

That error occurs when you run a loop and don't break it. Lua seems to be able to process about 130,000 loops before it comes up with that error (tested on Windows version).

I haven't seen the code for this, but the easiest way would be to 'break', the loop once you've achieved the outcome you wanted.

example:

  
local players = getElementsByType ( "player" ) 
for key, playerdata in ipairs(players) do 
     local sourcePlayerName = getClientName( playerdata  ) 
     if ( sourcePlayerName == "Me" ) then 
           break 
     end 
end 

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...