Jump to content

The_GTA

Helpers
  • Posts

    822
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by The_GTA

  1. You have omitted the line number and script filename from the error message. In the script excerpt there is no call to a global variable called "client". Could you please paste the entire error message? Best is a screenshot. I know it is annoying but you are making my life hard if you are leaving information out.
  2. Yes, replace the script as you have written down. Don't worry. I wanted to make you aware how important it is to think about oneself. You have asked the right question. I will help you finish this script.
  3. Fix the server script this way: addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); --- Your way of creating these errors is peculiar. Who even told you to use the onPlayerResourceStart event this way? Did somebody else teach you this? Please ask before you use new things that you do not understand. Scripting is not wizardry. Also, I do not like the way you just copy paste the code without thinking how to generalize it. For instance, you should not have created 4 copies of the exactly same event handler because one could do all of the tasks. I hope you will learn the way of code sharing in the future. I cannot teach you this because it takes spirit on your side to want to improve yourself which is not easy. Also you might have a longer path before yourself. Please mind yourself that this forum is about scripting help related to small questions as hints, not about creating the entire resource for you. Hopefully you understand and try to collect your mind on this issue. What have I showed you that you can already learn from? Take a breath, don't feel overburdened. This is a lot for the beginning but I hope you actually have learned something that sticks.
  4. You're welcome! Take it by heart if you face such problems in the future. It is important actually take effort in life, at least in things that you truly care about.
  5. Look at this post above: https://forum.multitheftauto.com/topic/132730-error-loading-script-failed-car_controlpanel03/?do=findComment&comment=1002018
  6. I have started the resource on my local 21002 server and it has started fine. Are you sure that you have given me the correct server version number? Either lemehost is not being honest to you or you have mixed up some information.
  7. Google Drive has made me request access permissions for your file. You need to accept my request. Look into your Google Drive account/your E-Mail box.
  8. For maintainability reasons related to DRM you cannot do that. But since the resource belongs 100% to you, please upload the .ZIP file somewhere and give me the URL to it. You need to find an upload location outside of the MTA forums.
  9. Thank you. If the server version that you sent me is correct, then the error message is contradicting the version string of the server. This is very odd and could be a MTA issue. I want to perform local tests on the resource myself. Can you send me the resource in a .ZIP archive so I can run it on my computer? I will be able to further help you after local testing. Please include meta.xml and all script files.
  10. I am confused. You are using a very recent MTA server. Could you show me the exact message that the server is giving you? You've not told me all the details because I know what type of message you are referring to. Also, you should show me the contents of your meta.xml file. Look at this post for a fix to make the GUI non-visible using F10 if you are outside a vehicle. To force it into non-visible state, you have to call the guiackapa function with false as first argument, like this: guiackapa( false ) Use the function inside your login panel script to make any GUI non-visible that should not be visible while your login panel is. For example, force the vehicle UI non-visible each time you set the login UI as visible. Glad to be of help!
  11. Judging from the code above, you are once again using one global variable that would be overwritten multiple times in an event handler, called "chicken". I hope you will not do that again and instead store such things in lists instead. You have not yet fixed the pickup issue that I mentioned as point number 3. Other than that, happy to see you scripting around. ?
  12. Go into your MTA server console and type in "ver". I don't know how lemehost exposes the server to you so please give me your feedback. Inside the MTA server console you should see the MTA version of the running server. Copy that text and post it here so I can check about scripting incompatibility. Here is the fixed script excerpt. You wrongfully used the client event variable in a command handler. Please do not mix functions as both command and event handlers. Use shims for interop, like this: -- Switch Engine -- function switchEngine ( player ) local vehicle = getPedOccupiedVehicle ( player ) -- Check if the player is in any vehicle and if he is the driver if vehicle and getVehicleController ( vehicle ) == player then local state = getVehicleEngineState ( vehicle ) setVehicleEngineState ( vehicle, not state ) end end addCommandHandler ( "switchengine", function( player ) switchEngine(player) end ) addEvent("switchEngine", true) addEventHandler("switchEngine", root, function() switchEngine(client); end )
  13. Wow, that is a long time ago! I am happy to see you come back to MTA scripting. It sure is fun ?
  14. Glad to be of help to you, my friend! MTA can be a complicated mess because of hidden pitfalls like events not triggering even though they should have. That is why it is important to come ask for support inside our forums. You are doing the right thing. Also nice to hear about some family work being done inside MTA ?
  15. I don't know what error you are talking about. The script is working fine. I have even quickly tested it on my server because you doubted it. It could be that there is a mistake in how you "pasted" the code into your own code. Have you replaced the old code with the new code? Have you removed the old code? Please post your entire script with my script inserted into it (HINT: use the <> forum editor button to paste Lua formatted code). I am looking into some issues related to onClientVehicleExit event handler and it may be unreliable in connection with scripted vehicle ejections. Here is patch for the F10 keybind to at least hide the GUI if it is visible for too long: bindKey("F10","down", function() -- Only allow switching GUI visibility if the local player is inside any vehicle. if (getPedOccupiedVehicle(localPlayer)) and not (gui_is_visible) then guiackapa( true ) elseif (gui_is_visible) then guiackapa( false ) end end ) Sorry about this inconvenience.
  16. local gui_is_visible = false; function guiackapa (set_vis) if gui_is_visible and not set_vis then guiSetVisible ( GUIEditor.window[1], false ) guiSetVisible ( GUIEditor.window[2], false ) guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) elseif not gui_is_visible and set_vis then guiSetVisible ( GUIEditor.window[1], true) guiSetVisible ( GUIEditor.window[2], true) guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end gui_is_visible = set_vis; end bindKey("F10","down", function() -- Only allow switching GUI visibility if the local player is inside any vehicle. if (getPedOccupiedVehicle(localPlayer)) then guiackapa( not gui_is_visible ) end end ) addEventHandler("onClientVehicleExit", root, function(exitor) -- Turn of the GUI if the player has left a vehicle. if (exitor == localPlayer) then guiackapa(false); end end ); -- CLIENT function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01) -- SERVER function changeSeat01 ( ) thePed = client -- client is the player who triggered the serverside event/did the request theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 0 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) Please take a look at how to combine code that is redundant efficiently into shared functions. It could help minimize your code and reduce the risks of bugs. You're welcome! Besides not knowing how to format your posts properly, you are a friendly person. I like that. Friendliness does go a long way, you know? ? For exposition purposes I will leave out synchronization of data for players that join the server after setting windows open or closed. That will be an exercise for yourself. I will also leave out any serverside protective checks (is the player really inside a vehicle, known by the server?). But to get a quick idea let's change it for all players that currently play on the server. Clientside: -- OLD function open() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 4, not isVehicleWindowOpen( playerVehicle, 4 ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open", open) addEvent("open", true) addEventHandler( "open", localPlayer, open ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open ) -- NEW local function open_event(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request() triggerServerEvent("onVehicleWindowOpenRequest", root, seatWindows[0]); end addCommandHandler("open", open_request) addEvent("open", true) addEventHandler( "open", localPlayer, open_event ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request ) Serverside: -- OLD addEventHandler("onPlayerResourceStart", root, function () function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end) -- NEW addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); You should adjust the code templates that you have already made with the code I have given you.
  17. Hello Heshan_Shalinda_eUnlock! This is actually quite easy to tell. You forgot to tell Lua that you are trying to define an anonymous closure! An anonymous closure is a function without a name that is returned as value by the syntax operation. Every Lua code that should form an anonymous closure has to be enclosed by an anonymous function signature and an end tag, for example: function (p1, p2, p3) outputDebugString("anonymous closure!") end You can fix your code excerpt this way: ------ trigger Client Events ------ function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) I hope this helps you! Come back to me if you have any further problems related to your script. ? EDIT: fixed some stuff I was caught off-guard.
  18. Hello kewizzle! it looks like there are multiple issues with your script. I don't know why but you are using an inconsistent scripting style. At one point you either are using local variables and at the other you are not. Please refresh yourself on coding best practices! in lines 34, 35 and 36 you are storing data in global variables x, y, z, dropped and dropMarker that is being overwritten each time the createDeathPickup function is called. I suggest you to use local variables for storage instead. change the way the HitPick function is defined. You could use the source event variable instead of the dropped global variable to cancel the event. Making it depend on the global variable dropped is a bad idea because it does change each call to createDeathPickup. Imagine what happens if there are multiple death pickups at once: if the last created one gets destroyed then your event handler stops working! If you are hitting multiple pickups in a short time-interval then only one of the pickups would be stored in the element-data variable "pickup". The player has to leave the pickup marker and re-enter it in order to pickup another thing it is supposedly standing on. This could be annoying to the players. I recommend you to instead use a list of pickups that the player is nearby of. I suppose that the usePickup function is not able to be triggered twice to get health, guns, etc from the same pickup. You should clean-up the marker after the pickup was taken because it would otherwise still collide with pickups that can be taken. The result is an invisible pickup that prevents the other pickups from being taken. Just like the issues above this could prevent your script from working properly. Suggestions to further improve the script: make use of the onMarkerLeave function to clear the list of nearby pickups of the pickup that the player is nearby. Proposed fixes for 1, 2 and 4: outputServerLog ( "***Drop System Loaded ***" ) local state = {} local deathpickups = {}; local function bindState(player) bindKey(player, "l", "down", function(player) local dropped = getElementData(player,"pickup"); if isElement(dropped) then local pickupInfo = deathpickups[dropped]; usePickup(dropped,player) killTimer(pickupInfo.dtimer); destroyElement(pickupInfo.dropped); destroyElement(pickupInfo.dropmarker); removeElementData(player, "pickup") deathpickups[dropped] = nil; end end) end function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then local x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z local dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) local dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onPickupHit", dropped, HitPick) addEventHandler("onMarkerHit", dropmarker, function(player) if isElement(player) and getElementType(player) == 'player' then setElementData(player,"pickup",dropped) end end) local dtimer = setTimer(function() if (getElementData(player, "pickup") == dropped) then setElementData(player, "pickup", nil); end destroyElement(dropped); destroyElement(dropmarker); deathpickups[dropped] = nil; end, 15000, 1) local info = {}; info.dtimer = dtimer; info.dropped = dropped; info.dropmarker = dropmarker; deathpickups[dropped] = info; end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup) function HitPick ( ) -- you don't have to check the source parameter if you just plan to check if it is an element. cancelEvent() end
  19. The_GTA

    row

    Can you show what you have scripted so far? You say that you have no idea but we could tell you if you made a good attempt anyway or what is missing from your current approach.
  20. The_GTA

    FPS mta

    you didn't do anything (it takes a special situation to get me to answer this way)
  21. Hello pixel77! Times are moving on and technology is becoming more robust. With the constant improvement of technology over time come more thorough requirements for developers to specify data in their code. It looks like MySQL does not want to assume implicit default values for table fields by default anymore which I think is fine. I recommend you to either modify the SQL table definitions to provide default field values where there are not or to always specify the field values in INSERT statements that have no default values. Otherwise you may risk further incompatibilities with future MySQL versions due to technological progress.
  22. The_GTA

    row

    If you have performed a SELECT with an ORDER BY condition then you can depend on the order of the returned rows. By using dbPoll or dbQuery you can obtain an indexed table of returned rows. If you loop over the rows by index, you can execute code that depends on the index. By using a Lua if-condition that depends on the loop index you can execute different code depending on the row index. Does that make sense to you?
  23. No, it does not suck. YouTube is doing this to 1) advance their app agenda and 2) force people back to their website. It makes perfect sense from a business perspective. They are known to do this because they have attacked the myTube! Windows 10 app multiple times by API changes. If you want to give them the benefit of the doubt then you can blame the instability of web technologies in general. But now you understand why they are really good at their agenda and not "suck".
  24. I am happy to have contributed to this amazing MTA 1.5.9 release! Not only has the stability of the mod been improved (based on my contribution). By introducing strong model-related engine functions, MTA is providing the opportunity for content creators in general to make their multiplayer ideas come true. I have always been dreaming about this and thank you very much for that! On a side note I do appreciate the introduction of SVG clientside functions. It could be useful to power-users like me who wish to bundle many draw-calls into one from either external tools of a serverside thing. Cool new addition!
×
×
  • Create New...