anumaz
Members-
Posts
60 -
Joined
-
Last visited
Everything posted by anumaz
-
Two ways. First way is making a table of allowed characters and then returning an error if your string contains a character not listed in that tab. Second way is with string.match and string.find with patterns. The patterns are: . --- (a dot) represents all characters. %a --- all letters. %c --- all control characters. %d --- all digits. %l --- all lowercase letters. %p --- all punctuation characters. %s --- all space characters. %u --- all uppercase letters. %w --- all alphanumeric characters. %x --- all hexadecimal digits. %z --- the character with hex representation 0x00 (null). %% --- a single '%' character. %1 --- captured pattern 1. %2 --- captured pattern 2 (and so on). %f[s] transition from not in set 's' to in set 's'. %b() balanced nested pair ( ... ( ... ) ... )
-
Pretty sure there's an argument in your .map file, you could add: dimension="2" if you want it in dim 2.. etc.
-
or actually, totally forgot about a function https://wiki.multitheftauto.com/wiki/GetRandomPlayer local players = getElementsByType ( "player" ) -- get all players connected local thirdpart = math.floor(#players / 3) -- get 1/3 count of those players local i = 1 while i <= thirdpart do local random = getRandomPlayer() setElementData(random, string, data) i = i + 1 end
-
local players = getElementsByType ( "player" ) -- get all players connected local thirdpart = math.floor(#players / 3) -- get 1/3 count of those players -- you could use many other loop method, I'd probably use this one though local i = 1 while i <= thirdpart do local value = math.random(0, #players ) -- generates a random value between "0" and the amount of players if isElement(players[value]) then setElementData(players[value], string, data) i = i + 1 end end EDIT: Edited my post, totally forgot you wanted it to be random.
-
When do you want to cancel it/how do you want it to trigger? The event name is cancelEvent
-
Making memo editable for certain people and saving it
anumaz replied to scaryface87's topic in Scripting
Doubt it'll work. Didn't test it, but you events don't return anything and the way you did it, it does not matter if he's acl admin or not. You need another event going from server to client again. -
Making memo editable for certain people and saving it
anumaz replied to scaryface87's topic in Scripting
Do you want it to save even if you restart the resource/server? -
You need to use isElementAttached() with the object you put on the forklift. It'll return either true or false if it's attached. It won't detach automaticly. You need to use https://wiki.multitheftauto.com/wiki/DetachElements
-
the lazy way would probably be something like. there's probably a better way though. just trying to help you from top of my head local countdown = 120 local label = guiCreateLabel(pos, tostring(countdown), parent of) setTimer(function () countdown = countdown - 1 if countdown >= 0 then guiSetText(label, tostring(countdown)) else --you've reached 0! end end, 120000, 1000) but you could work around getTimerDetails to get the timeRemaining (in ms) - 1000 to get into seconds
-
Salut, Installe http://www.microsoft.com/download/en/de ... px?id=5582 as-tu essayé la dernière version de mta?
-
Have you even tried it out? Is this server side or client side. How are you triggering the createPickup function (asd)? Other than that, yes, it is working.
-
You need to define the pick up and then trigger the hit or leave with an event: function asd () local x, y, z = getElementPosition(localPlayer) local element = createPickup(x+2, y+2, z, 0, 20) addEventHandler("onClientPickupHit", element, function () --your stuff here end) end asd() It works both client and server side (onClientPickupHit or OnPickupHit) Sorry for indent, TAB doesnt work https://wiki.multitheftauto.com/wiki/OnClientPickupHit
-
Have you enabled OOP in your meta.xml file? true
-
Perhaps if they want to manage how maps are loaded by themselves, rather than it being automatic with the .map file
-
In another file, in the map's files?
-
Hi, if you use the function removeWorldModel on a specific object and that object also has a LowLOD object, it won't be automaticly removed. You'd have to use removeWorldModel on the lowLOD object as well. Although, with this map manager I'm making, people simply paste the .map files content in a memo gui, which is then transfered to removeWorldModel or createObject. Though, those .map files don't have several removeWorldModel lines for LowLOD objects. Is there a way to automaticly detect it, and possibly delete it when removed? Thanks
-
Please submit it to https://community.multitheftauto.com/
-
I'd personally build my table like; local theTable = { --["vehicleid"] = {x, y, z, amountOfCash} ["122"] = {500, 200, 20.2, 5000}, ["119"] = {230, 600, 13.5, 4500} } and trigger the cash reward when client triggers the colshape: https://wiki.multitheftauto.com/wiki/CreateColSquare https://wiki.multitheftauto.com/wiki/On ... olShapeHit
-
Hi, I've been trying to find a way to automaticly detect LowLOD objects and thus removing them for a map manager that I'm making. Although, if you removeWorldObject something, you may encounter lowLOD objects underneath them. My question is - how would you automaticly detect if there's a lowLOD object associated to the object you want to removeWorldObject, and if so, remove it as well. I have thought of a possible attempt being getElementModel( getLowLODElement ( element theElement )) But I'd need an element to put as a variable there. I only have the object ID, not the element itself... hence the question in thread title. I need assistance! Thanks
-
Date: 17/09/2014 Author: Anthony '.tree'/anumaz Dupont Topic: Caching your resource to avoid multi SQL queries Special thanks for helping out: cat, whoever made the mysql resource I am using, CourtezBoi Chapters A. Identifying the need for caching and what should be cached B. Visual Method C. Scripting Method A. Identifying the need for caching and what should be cached You will probably need caching if your resource contains a lot of data which changes infrequently, but has to be shown/displayed frequently.. An example of this would most likely be a vehicle system or even an account panel, where data is requested often by the client. What you want to identify is that 'data send' from a server-side sql request being transfered to client. Having a lot of that leads to important technical issues and delay with your server, hence reducing its performance. If your resource corresponds to that, then you most likely will want caching. You won't want to cache every data of your resource. Doing that would simply result in making a double-weighted resource which you want to avoid for file size's sake. B. Visual Method Typically, cache is used when showing data, not updating. Hence, every time the client requests to show data, you'll want to use the cache. Although, every time the client requests to update data, you'll want to directly do that in the database. It is however logical to always use the cache to update, and then export your cache to your database when the resource stop, simply not typical. First, at your resource start, you will load your table(s) with an sql update query. Secondly, you will want to use that table when a user requests to see data. Keep in mind to also update that table every time a change is made. On the third step, you will want to clear your cache when your resource is stopped. C. Scripting Method First step: Loading your data. -- s_cache shall be added server type in your meta.xml -- On top of your s_cache script, you'll want to create all tables you will want to cache. table = { } addEventHandler("onResourceStart", resourceRoot, function () local sql_table = exports.mysql:query_fetch_assoc("SELECT * FROM table_name") for k, v in pairs(sql_table) do table[k] = v end end) Second step: Updating your database and cache, or using cache to show. -- To show your cache table, you'll want to go the simple way. Example below, presuming your table is like this below, which is my username with some data. local cacheTable = { [".tree"] = "any data", ["anumaz"] = "other data" } addCommandHandler("mydata", function (player) local username = getPlayerName(player) if cacheTable[username] then -- To check if it exists outputChatBox(cacheTable[username], player) -- Presuming it is a single data, and it's a string end end) To update data, you will want to update via the sql query and also to add it to the cache table. A common error is refreshing the cache table every time something is modified to it. Don't even think about it! function updateData(key, data) if exports.mysql:query_free("UPDATE table_name SET column_name='"..data.."' WHERE key='"..exports.mysql:escape_string(key).."'") then cacheTable[key] = data return true else return outputDebugString("SQL error at updateData function"), false end end Third step: Normally, when you stop resource, it should delete everything contained in it. You can also, at the same time, make a 'refresh cache' command. addCommandHandler("refreshcache", function () cacheTable = { } -- Clears the table local sql_table = exports.mysql:query("SELECT * FROM table_name") while true do local v = exports.mysql:fetch_assoc(sql_table) if not v then break end -- We'll assume the first column in the table is called 'username' and returns a string. Second column is called 'data' and contains all we need. cacheTable[v.username] = v.data end exports.mysql:free_result(sql_table) end) A practical example is available on my gist at https://gist.github.com/tree-/8f97a42d7834c258069f
-
That's a good suggestion, however, that wouldn't follow GTA physics just like a normal trailer.
-
Adding the possibility of creating hitch points for vehicles/trailers. This feature exists for the Utility Truck, which has attached a Utility Trailer. However, if creating hitch points to any vehicle could be done, that'd be sick. Something like createHitchPoint(vehelement, offX, offY, offZ)
-
Not too sure on how to use this. Any help, anyone?
-
It outputs 'Missing the team'... I did: crun for k, v in ipairs ( getPlayersInTeam ( getTeamFromName( "Los Santos Fire Department" ) ) ) do outputChatBox ( "Hello", v ) end And it returns Hello... it's weird.
