-
Posts
1,031 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Bonsai
-
Yeah, thats this --env.all functions... I didn't write them all down here since I deleted that try after it didn't work.
-
Nope, still not working. But its okay, gsub works fine.
-
Hmm, its not working. Same error. I'm using mapname = string.gsub(mapname, "-", "") now. That gets it done. Should have sticked to mysql Thanks anyway.
-
Not working: executeSQLQuery("CREATE TABLE IF NOT EXISTS '["..mapname.."]' (playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT)") executeSQLQuery("INSERT INTO '["..map.."]' (playerName, playerSerial, timeMS, timeText, dataRecorded, extra) VALUES(?,?,?,?,?,?)", playerName, playerSerial, timeMS, timeText, dataRecorded, extra ) Working: executeSQLQuery("CREATE TABLE IF NOT EXISTS 'abc' (playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT)") executeSQLQuery("INSERT INTO 'abc' (playerName, playerSerial, timeMS, timeText, dataRecorded, extra) VALUES(?,?,?,?,?,?)", playerName, playerSerial, timeMS, timeText, dataRecorded, extra )
-
Yeah, thats what I do. Just the table name depends on the current map name. And it turned out, that brackets do not work with map name... again
-
executeSQLQuery('INSERT INTO " '..map..' " ... That's working fine as long as I take only letters as table name. I also tried "bb-bb" and it didn't work again. So the problem is this "-", but shouldn't it still work with quotes? EDIT: I think I got it! Brackets! "[bb-bb]" worked! Thanks!
-
Hey, I was just trying to create map name tables to save some map data. But it doesn't work. The map names contain a lot of different symbols. So I'm using double quotes around the tables name, but it still doesn't work. Example: mapname: race-portdog executeSQLQuery('CREATE TABLE IF NOT EXISTS " 'mapname' " ... It's shown in the SQL Browser, but that + Symbol is missing and I can't insert any data. I tried some random tables names like "bbbb" and it works fine. Do I have to filter the names first? Bonsai
-
Use a table. vehicle = {} vehicle[x] = veh They will be saved like this: vehicle[1] = veh1 vehicle[2] = veh2
-
As I said, I'm doing it just like u did in your example, but with some script not only one command. local env = {} --env.all functions... function loadScript(file, dim) dimension = dim local file = fileOpen(file) local content = fileRead(file, fileGetSize(file)) local loaded = loadstring(content) setfenv(loaded, env) pcall(loaded) end _addEventHandler("onLoadScript", root, loadScript)
-
function loadScript(file, dim) dimension = dim local file = fileOpen(file) local content = fileRead(file, fileGetSize(file)) local loaded = loadstring(content) pcall(loaded) end _addEventHandler("onLoadScript", root, loadScript)
-
Okay, thanks for that. I'm loading a complete script by loadstring. Everything works fine. Wrapper do their job etc. But when I put setfenv on my loadstring it outputs an error. "bad argument #1 to setfenv (number expected, got nil)" Simple functions like in your example work fine. But a script does not.
-
This seems to be the hardest part when making wrappers. Its easy to destroy created elements or set back world functions to normal, but getting rid of set variables is complicated. Easiest way seems to be just to restart the wrapper resource, but it turned out restart takes too long so its not up again when server side scripts ask for execution. PS: When I want to remove an EventHandler, but the attached Element doesn't exist anymore at that time, could I just use root? Or isn't it necesssary to remove that handler at all?
-
Yeah, that works. But thats not suitable for loading complete scripts sadly.
-
Whats your question?! You overwrite the Staff team in line 2.
-
local env = {} local func = loadstring(data) setfenv(func, env) pcall(func) It tells me "bad argument #1 to setfenv (number expected, got nil)"
-
Don't I need setfenv to get that done?
-
It didn't work for me. Don't know if I did it right. Is there a way to get rid of variables without restarting the resource? Bonsai
-
Checking if something happened in timer and then disabling
Bonsai replied to Pigfoot_Nosebeggar's topic in Scripting
Actually you should be able to kill a timer in the function he was calling, but I've never tested that. What about a timer that is only executed once starting a function that checks your stuff, if its false it starts another timer doing the same, until its finally true, or killed if it takes too long. -
Something is not working well with this way of loading code. I get an error if my script looks e.g. like: grav1 = createMarker ( 5595.1923828125, -1091.1322021484, 91.135231018066 , "corona" , 7, 0, 0, 0, 0) addEventHandler( "onClientMarkerHit", grav1, markerHit2) It says element attached to Handler is nil... EDIT: Nevermind, I've found the problem. Thanks anyway.
-
Okay, I tested yours and it works... My code did pretty much look like that, don't know why it wasn't working. Anyway, now I can finally get started. Thank you.
-
https://wiki.multitheftauto.com/wiki/Call Try another way to call it.
-
https://wiki.multitheftauto.com/wiki/OutputChatBox Required Arguments text: The text string that you wish to send to the chat window. If more than 128 characters it will not be showed in chat. Optional Arguments NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments. visibleTo: This specifies who the chat is visible to. Any players in this element will see the chat message. See visibility. r: The amount of red in the color of the text. Default value is 231. g: The amount of green in the color of the text. Default value is 217. b: The amount of blue in the color of the text. Default value is 176. [b]colorCoded: A boolean value determining whether or not '#RRGGBB' tags should be used.[/b]
-
I had this problem before. Happens when there is only 1 compatible gamemode map.
-
Hey Peeps, I did a lot of research before, but I didn't find any good answer to my question. When I'm loading a script file by loadstring, where do I put my wrapper functions? It obviously does not work to just have them in the same resource. Do I have to edit the loaded script string before executing? Bonsai
-
Try table.concat. The args gotta be ... e.g. function test(...) as far as I remember.