Jump to content
  • Posts

    65
  • Joined

  • Last visited

Everything posted by [email protected]

  1. this is possible: The script sets the timer variable using set("vrdelaytime", value), where value is the configurable varible removeDelay to set the delay in minutes, but in milliseconds. You can read from this using get("vrdelaytime") If you want to change the delay while the script is running, you can do that by issueing: set("vrdelay", newDelay), where newDelay is the new delaytime in milliseconds (x minutes = x * 60000 ms) When a new car is put on the queue then, it will be despawned faster/slower(depending on the new delay) than before the change of this value. The script should have no problem with searching the correct car in the queue to remove. It can remove items from inside the middle of the queue, etc.
  2. Not sure if I got your words there, but the script actually does: event | action --------------------------------------------------------------------- player leaves vehicle | vehicle is put on destructionqueue player enters vehicle | if the vehicle was on the destruction queue, it's taken out of the queue vehicle on destruction queue is being despawned | remove vehicle from queue and physically destroy it vehicle explodes | instantly physically destroy vehicle So basically it looks currently the easiest to me, to simply change event 1, so that the vehicle is put on the destruction queue, ONLY if the player was the only player inside that vehicle. You can do this by looping through all seats of the vehicle and check if all seats are empty when the player left. If so, then put the vehicle on the queue. physically this means you need to add this check in the "function delayVehicleDestroy()" function. EDIT: I also noticed I uploaded a zipfile, which still had most debugging output enabled. re-uploaded it now.
  3. I wonder what happens if 2 players have the same previously used vehicle If 2 players have been in the same vehicle and both of them left the vehicle, but did not create/enter another one yet Then player 1 enters another vehicle and his previous vehicle gets destroyed.(eventually players in it are kicked out) After that player 2 anters a different vehicle than player 1 is in. Both players are drivers in this case, not passengers. Then there is an attempt to destroy a vehicle that doesn't exist anymore I would guess...
  4. I think I get your idea, but storing the same data on 2 places, in this case all queued cars at a specific moment are present in both queues, can be dangerous. You should be absolutely sure that, if a car gets removed from queue1, then it should also be removed from queue2, and also the other direction: car removed from queue2, then it should also be removed from queue1. If this cannot be guaranteed you actually can't say if the script always does the same thing. An example: queues: Q1 and Q2 2 cars are being removed every time-tick when we start, Q1 contains 3 cars and Q2 has not yet copied the contents of Q1. Q1 = {car1, car2, car3} Q2 = {} Q2 copies from Q1: Q1 = {car1, car2, car3} Q2 = {car1, car2, car3} A vehicle is added to the realtime queue Q1: Q1 = {car1, car2, car3, car4} Q2 = {car1, car2, car3} time-tick occurs, 2 cars being removed: Q1 = {car1, car2, car3, car4} Q2 = {car3} *exploded* the timers for car1 and car2 are still running, and will attempt to destroy a vehicle that doesn't exist anymore (because it was removed by the regular cleanup), but Q1 wasn't updated also during the operation, where 2 cars were removed). And an update: I have updated the output when issuing the /vrdelay command, to match the situation. The message that says that the script is enabled now or disabled now is also sent to every player on the server now, as I intended at first. I haven't added any comments and implementation descriptions still. Current changes are updated in the zip: http://www.colips.nl/files/vrdelay.zip
  5. Adding a GUI would be very cool I'm not sure about a performance boost for the server if you remove all queued vehicles instantly. If the list of queued vehicles is pretty large, then the server may need some time to despawn every vehicle on that queue, thus creating more likely something like extra latency for 1 second, after which you can start with a clean desk again To be honest I haven't analyzed what kind of impact the server would get if you would need to destroy, let's say 500 vehicles instantly. In theory this is possible if you have a very populated server, with many people switching cars all the time and a large timer delay. Question should then be: what is the best possible case to maximize overall server performance? Ofcourse a very bad scenario is to have more and more vehicles being stacked up in the server until it crashes because it ran out of system resources, so that's not an option. Another bad scenario can be the case where you need to instantly remove 500 vehicles (because an admin wanted to clear the queue), this can, depending on your server machine take up to seconds. Which might be enough to disconnect a lot of players. I'd say that is not a solution also. A 3rd possibility could be that if an admin wishes to clear the queue and destroy all vehicles on the queue, to destroy every car on the queue with a 500ms delay between the destroy of a vehicle and the next vehicle on the queue. An extra concern would be the time it would take to clear the queue then, and what would happen if you stop clearing the queue halfway. Also what would happen with vehicles being added to the queue, while the queue is being cleared. A 4th option could be to clear the queue automatically every x minutes. By adding a function that starts a timer, which calls the function itself again (recursively). This function should only be running if the global variable sEnabled (which holds the state of the script) is true, if it is false it should not execute the timer anymore, but it should resume executing again if an admin uses /vrdelay start for example. Oh my, what a block of text was that
  6. getVehicleOccupant( vehicleObj ) in the script should return the driver of the vehicle and getVehicleOccupant( vehicleObj, i ) in the loop should check every seat of a vehicle for the condition that there's a player on the seat. However: Between the start of the destroy vehicle timer and the actual destruction of the vehicle, it can happen the vehicle does not exist at the moment when the timer for that vehicle expires. (for example, when the vehicle got blown up but has not yet respawned). This should be fixed once the vehicle will be removed if it explodes. But I haven't had the time to create that properly. You can probably do it yourself easily, by adding an event handler for the server event "onVehicleExplode", which calls the function destroyVehicle. I still have an issue with removing the vehicle if a player dies inside the vehicle though. Trying to work that out for tomorrow. As for that syntax message for the start/stop command. The script does check if it is running or not, but the condition of the output of that message is not correct. It doesn't start the script if it was already running. I will make sure this inconsistency is not present in the next update.
  7. Yes there is. if you wish to find the coordinates of a car, you can try: local vehX, vehY, vehZ = getElementPosition( vehicleObj ), which basically saves the x, y and z coordinate of the vehicle vehicleObj into the variables vehX, vehY and vehZ. Note that a vehicle is also an element. the function specification: float, float, float getElementPosition ( element theElement ) for the vehicle rotation you can use: local rotX, rotY, rotZ = getVehicleRotation( vehicleObj ), which saves the x, y and z rotations into the corresponding variables, just like the previous function. and the function specification: float float float getVehicleRotation ( vehicle theVehicle )
  8. Hi Ryzel, I read the following as "when a player abandons/leaves his car": It seems you meant when there is no player in the car. I will look into that tomorrow afternoon, or earlier if time allows it. and thanks for the reaction on permissions eAi. I have been trying to mess around with hasObjectPermissionsTo, but I do not have anything yet that does what it should do EDIT: the in-game command "/vrdelay start|stop" works as it was meant to work now. Admins using "/vrdelay start" and "/vrdelay stop" (in the console window without the slashes), can respectively enable or disable the scripts functionality now. Upon using the stop command, no more vehicles will despawn by this script and the queue holding all vehicles that were about to removed is emptied. Every player on the server will also be updated if the script is started/stopped The updated version is located at: http://www.colips.nl/files/vrdelay.zip and the despawn timer is again set to 10 minutes by default. TODO: -vehicles despawning, even if nobody ever entered the vehicle -vehicles despawning when the vehicle explodes -vehicle despawning when the last player occupying the vehicle died -vehicle despawning currently does not look if the player who left the vehicle was the ONLY player inside that vehicle, in other words: If there was more than 1 player in the vehicle, the despawn timer will still be started. *I forgot to update the implementation description with the vrdelay command-related details, and some comments related to the vrdelay command aren't updated also, in the current resource package Feedback on bugs, positive reactions, suggestions are welcome ofcourse
  9. I was trying to add a command that would enable/disable the script's functionality during runtime. That means: admins would be able to stop the vehicles from despawning by typing: "vrdelay stop" in the console (or "/vrdelay stop" in the chatbox), and type "vrdelay start" to resume vehicles despawning again. But I had some issues by making this an admin-exclusive command (everyone was basically able to use it which you probably don't want ) If anyone can get me a hint on making that command accessible to server admins only that would be very sweet The command is disabled for now, but was implemented through a command handler, calling a function that starts and stops the script, based on what it's argument was. Code below: function startStopHandler( playerObj, cmd, arg ) -- function to start/stop the script functionality, currently disabled. if isGuestAccount( getClientAccount( playerObj )) then outputChatBox("You do not have permission to use this command!", playerObj, 255, 0, 0) else if( arg == "start" ) and not sEnabled then sEnabled = true outputChatBox("#00FF00Delayed Vehicle Despawn #FFFF00is enabled now", playerObj, 255, 255, 0, true) else if( arg =="stop") and sEnabled then local numQueued = #markedVehicles for i = 1,numQueued do table.remove( markedVehicles, i ) end sEnabled = false outputChatBox("#00FF00Delayed Vehicle Despawn #FFFF00is disabled now", playerObj, 255, 255, 0, true) end end end end addCommandHandler("vrdelay", startStopHandler) -- command handler to enable/disable the script Additional notes: -sEnabled is a global variable, which is true or false. the other main functions read from this variable. -this function works for all registered players currently. Unregistered players (players without accounts on the server) cannot use the command, but I want it to be an admin/moderator-only command. -I have been experimenting with the ACL, concerning this problem but it seems quite hard to add the permission for this command from inside the script itself, as the whole resource doesn't seem to have permission to edit the ACL.
  10. Currently I do not have too much free time to create a script like this, but for the other scripters: I think this can easily be achieved using the setAccountData and getAccountData functions to store and load player-specific data, like money, coordinates, weapons, etc. a small example and explanation can be found here: http://development.mtasa.com/index.php? ... ccountData To realize this you need to have players being able to register accounts, and to login to their account. The only concern could be if "guests" actually have the permissions to create an account for themselves. I'll try to work this out when I have some time if nobody does
  11. Hi again, apologies for doubleposting, seemed I couldn't edit my own post EDIT: and for a weird reason I can edit this post, but not my previous one... Anyway Rynet, I created a resource-script, of what I think you meant the script should do. You can download it currently from: http://www.colips.nl/files/vrdelay.zip (forum doesn't allow me to put it as attachment, for a reason I suppose ) Put the zipfile in your /mods/deathmatch/resources/ directory, and load the resource in the server ( servercommand for this is: start vrdelay ) The default vehicle despawn delay-time is set to 10 minutes. Currently this is hardcoded in the .lua scriptfile, but if you unzip the contents of the zipfile into your /mods/deathmatch/resources/ directory, you can open the .lua script with a text editor (even notepad would do), and manually set the delay-time of the vehicles. if you open the delayedVehicleDestroy.lua file, you should change the line in bold-style, as shown below. For instance: if you want the vehicles to disappear after 45 minutes, after the player left the vehicle, then you should change the "10" in the bold-styled line in the code, to "45". Note that that line is not typed in bold in the actual .lua file. ---------------------------------------------- -- Delayed Vehicle Removal Script -- Author: [email protected] -- Date: 6 january 2008 -- Description: This resource removes any -- abandoned vehicle on the map after a -- certain amount of time. Abandoned -- means a player leaving the vehicle. ---------------------------------------------- -- Configurable, set your despawndelay here! -- [b]local removeDelay = 10 [/b] -- The amount of minutes to wait before removing an abandonded vehicle ---------------------------------------------- -- Description of the implementation: ---------------------------------------------- -- -- We record a queue that holds all vehicles that are about to be removed from the game, within a certain amount of time. -- A vehicle that has been abandonded is added to this queue and will remain on the queue until the vehicle gets removed, or a player enters the vehicle again. -- When the timer has been expired for that specific vehicle, the vehicle will be removed from the game. -- If the vehicle is removed, it will never respawn again. It can only be recovered by restarting the map on the server. -- Ofcourse spawning a new vehicle is an option also ..... One last note: I haven't specified exactly what happens when there are several players in a vehicle and only 1 of them leaves the vehicle. My guess is that the vehicle despawn timer will start anyway then, and when that timer expires it probably kicks out all "passengers" and removing the vehicle. As soon as another player enters the vehicle the vehicle will not despawn though. I will look into that later One more last last note : You are free to use this script for non-commercial purposes. You can modify the script if you wish to. You cannot remove my credits from the script though.
  12. I guess you can build a script that uses the destroyElement ( element elementToDestroy ) function to destroy the vehicle itself. To find the vehicle you can use the event handler onExitVehicle, which triggers your function to destroy the vehicle, passing the vehicle element to the triggered function as source. Inside that triggered function you can add a timer which triggers a second function actually destroying the vehicle after a certain amount of time, let's say 10 minutes. I will script an example in some moments and verify if that works
  13. I wonder whether it is possible to add NPC's (non-player-characters) to a map, to interact with, for example store-personel. If anyone has some info on that I'd love to hear the details And on-topic: About NPC's I am not really sure, but apart from that it seems almost anything can be done while scripting for my own MTA test server, I am quite sure roleplaying is possible if someone takes the time to code it properly.
  14. Might be useful to copy and paste the exact error output from your server
  15. Ok, I haven't taken a really deep look in your script, but it seems that: Here you call the function spawnPlayer(source), where source is the player object defined by the event handler. Ok, let's have a look at the spawnPlayer function then.. Previously you called this function with the argument "thePlayer"'s value as "source", Notice that the value of source has been inserted in this function's argument. To get access to this value (namely the player object from the onPlayerJoin function), you have to use thePlayer, because the value is held in this variable within this function. To make a long story short: find in spawnPlayer (thePlayer): fadeCamera( source, true ) replace with: fadeCamera( thePlayer, true )
×
×
  • Create New...