Jump to content

arezu

Members
  • Posts

    446
  • Joined

  • Last visited

Everything posted by arezu

  1. The server side script does load before triggering client event, it's just that outputChatBox server side seems to have lower priority than triggerClientEvent or something so triggerClientEvent is processed before outputChatBox. So you dont have to worry about it.
  2. Water cant be created outside the gta map, but objects can be placed; until around 7000 in any direction, then the objects start behaving weird and there is no sync there.
  3. arezu

    Money hack

    With custom d3d9 file, you can do this kind of hack (by triggering server events from clientside). You can prevent people with custom d3d9 from joining your server, or have a list with allowed d3d9 versions (look on wiki for the functions). But there still are ways to inject hack into MTA even if you dont allow custom d3d9..
  4. Why would you want to do this? Anyways, an environment refers to a table from which variables are read from when using variables, and written to when saving variables. So an empty environment refers to an environment where there are no variables to start with. local code = [[put your code here, or load from file or whatever]] local env = {} --env._G = env -- use only if you have variables to put in env at start, so that _G.varName can be used if there is a need for it local func = loadstring(code) setfenv(func, env) pcall(func) This website has very good examples and explanations on how to use certain functions in lua: http://www.gammon.com.au/scripts/doc.php?lua=setfenv
  5. how are you triggering "showStation" ? did you try debugscript 3 command to see if there was error? and keep in mind not all songs have title in the sound data.
  6. You are overriding waitDisplay, waitText1, waitText2, waitText3 and waitText4 everytime, so if a player joins and another player joins before the previous player has finished downloading, then the player that joined previously wont have his text destroyed. A table should've been used, but in this case, there is no need to create new text items and display for each player. local waitDisplay = textCreateDisplay() local waitText = {} waitText[1] = --textCreateTextItem(blablabla) waitText[2] = --textCreateTextItem(blablabla) waitText[3] = --textCreateTextItem(blablabla) waitText[4] = --textCreateTextItem(blablabla) for k, v in ipairs(waitText) do textDisplayAddText(waitDisplay, v) end addEventHandler("onPlayerJoin", root, function() showChat(source, false) textDisplayAddObserver(waitDisplay, source) end) addEvent("onClientReady", true) addEventHandler("onClientReady", root, function() textDisplayRemoveObserver(waitDisplay, source) end) Also, Use outputDebugString to see the flow of your script, so you can see if an event was really triggered or not.
  7. You can get past that and make it work by creating another function that calls that, but you shouldn't do that because metamethods are not copied. If you dont know what metamethods are, then in other words it just means that it wont work. It's better if you copy the library or download it from the forum here and use it in your other resource instead.
  8. like beatles1 said, servers can already be used to send "bad" files to client, so would it really be that bad to not put a restriction?
  9. You cant return a value in such a way, since it takes time for the server to receive the data and to send it back, and that would mean you would have to freeze the client and wait for answer. The solution is to use triggerClientEvent server sided in the event that you trigged to trigger back to client. -- Client sided: addEvent("onReceiveVIPData", true) addEventHandler("onReceiveVIPData", resourceRoot, function(isVIP) -- You are a VIP if isVIP is true end) triggerServerEvent("checkIfPlayerIsVIP", resourceRoot) -- Server sided: addEvent("checkIfPlayerIsVIP", true) addEventHandler("checkIfPlayerIsVIP", resourceRoot, function() -- 'client' variable is set by mta to the player that triggered the event from client-side local accName = getAccountName(getPlayerAccount(client)) local isVIP = false if isObjectInACLGroup("user.".. accName, aclGetGroup("VIP")) then isVIP = true end triggerClientEvent(client, "onReceiveVIPData", resourceRoot, isVIP) end) But a better solution here would be to use onPlayerLogin and setElementData to the player as VIP, or maybe even set the players team to VIP team.
  10. arezu

    Shutdown

    Why not use "shutdown" command instead?
  11. Why dont you guys read MIKI785's comment? You have to multiply the nitro level with a high value if you want to display it graphically (try to multiply by 100 or something).
  12. arezu

    loadstring

    If you are only sending your own code to the player and loading it, then you don't need a sandbox. Anyways if you want to know, what you wrote is not enough, setmetatable is also needed, but you can read on how to do that somewhere else as there are already good tutorials for that (and i've also answered on how to do it properly on mta forum previously, so you can use search).
  13. arezu

    loadstring

    You got it wrong, saving to harddrive or not doesn't matter, it's the fact that you are loading scripts from a map that is not made by you. Using a sandbox will prevent the script from calling functions that you dont want it to be able to call.
  14. arezu

    loadstring

    If you are using loadstring to load script from maps, then a player can add a script to their map which calls any function and ruin your server and steal maps (and possibly server-side scripts as well).
  15. arezu

    loadstring

    I assume he wants to unload the whole code loaded with the string; and why would there be any reason to only "unload" some parts of it? Also it is better to use pcall if you want to have the same affect as mta's script loader, like there are hundreds of maps that try to call a misspelled function (SetCloudsEnabled), and mta script loader ignores that and makes other scripts in the map work, and that is only possible with pcall. Yes, that is the right way. It is recommended to use a "sandbox", but you can add later.
  16. arezu

    loadstring

    This is what I do: local func = loadstring("function thisFunction() end") pcall(func) -- and then later when I want to unload... func = nil
  17. Not exactly all functions are synced, it would be good to have a list of functions that sync though.. MTA already uses a timer to sync with server, so it shouldn't matter if you spam them onClientRender.
  18. Client-side functions setElementPosition, setElementRotation, setElementVelocity and setVehicleTurnVelocity (and a few more functions) automatically sync with server if the element was created server sided.
  19. That will change the value of the local instance, it wont create a global variable. Here is how the scope works in lua: a = 2 -- Access to this variable is possible anywhere from all files in this resource local b = 2 -- local variable, but global for this file, meaning that everything defined in this file has access -- to this variable -- function 'test' behaves like the variable 'a', all files in this resource have access to it function test() end -- function 'test2' behaves like the variable 'b', only this file have access to it local function test2() end function scope() local c = 0 -- Everything defined inside this function has access to this variable d = 0 -- Global variable, behaves like like the variable 'b'. Dont do this.. will only cause bugs. local b = 3 -- Creates a new local variable, the variable 'b' on line 2 still exists but just not -- in this function when writing 'b' if(c == 0)then c = 3 -- Changes the variable 'c' that was defined on line 16 b = 4 -- Changes the value of the variable 'b' defined on line 18 _G["b"] = 7 -- _G is a table with all global variables, and you can get access to global variables instead -- of variables defined here by using it by doing -- _G.variableName or _G["variableName"] -- On line 23, the value of the variable defined on line 2 is changed to 7 end -- Variable 'c' declared on line 16, and varible 'b' declared on line 18 are both -- removed from lua here (and may right away be removed from memory) end
  20. If you read the code, you can clearly see it has a variable to change the threshold: local UPSIDE_DOWN_THRESHOLD = math.cos(math.rad(20)) Set a higher value like 80 and try again.
  21. Depending on the content in which you want to use this, you could find other solutions. If you write what you are trying to do, then maybe we can find another solution.
  22. http://www.extremetech.com/extreme/1731 ... puters-cpu
×
×
  • Create New...