Jump to content

ReZurrecti0n

Members
  • Posts

    123
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by ReZurrecti0n

  1. Using setPedCameraRotation on a player will not work, it is meant for peds only... You can point the camera at a X, Y, Z position using the same setCameraTarget function instead of a Element Target, but that must be done Client Side. Therefore, you could call a Client Event and then set the Camera's Target using the X,Y,Z Method
  2. https://wiki.multitheftauto.com/wiki/Main_Page Client Functions, Client Events, Server Functions, Server Events (Visiting just these 4 sections on the Wiki will greatly help you as it lists all those Functions as well as Events too) The console is something very different than the chatbox, personally, I don't have much experience with that console window as I never use it though
  3. triggerClientEvent(hitElement, "bankaGuiAc", hitElement) -- This seems to be what triggers the Bank So, just make your own /Bank command and then trigger it with the above line. Make whatever adjustments needed of course
  4. You must use the onClientRender() Event to show any dx. Then use If Statements to determine if it should be shown on screen. Could use the onResourceStart() Event to turn on a variable to use with the If Statement, then set a timer to turn off the variable. Either way, there are many ways to do this, but remember this all should be done clientside of course
  5. function createSomeVehicle(player, command) -- I believe the player and command arguments are passed automatically when it comes to the Command Handler local x, y, z = getElementPosition(player) -- Because we don't need the x, y or z variables after this function, should make those variables local createVehicle(400, x, y, z) end addCommandHandler("createveh", createSomeVehicle) However, I did not spot anything wrong with the code you posted, it should have worked as far as I can tell. May seem silly, but are you certain your player name was in fact "Xeno" at the time of using the command? Also, if there are any missing thens or ends, that will stop a script from even loading up. Missing ( )s, accidentally using a . when it should be a , etc etc etc getElementPosition(Element) - You need the player element, NOT a player name: He was just getting the player element from the player name "Xeno"
  6. https://wiki.multitheftauto.com/wiki/IsPedReloadingWeapon ?
  7. getPedWeapon: https://wiki.multitheftauto.com/wiki/GetPedWeapon
  8. I believe it is good practice to nil any variable that is no longer in use, just like using local variables where ever possible. Every penny counts and although one penny alone is nothing, eventually it builds up to greater amounts. But yes, as far as affecting performance, it's exactly as IIYAMA said here
  9. If it is working while not on any team, but then breaking while on a team, then it must be your scripts. I would start with tracking down what triggers the chat, maybe throw in a debug output with the normal chat message to figure out if it is triggering for the same source... For example: outputChatBox("TestMessage: ("..tostring(source)..")",255,150,50) -- Replace source with the player element maybe... This should output "UserData:0x000" or something similar anyway, this would at least tell you if another player is triggering the chat message for you, plus your own Otherwise, you may need to scan your code within whatever triggers the chat messages and keep in mind teams are causing double... You might not have changed anything, but the upgrade may have changed some old functions or something that would need updating if that makes any sense
  10. Have you tried looking through these resources for the water script? https://community.multitheftauto.com/index.php?p=resources
  11. Well, when I encountered this problem, it was from client events triggering for everyone when I had thought it was triggered for only 1 player... There are some Client Events such as onClientVehicleEnter that will trigger for every player on the server rather than just the player who enters the vehicle. If this proves to be the issue, then you'll just need to check if the player is the local player onClientVehicleEnter(player,seat) if(player==localPlayer)then -- Checks if the player is the local player or not -- Whatever Code end end There was another issue I discovered that was also "doubling up on everything" which happen to be how I was triggering client side events: triggerClientEvent("SomeClientEvent",source) -- Because I ignored/skipped the first argument, this would cause the event to trigger for everyone triggerClientEvent(source,"SomeClientEvent",source) -- This fixed that issue for me, the event would only trigger for the "source" player But in either of these cases, if they were a third player online, everything would triple and so on and so forth... It doesn't sound like this will be your problem, but still worth looking into, just in case of anything
  12. If you're looking for a script or resource, try here: https://community.multitheftauto.com/index.php?p=resources If you're wanting to learn how to make a panel for something, check out the gui stuff: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#GUI_functions_2
  13. First, you are going to want to create some gui which is only done client side: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#GUI_functions_2 I recommend you get the gui edit resource that will make guis for you much easier: https://community.multitheftauto.com/index.php?p=resources&s=details&id=141 Once you get a gui menu up and running, you'll need to fill it with the player's status: https://wiki.multitheftauto.com/wiki/GetPedStat One step at a time though, just focus on making the gui first...
  14. You should use the code tag '<>' when displaying code in your post... Anywho, you want to destroy that blip when the player leaves the server: -- serverside: function PlayerQuit(quit,reason,element) destroyElement(myblip[source]) -- source is the player who is leaving the server for this event myblip[source]=nil -- Free up the memory the player was using for this variable end Also note, myBlip is already defined at the top of your script, therefore no need to define it again, you should remove line 3 local myBlip = {} -- Defines myBlip as a simple table function showPlayers(source) myBlip = {} -- Not needed because it is already defined on line 1, you should remove this line altogether
  15. The screenshot is rather difficult to read and not likely going to receive much help because of it. Copy and Paste the Warnings/Errors lines into your post instead. Also helps to describe what you are trying to do and what is going wrong exactly, provide as much details as possible. Handing over a script and expecting someone to fix it for you is very unlikely, while if you put in some effort on your behalf may convince others you are wanting to learn instead of just hoping for some handout
  16. A quick fix can also be applied by simply checking the Z Coordinate... local x,y,z=getElementPosition(localPlayer) -- Gets the Player's Position if(z>=0 and z<=1)then -- Check the Z Position (Adjust the values to fit the location of your marker of course) -- Enter the Shop code here... end However, in the long run it is good practice to make solutions that may be used over and over, for other similar markers you may create in the future. Just as Z4Zy had suggested here because you could use that route to "cover more ground" later on in your scripts
  17. Maybe I'm getting in over my head here and need to slow down a bit as I still don't understand what Velocity does exactly, let alone jump into something deeper I have no understanding of such as matrixes, lol... It seems the rotation of the projectile doesn't affect the movement at all, yet the Velocity arguments do. In the end, I've just decided to go with the simple fix of using heat seekers and maybe one day come back to this problem and consult this thread. I'm sure the answers are here (Thanx IIYAMA, MrTasty), I just need to study up on this stuff... createProjectile(ped,20,x,y,z,1.0,localPlayer,270.0,0.0,0.0,0.0,0.0,0.1) This creates the rocket on the ped which first launches upwards a tiny bit, then changes direction and rotation towards the target. This way, the projectile doesn't end up in the ground of anything before it starts to seek out the target. Not the desired result of course, but this will still work. Just going to move on and start working on other pieces of my AI script
  18. If you're only beginning to learn Lua and how scripting MTA works, I recommend starting out simple first... Mods are great, but probably not going to go well without any prior coding experience But take one step at a time, get the smaller and more simple things done first such as a spawning point, skin selection, team or class options... Things of that nature and then work your way up towards the desired mod scripts. But if you truly insist on starting on the mods first, consult the Wiki for Server/Client Functions/Events you are going to need
  19. It doesn't "know" what source is, you have to pass the argument to the function within your timer setTimer(function(source) -- Added source here fadeCamera(source, true) -- So now it will get "source" from the function's argument (source) end, time, 1, source) -- And here too, this tells the function what "source" will be This should resolve that issue... outputChatBox ( "Has cegado a " source, attacker, 0, 255, 120 ) -- There is no comma between the text string and source outputChatBox ( "Has cegado a ", source, attacker, 0, 255, 120 ) -- Im still not sure if this would work exactly, but could just do another line outputChatBox ( "Has cegado a ", source, 0, 255, 120 ) -- Send to the source outputChatBox ( "Has cegado a ", attacker, 0, 255, 120 ) -- Send to the attacker
  20. I don't quite understand how the createProjectile function works when it comes to using those extra arguments with rotations and velocity: local ped=createPed(200,-1665,-2185,34.5,0.0) -- Our Test Ped local rocket=createProjectile(ped,19,-1665,-2185,34.5,0,nil,0,0,180.0,0,0,1.0) -- Our Test Rocket I would expect this to ignore the default aim target and just create a rocket on the ped and then fire the projectile behind the ped in a straight line, similar to what it would default as if a vehicle was used as the creator instead. However, this fires the projectile to the right side of the ped (90.0) and also is launched very high into the air even. When I changed that last 1.0 argument to 0.1, the projectile would then fire to the left of ped and end up in the ground not very far from the ped. And all I did was change the velocity argument? This puzzles me... The 'force' argument I don't think would have any effect on a rocket projectile, right? (Wiki example uses a rocket with force of 200 though) What are the valid values? 0.0 to 1.0 maybe? What I think I'm doing wrong is setting the velocity speeds incorrectly therefore I'm not getting expected results. So, let's just say I want the rocket to fire straight forward from the ped just as it does by default for a vehicle. What arguments would I put into the function? local rocket=createProjectile(ped,19,-1665,-2185,34.5,0,nil,0,0,0.0,0,0,1.0) -- ??? I guess I just don't understand velocity and how it could affect the direction of a projectile
  21. What I have discovered was that the rocket projectile was actually aimed at what the player's camera was currently pointed at. Even though the creator was the ped. When the creator is a vehicle, it simply just fires straight ahead of where ever the vehicle is rotated at. So this changes everything... I am aware of the target argument and using heat seekers and does in fact work, but not preferred in my scenario. I'd much rather use rockets that either hit or miss. But you're right about setting the correct rotation arguments is the key. That's going to require some mathematics which is not my strong suit I'm afraid. However, there are some work arounds I still intend to try out: Switching the camera point to yourself (The target), creating the rocket, then setting the camera back to normal is one, although I suspect it will obviously affect gameplay and not the best choice. Another is just using heat seekers with a target of course Anyway, I do appreciate the response, ty for helping me out, will inform you how the math attempt goes which is the best way to do this... (Setting the rotations etc)
  22. With the code listed above, if I change the z1+1 to z1+5, then it becomes easier to spot the direction of the rocket projectiles. The rocket projectile fires in this direction: Behind the ped and into the ground. The player/vehicle is in front of the ped, straight ahead, only a few meters or so away. So I've ruled out the direction of the created rocket projectile firing straight forward from the ped in the direction the ped is facing. I am currently toying with the additional arguments such as the projectile's rotation, but not having much luck figuring out how any of this works yet...
  23. I'm trying to create a ped that fires a rocket projectile from a normal rocket launcher weapon targeting a player. The issue is the rocket projectile's aim, I don't understand how or where it gets even the base aim from in the first place. Through researching this issue, it is my understanding that the projectile will fire straight forward from its owner (In this case, a ped). However, this doesn't seem to be the case for me, seems the rocket flies into the ground near the ped's feet. I'll post a piece of the code to better understand what is going on: local rotation=-math.deg(math.atan2(x-x1,y-y1))-- x y z are the coords of the player or player's vehicle and x1 y1 z1 are the ped's coords if(rotation<0)then rotation=rotation+360 end setElementRotation(ped,0,0,rotation,"default",true)-- Ped now faces the Player setPedControlState(ped,"aim_weapon",true)-- Ped aims the weapon at the Player setPedAimTarget(ped,x,y,z)-- Targets the Player setPedControlState(ped,"fire",true)-- Fires the Rocket Launcher (Or at least the anim for it anyway) if(getPedWeaponSlot(ped)==7)then -- Ped is using the Rocket Launcher weapon (Slot anyways) setTimer(function(ped)setPedControlState(ped,"fire",false);end,200,1,ped) -- Just so the animations appear right... createProjectile(ped,19,x1,y1,z1+1)-- Attempted to use additional arguments such as projectile rotation at first, then went simple... end The results usually are that the rocket projectiles go into the ground near the ped's feet, in some case, seems to shoot backwards behind the ped even... So my question is, how exactly would I be able to aim the created rocket projectile to correctly fire at the Player's/Vehicle x y z position?
  24. It could possibly have been how I was using all my triggerClientEvent functions, the very first "optional" argument was missing, therefore triggering the client events for everyone... However, its difficult to test since I need more than myself to confirm I've even fixed this issue...
  25. You should use the code tag to post your code in if(Example)then -- Codes end It's the <> icon...
×
×
  • Create New...