Jump to content

Jusonex

Retired Staff
  • Posts

    507
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Jusonex

  1. It's a function that calculates the rotation you need to point to a specified position. Transferred to your code: local car = createVehicle ( 0, 0, 0 ) local arrow = createObject ( the_arrow_id, 0, 0, 0 ) addEventHandler ( "onClientPreRender", root, function ( ) local cx, cy, cz = getElementPosition ( car ) local x, y, z = getElementPosition ( localPlayer ) local rotH = findRotation ( cx, cy, x, y ) - 90 local rotV = math.deg(math.asin((cz - z) / getDistanceBetweenPoints3D(cx, cy, cz, x, y, z))) setElementPosition ( arrow, x, y, z + 1 ) setElementRotation ( arrow, 0, 90 + rotV, rotH ) end )
  2. function GPS:update() local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then self:stopNavigation() return end local x, y, z = getElementPosition(vehicle) local horizontalRotation = findRotation(x, y, self.m_Destination.X, self.m_Destination.Y) - 90 local verticalRotation = math.deg(math.asin((self.m_Destination.Z - z) / getDistanceBetweenPoints3D(self.m_Destination.X, self.m_Destination.Y, self.m_Destination.Z, x, y, z))) setElementPosition(self.m_Arrow, x, y, z + 1) setElementRotation(self.m_Arrow, 0, 90 + verticalRotation, horizontalRotation) end
  3. First, you've to learn a lot of stuff such as the IA-32/x86 architecture and (compiler generated) assembly, windows internals and programming in general. Reversing is mainly projecting an other programmer's thoughts. That means that you have to transfer compiler generated assembly code into C(++)-code (although there's a Pseudo-code generator plugin for IDA). After you learned x86, it's time to get IDA Pro Advanced - a disassembler with lots of capabilities and tools. Some pages and book tips: http://tuts4you.com/ http://blog.0xbadc0de.be/archives/67 http://www.amazon.com/Reversing-Secrets ... =Reversing
  4. That's because you're calling setElementPosition clientside. If you want the objects to be synced, you'll have to tell the other clients the current position of the object you're moving (--> triggerServerEvent). But it's not recommendable to do this every frame since that would lead to a huge amount of network traffic. Instead you can sync the position every 2 seconds for example. addEvent("onObjectCreated", true) addEventHandler("onObjectCreated", root, function(value) object = value addEventHandler ( "onClientRender", root, moveObjectUpOrDown ) setTimer( function() local x, y, z = getElementPosition(object) triggerServerEvent("positionSync", object, x, y, z) end, 2000, 0 ) end) Server: addEvent("positionSync", true) addEventHandler("positionSync", root, function(x, y, z) setElementPosition(source, x, y, z) end ) Attention: Due to security issues, you should check whether the player is allowed to set the position. Otherwise this event could be abused to teleport all elements.
  5. You should not use triggerClientEvent since it almost blocks network activity. If you want to transfer a lot of data, you should use triggerLatentClientEvent instead. Example: local content = fileRead(file, fileGetSize(file)) -- if you wanna open huge files, use a smaller buffer instead to save memory triggerLatentClientEvent(source, "runmod", root, content)
  6. You can use onClientObjectDamage as well as onClientObjectBreak to prevent the fuel station from exploding (in case of you're working with MTA elements).
  7. You can't save elements via setAccountData. If you want to save the team, you'll have to find another solution such as saving the team name + using getTeamFromName later. EDIT: addEventHandler("onPlayerQuit", root, function() local acc = getPlayerAccount(source) setAccountData(acc, "team", getTeamName(getPlayerTeam(source))) setAccountData(acc, "skin", getElementModel(source)) end ) addEventHandler("onPlayerLogin", root, function(oldAccount, newAccount) setElementModel(source, getAccountData(newAccount, "skin")) local teamName = getAccountData(newAccount, "team") local team = getTeamFromName(teamName) or createTeam(teamName) -- get existing team if exists or create a new one setPlayerTeam(source, team) end ) (Untested)
  8. The particle functions are not that flexible. If you want to use objects like in SA:MP, some guy did a nice work here: https://community.multitheftauto.com/index.php?p ... ls&id=1292
  9. Well, you're trying to call triggerClientEvent from the client, but triggerClientEvent exists only on the server. If the event you want to trigger is on the same side, you can use triggerEvent
  10. "statsData" seems to be wrong somehow. That might happen if the the account data is not set. First, you should try to ensure that it is really the missing account data: outputChatBox(tostring(getAccountData(account, "weaponStats")))
  11. Jusonex

    Shop

    GUIEditor.window[2] = guiCreateWindow(527, 227, 409, 336, "Shop ", true) The relative argument is set to true which means that your window will be created somewhere far away. Change it to false and everything will work fine
  12. Jusonex

    Not working

    triggerClientEvent always returns a boolean value (true if the event was triggered successfully, false otherwise). If you want to retrieve the passcode from the client, the client has to trigger the value back to the server. But it would make more sense to trigger the passcode only from the client to the server to save 1 triggered event like you do it already. triggerServerEvent("checkcode",getRootElement(),getLocalPlayer(), thecode) ==> The second parameter contains the passcode function verify (player, passcode) if passcode == "A4F8G0T1D5XP5" then givePlayerMoney(source, 100) else outputChatBox("No!", source, 255, 0, 0, true) end end addEvent("checkcode",true) addEventHandler("checkcode",getRootElement(),verify) Edit: Furthermore 'source' (in the scope of the verify function) contains the root element, not the player. If you want to output the message to the client who triggered the event, you can also use the global variable 'client' (behaves similar to source) or, as an alternative, you can pass localPlayer instead of "getRootElement()" to your triggerServerEvent call (but due to security issues it's better to use client).
  13. What is the value of your host variable (DBHost), where do you run the MySQL Server (on localhost or an external server) and which OS are you using?
  14. Jusonex

    Color save

    You can't receive several returns from getAccountData. getAccountData returns always a string. Thus, the first version is almost correct. If you take a look at the wiki page, you'll find that the non-rgb version requires each of the four available vehicle colors: bool setVehicleColor ( vehicle theVehicle, int color1, int color2, int color3, int color4 ) ==> Line 20 of the first version should look like this: setVehicleColor ( veh, color, 0, 0, 0 )
  15. Due to backwards compatibility, the password hash is a bit more complex. The first 64 characters contain the SHA256 hash, followed by one character representing the hash type (old/new version) and finally the 32-chars salt. I wrote the following function some time ago: function checkPassword(dbPassword, inputPassword) local hash = dbPassword:sub(0, 64) local type = dbPassword:sub(65, 65) local salt = dbPassword:sub(-32) if not (hash and type and salt) then return false end if type == "1" then -- Old version return sha256(salt..md5(inputPassword))..type..salt == dbPassword elseif type == "0" then -- New version return sha256(salt..inputPassword)..type..salt == dbPassword end return false end By the way: Encryption != hashing
  16. After some tests, we decided to move to GitHub now. You can find the new repository here: https://github.com/OpenMTADayZ/open_dayz
  17. The development progress is a bit slow at the moment since our previous graphic designer terminated his work (due to missing time). To make the next, huge step, we need a new designer who is able to produce a basic GUI design for now. This mainly includes elements such as windows, edits, lists, buttons and so on. If you are really interested and trustworthy, you can contact us via IRC: http://chat.mibbit.com/?channel=%23open ... gtanet.com (or, as an alternative, via PM).
  18. We had problems with GitHub some time ago (especially merging leads often to needless conflicts), why we decided to use SVN and GoogleCode instead of Git/GitHub. GoogleCode doesn't mean that you can't contribute. If you would like to contribute you just have to submit a source patch at our Mantis Bugtracker which can be found here: http://www.open-dayz.tk/mantis/my_view_page.php It's pretty simple. Feel free to join our IRC channel: Connect
  19. We've decided to release the source code a bit earlier than we planned originally. There are still a lot of things, especially gameplay elements to be done, but the backends (database, transfering data etc.) are mostly complete. However the gamemode is currently not yet in a playable state. Our next focus will be the creation of the GUI forms once we have our finished design. You can find the source code and some additional information here: http://code.google.com/p/open-dayz/
  20. Maybe some of you are disappointed by the fact that the current MTA:DayZ gamemode offers barely any possibilities of modifications or extensions to create an unique server feeling due to the proprietary nature of the script. The result is obvious - hundreds of servers with the very same script and feeling without anything to make a specific server more enjoyable than the others. We believe that a DayZ gamemode in MTA has a lot more potential to offer players a more unique feeling and more enjoyable servers. Goal: The project’s main goal is an open sourced MTA:DayZ gamemode which provides a very detailed interface so that you are able to customize the gamemode in any direction you can think of. Additionally, the gamemode’s features are planned to be close to the original ArmA II Mod ‘DayZ’, though we have to differ in some parts. Development process: For now we plan to develop the gamemode in a private and small group (to avoid thousands of weird questions related to the unfinished state). As soon as the gamemode takes shape, the project will become open-source. But that does not mean that you cannot do anything to support the development process. Everyone with special knowledge is welcome to join us. If you have got a great idea and would like to share it, we will be happy if we meet you in our forum (URL: see below). Concept: The general concept is - of course - to create a DayZ gamemode as close as possible to the ArmA II Mod. But the way how we implement features, and also additional features aren’t set in stone and we want the community to participate in the process of giving the developers more input on what the community would enjoy. Everyone is encouraged to present his ideas to the public by posting in our forum for an open discussion of the feature and a possible implementation. Current Progress: We already began developing the gamemode and have made big progress. Most backend systems, such as SQLite and MySQL integration and a custom Zombie AI are finished. The biggest we have to do now is adding actual gameplay content and the design of the gamemode. More help is always welcome, be it by scripting, creating graphics or just telling us your very own ideas on how you’d want a DayZ gamemode in MTA to be. Conclusion: If you have any questions related to the project, we’ll be happy to answer them in our IRC channel or, of course, our forum. We’re especially looking for someone who is able to produce a nice GUI design. For more details, please join our IRC channel. IRC: irc.gtanet.com #open_dayz - Connect now Forum URL: http://www.opendayz.tk/forum/ (disabled at the moment) GitHub: https://github.com/OpenMTADayZ/open_dayz Best regards Your Open MTA:DayZ team
  21. @Arran: If you want to implement encryption algorithms, you'll need bitwise operators in 99 percent of all cases. Another good example are flags. If you'd like to conjunct one or more vehicle handling flags "live", you'll need to use a bitwise (X)OR. Even though these functions are not really fast and a bit "pseudo-like", you have the ability to implement those things.
  22. krischkros, the purpose of a compiler isn't protection.
  23. You're right, my fail (selected wrong hex-view window). But that's not the problem. If you want to override all the stuff, just override these lea instruction, too. (See code snippet below) The installation of the hook isn't the problem, if the size is higher than or equal to 5. The problem is the expression fTest = 0.5f. In assembly fTest = 0.5 looks like the following: fld [address] // Load value from the given address to the floating point register st0 fst(p) [destinationAddress] // Copies the value in st0 to the given address That's because we can't copy between addresses directly. That means that the previous expression changes the value in st0. The solution is pushing all relevant registers to the stack and "pop" them back after execution of your code. The instructions pushad and popad push/pop all general cpu registers to the stack. The following works for me. #define HOOKPOS_CAutomobile_ProcessWheel_Size 0x6AA666 DWORD RETURN_CAutomobile_ProcessWheel_Size = 0x6AA66D; void HOOK_CAutomobile_ProcessWheel_Size(); void CMultiplayerSA::InitHooks() { ... HookInstall ( HOOKPOS_CAutomobile_ProcessWheel_Size, (DWORD)HOOK_CAutomobile_ProcessWheel_Size, 7 ); ... } float fTest; void _declspec(naked) HOOK_CAutomobile_ProcessWheel_Size() { _asm pushad fTest = 0.5f; _asm popad _asm { // f3 push fTest // f2 push fTest // f1 push fTest // Execute overriden instruction(s) lea ecx, [esp+0F8h-0A4h] // Jump back to continue the normal control flow jmp RETURN_CAutomobile_ProcessWheel_Size } }
  24. The minimal size you have to pass to HookInstall is 5 (the jmp opcode has 5 bytes). But push has only 2 bytes. In that case you could use a size of 6 bytes to hook/override all these pushs. To find the length of an opcode and its arguments out, just click in IDA on the instruction you want to hook and select the assigned Hex-View. Finally the amount of selected blocks/bytes is the size of the opcode.
×
×
  • Create New...