Jump to content
  • Posts

    65
  • Joined

  • Last visited

Everything posted by [email protected]

  1. check this: viewtopic.php?f=91&t=21370#p268805 For some reason the buttons have issues in the addEventHandler routine.
  2. What you should do is to make sure you get yourself an ACL account if you haven't got it already (in the form of: user."name"). Then you can loop through all players and get the accounts they are logged in to. If their account matches with your user."name" account, then he/she is identified as you. Obviously you should login to your own account to make this work Ok, that may sound vague, so here is an example I made for my own scripts. This script checks whether a specific user is an admin or not: function isAdmin( playerObj ) -- get player account access... acName = getAccountName( getClientAccount( playerObj ) ) aclObj = "user."..acName -- retrieving all admin accounts... adminusers = aclGroupListObjects(aclGetGroup("Admin")) for akey, aname in ipairs(adminusers) do if (aclObj == aname) then return true -- if player's account username belongs to an admin's account, we found what we wanted to know. playerObj is an admin. end -- loop ends as soon as a match is found (on returning a function value) end return false -- player's account is not an admin account. end In your situation you do not need the loop because you want to match 1 name with a pre-defined account (but you must still loop through every player on the server and execute this function per player), you do not have to check ALL adminaccounts for matches (like I had to do), only the one you wanted, your code would look something like this: function isMe( playerObj ) -- get player account access... acName = getAccountName( getClientAccount( playerObj ) ) aclObj = "user."..acName -- retrieving all admin accounts... myAccount = aclGet("user.myName") -- myName is your account username if( aclObj == myAccount ) then return true -- player's account is your account. else return false -- player's account is not your account end end This function should return true if the player is logged into your account, and false if your player is not logged in to your account.
  3. I think that is where your "error" lies also. My buttons do not work for some reason also, when I implement it the way you did. "# addEventHandler ( "onClientGUIClick", button, changeVisibility) -- Close the GUI using the button " the second argument doesn't seem to be taken correctly by the event handler for a weird reason. My temporary solution was to change the addEventHandler() to: addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), changeVisibility) and add an extra check inside the triggered function: if ( source == button) then ... end
  4. Well if you want to match it to your playername, then you can simply do getClientName( aPlayer ), and verify whether that is or is not your playername. (client side this is getPlayerName( aPlayer ) I think), but there is much more secure ways of implementing some sort of identification. It would depend on what you really want to have. And a side-note: the script you "quoted" is copyrighted, you probably need to get permission from it's creator to use it
  5. i can save positions the "Saved!" appears but how to teleport to there ? in the server window of developers preview 2 there comes an error: Attempt to concatenate local 'coment' Assuming "comment" was spelled correct: This means the variable comment has no value (it points to nothing). The script in the first post here, doesn't check if the value of comment exists. To do this add something like: if( comment ~= nil ) then ... end
  6. Welcome messages have been added to the admin-panel, that comes with the server program in developers preview 2 (didn't test it myself though)
  7. The fact the vehicle sometimes does not appear I cannot explain also, it also happens with my version of the solution to the problem. I ran it with multiple PC's at the same time, and on one PC the car was really visually removed, while on the other PC it was still there, but not possible to interact with the car anymore (the element was really destroyed along with it's timer). I think it may be a client-side problem perhaps. As for the admin-access thing. What I basically do is, to gather all players who are on the server and are logged in to the server account system (they must have used /login username password in-game), and out of that select of players I match their accounts against the admin-data I retrieved from the ACL. If a match is found and that player is the player in question, then my script says he/she is an admin. Same can be done for moderators, where you can match useraccounts against the acl-data of admins united with the acl-data of moderators PS. you can also use the ACL and limit access to a command for example, through the ACL. One issue which was a disadvantage for me, is that you need to setup this specific access, on the server in the ACL... This means server adminitrators have extra work, and the correct configuration is not that obvious also. An example, if you would limit access for the resource "test" to the command "testcommand", through the webadmin resource: - first problem is that the webadmin resource does not have permissions to change the ACL by default (the in-game admin-panel does, but I am lazy and I do not wish to boot up the game everytime to add, remove, or change the ACL. So let's open: acl.xml inside your deathmatch mod map on the server. Scroll down until you find something like: <group name="Admin"> <acl name="Moderator"/> <acl name="SuperModerator"/> <acl name="Admin"/> <acl name="RPC"/> <object name="resource.admin"/> </group> Add the webadmin resourcee to this "admin-node", above the admin resource: <group name="Admin"> <acl name="Moderator"/> <acl name="SuperModerator"/> <acl name="Admin"/> <acl name="RPC"/> [b] <object name="resource.webadmin"/>[/b] <object name="resource.admin"/> </group> Alright, now reboot your server to active this, you don't need reboots after this anymore. Now let's get to the real stuff, open your webbrowser and go to http://serveraddress:22005 and login with any admin-account from your server. If you do not get a response, check if the resources: "webadmin" and "resourcebrowser" are running, and whether you use a different port (default is 22005) for your webadmin resource (mtaserver.conf). You should see a menu-section for ACL management, click on GROUPS and add a new group, for example "testgroup". After that add the resource "test" to this group. Now head over to the ACLs menu, and add a new ACL, let's call it "testACL", after this add the command "testcommand", with ALLOW ACCESS to the ACL you just created. After that, add the same command to the ACL "Default", but this time leave ALLOW ACCESS unchecked (meaning disallow access). Right now, nobody, except objects in the ACL "testACL" can use the command. If you would have put the command into the ACL "moderator" instead of testACL, then moderators would be able to use it (and also admins, because moderator rights is a part of administrator rights) Hope that clearifies something at least
  8. Hi, Can you give some info about the "createPed" function or where I can find it? It's not listed on Wikki. Thanks. *bump*, like to know that also
  9. You "might" have a look at the script I built for the same issue. It's called "vrdelay", or it's full, very unlogical name: Delayed Vehicle Despawn. What it currently does is removing any abandonded vehicle after a set amount of time (default 10 minutes). One known issue however is that it currently doesn't remove vehicles that were never entered. If you are an administrator you can soft-enable/disable the script using the commands it supplies. There is a help.xml file included that is supported by the help manager to give you some detail. There's also a command that let's you show all vehicles that are on a timer for destruction. You are free to copy code from it for use in your script, if you put in my credits at some visible spot. If you wish to edit the code and redistribute it, please ask me first, as I want to know where and how my stuff is used link: viewtopic.php?f=91&t=21102 (scroll to last posts for latest version) -My script has a "sneaky" way to identify users as admins or non-admins, you might use that. -destroyElement is a server-only operation I think yes. -client-side outputChatBox... I have no clue tbh, try it , it's much more obvious to use: outputChatBox("sometext", thePlayer) to send the text "sometext" to a player object: thePlayer.
  10. The easiest way is putting the player that created a vehicle in the vehicle element using setElementData. ie setElementData ( createdVehicle, "creator", playerThatCreatedIt ). When a player exits, just loop through all the cars looking for a matching "creator" and delete it if the car is empty. If it's not empty, perhaps change the creator to the current driver of the car. There is no way to detect an element being created yet. We might have to add something like onElementCreate for a future release. Thanks for confirming that it is currently not yet possible to detect whether a new element is created or not, ChrML. That implies I have to find an alternative way to get done what I wish to reach
  11. Sorry Rynet, the last available version is a bit outdated again, I will be removing most debug output from the script now, and upload the latest one after that. I will update when it is up with the link in this post, once it is online. UPDATE: newest version uploaded to: http://www.colips.nl/files/vrdelay0.2b2.zip Newest version also has a help-tab on the help-manager resource now, describing what it does and the known issues we've discovered while testing it locally, debug output is suppressed in this version. One major change in this version is the structure of the destruction queue. Instead of holding vehicles in it, it holds arrays of vehicles, combined with timers. That way the timer is guaranteed to be bound to the vehicle on the queue, and can easily be destroyed with it's vehicle. The structure now looks like: { { vehicle1, timer1 }, { vehicle2, timer2 }, { vehicle3, timer3 }, etc.. } Plan for next version is to make it more configurable, hopefully with an included GUI --- Clouds response (edit) has some sense, that would be my alternative if it isn't possible to put a vehicle on the queue directly when it spawned. Most likely this can can be done with something like: if not (isVehicleOnDestructionQueue( vehicleObj )) and isEmptyVehicle( vehicleObj ), then add it to the queue, for every vehicle on the server. The functions in that are to be found inside the lua scriptfile, and do exactly as the implementation description says
  12. I scripted my own vehicle-saving script, but it's very userunfriendly if you aren't used to it a lot... What it mainly gives you is 2 commands: 1 is to save an individual vehicle's respawn location, another is to save the total map to your disk. It's very sloppy coded, and doesn't take performance in mind or whatso-ever (it removes all vehicle nodes from your map-file and updates it with the ones that were there + new cars spawned on the map). This is mainly because I am lazy and it's meant for developing only, not for production servers. It works nicely for me, it has the following benefits: -Vehicle spawns can be added, removed (by destroying the vehicle element), updated and saved to the disk, all in-game -It has no GUI, but it's fairly simple to use: Spawn a car using the admin panel (or any other method), drive the car to the positon you want it to spawn at and make sure it's rotated to the way you want it, then use the save car command in-game. Your car is saved in the server memory then, not your disk. Do this for all cars you want to add/update. When you are down use the command to save the map, and your mapfile is updated , just restart the admin resource and your gamemode/map that is running on your server and it's ready for use. -Disadvantages: -no GUI -poorly coded, but it does it's job -the code is basicaly untested for specific scenario's, always make a backup of your mapfile before attempting things with this, for safety. -no documentation -can only edit vehicles in mapfiles, or files having an XML structure that matches the basic mapfile structure. I will upload this somewhere tomorrow or the day after, because the code is currently hardcoded for 1 specific map, and 1 specific game-mode. I will change this so you can set your own mapfile, easily and remove some stuff that is absolutely useless for this purpose
  13. Shouldn't really make a difference I think..., unless the root element changes to a different one, but that should not be the case I think.
  14. Hi everyone, I have a small issue that is out of my reach currently: first of all what I want to create: -In short: gangzones -Longer: coloured areas on the map, which are owned by a team or by nobody. If someone enters a specific area, and is not in the team that owns the area, then it should start flashing (if it didn't do that already (multiple players)), and if the last player inside the area not belonging to the area-owning team, exits the area it should obviously stop flashing. If an area flashes for a specific amount of time, and no player of the team that owns the area is inside that area, and there is only 1 team inside this area, then that team becomes the new owner. The problem: -Currently working: drawing the areas on the map, saving them to an xml file. They also start flashing if a player enters and stop flashing when a player leaves the area. -Main issue now: When I draw multiple radarareas on the radar, and link a colshape to it to detect whether a player enters it and leaves it, it goes alright but: For some reason it often happens that my whole radar becomes the color of a drawn radararea. This happens on approximately every 90 degree-turn of the camera. I suspect this is some sort of a rendering issue, or at least client-side? Anyhow, it's very annoying and lethal to the idea I wish to realize (using a colshape rectangle for the radar area, which may be related to the 90-degree draw issue...?) Can anyone explain me what is happening there exactly?
  15. Update: I am still looking for a way to set a timer, when a vehicle is spawned. This does not mean respawned. For the script to function 100% as it was intended to function I will probably need a hint from someone on how to trigger an event when a vehicle is spawned, even if it was spawned from external scripts/resources. Hints are extremely welcome on this
  16. I cannot answer question 2, but in response to qyestion 1: I think you can do this like this: -create an empty map using the fast tutorial on the scripting wiki. -this is a .map file with an internal XML structure. -load this mapfile into your script, and find the correct XML node (the parent node for the nodes, which is the map-node I think, but I haven't check that currently). -Then simply for every vehicle create new vehicle-nodes in the XML structure, and when you are done save the XML tree back to the file. I had some difficulty by figuring out the details on the way MTA handles this, but there is a set of basic operations (like xmlCreateNode or whatever), you can look that up in the scripting wiki again.
  17. You can do it with much less difficulty: You had: ramp = createObject ( 1655, x, y, z, 0, 0, r ) ... setTimer ( RemoveRamp, 8000, 1 ) just add the ramp as argument to that timer: setTimer ( RemoveRamp, 8000, 1, ramp ) This way it will function as if ramp was an argument of the functioncall, usually written as: RemoveRamp( ramp )
  18. You might want to add a check whether the data really got saved to the file. Currently, it (is supposed to) always report "Worked!" back to the player (a file could be read-only)
  19. Also: # function savepos(player, cmd) # local posX, posY, posZ = getElementPosition(player) # local rot = getPlayerRotation(player) # local name = getClientName(player) # positions[name][x] = posX # positions[name][y] = posY # positions[name][z] = posZ # positions[name][rot] = rot # end looks like you are saving exactly the same data, just twice in basically exactly the same way. You might consider using the registry system, saving data by using the "set()" function and retrieving the data with "get()", this saved data should also persist through server reboots or downtimes. (it seems to be saved in a file called "settings.xml")
  20. your lua script file... is that "auto.lua" or "car.lua"? Seems a bit cunfusing looking at the error and your meta file, if the lua scriptfile is indeed the one shown in your posted meta-file, then you are probably looking in the wrong lua file
  21. function spawnRamp( thePlayer ) local x, y, z = getElementPosition(player) local a = getPlayerRotation(player) x2 = (10 * math.sin(-a)) y2 = (10 * math.cos(-a)) local ramp = createObject (3593, x2, y2, z, 0, 0, a) [color=#FF0000]setTimer ( removeRamp, 3000, 1, [b]ramp[/b] )[/color] end [color=#FF0000]function removeRamp ( [b]rampObj[/b] )[/color] [color=#FF0000] destroyElement(rampObj)[/color] [color=#FF0000] end[/color] bindKey ( thePlayer, "c", "down", spawnRamp ) You should have scripted it like above: 2 functions: 1 spawns the ramp, 1 destroys the ramp. 1 timer: inside the spawnfunction, that will trigger the destroy function when it expires. EDIT: text in red is changed code, but noticed previous post got deleted, I also didn't verify whether your code really does what it is supposed to do, just the correct use of the 2 functions and the timer
  22. Thanks for that hint, I had forgotten that isElement() excepts not just elements as it's argument, but obviously that should be the case or the function would be worthless after all I actually worked it out by simply destroying the vehicle element when the vehicle explodes in an earlier version though, and removing the vehicle from the queue manually then if it was on the queue, by just performing my destroyVehicle function, which has an optional argument whether or not it should try to remove a vehicle from the queue when the function is called. Update note: I noticed that the script as it is available for download currently (vrdelay.zip), contains a flaw when the resource cannot set a register-setting on the server. This can sometimes be avoided by removing your settings.xml file on windows dedicated servers. The developement version I currently got checks for this and disables script execution on scriptloadtime (setting sEnabled to false) if it cannot write the register variable containing the delaytime-amount. Further, the script could send a message that says the script has been unloaded or loaded inconsitantly: When a different resource was loaded or a game-mode was stopped for example. In the next version, this will only happen for the vrdelay resource, to restore consistancy on this message again. Last major change is that most debug output will now be output to the server window instead of sending it back to the player who initiated the event. I will be uploading my next update, once I have updated all implementation details and comments. EDIT: does anyone have a suggestion on executing a function whenever a vehicle is created/spawned, no matter which resources was responsible for it? Something like the onVehicleRespawn event, but not just when it respawns, simply whenever it spawns. This is to set start the vehicle destruction timer, whenever a vehicle is spawned. If anyone figured it out, let me know What I'm affraid of is that I need to add a custom event, that does this and build a vehicle spawn function inside the script myself, and export this function via the meta-file, for it to be available to other resources through the call() function. (Silently hoping on an easier way though ) EDIT: 8 january 2008, 1:35AM CET: vehicle destruction timers are now ONLY started when the player who left a vehicle was the last player (= vehicle is then empty). Also fixed some typos in text output and the script doesn't think it is unloaded anymore whenever a different resource is unloaded. Added a check whether the started/stopped resource is the vrdelay script itself or not. Made some major changes in the onVehicleStartExit handler, in order to suit some new requirements. Added a function that checks whether a vehicle is empty or not and updated a serious amount of implementation details and descriptions. Bed time I have uploaded a newer dev version of the script to: http://www.colips.nl/files/vrdelay_dev.zip This version has all debug-output still enabled. I wouldn't recommend to use this version on a server that is not meant for developing scripts/code. If you have a server for players to have fun on and you use this script version on it, you probably get spammed by debug messages Alright, so what has changed in this version: - Vehicles no longer respawn when they exploded. - Vehicles that respawned will get on the destruction queue, to be removed after the specified amount of time. (this can happen when a vehicle respawned, but did not explode before, mostly caused by external scripts) - Vehicles that explode will instantly be destroyed, and will not respawn anymore. - Added a new argument to the command /vrdelay, called "status". When an admin types: "/vrdelay status", then a debug message will be returned to the console and the server-console-window, showing all active timers and which vehicle they belong to. - When a vehicle is removed from the destruction queue, it's timer will get destroyed also (using the function removeVehicleFromDestructionQueue for that). - When a vehicle is directly destroyed, using the function destroyVehicle, and supplying the optional attribute (to also remove the vehicle from the queue), then also it's timer will be destroyed. - Updated some implementation details, but it is currently not up-to-date.
  23. Declaration of a function in LUA, as MTA uses it works as follows: function functionName( arg1, arg2, arg3, ... ) end functionName is the name of the function and arg1, arg2, arg3, etc. are the arguments the function will accept. For instance, suppose we want to create a function called "printText" and arg1 is "Hello world!" and arg2 is empty. We want the function to accept exactly 2 arguments. The function will write arg1 and arg2 to the chatbox of all players on the server, such that arg2 is directly place behind arg1 on a single line. (like: "arg1arg2") We would define the function as follows: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end arg1..arg2 means the values of both arg1 and arg2 (the actual text) will be linked into 1 whole, in difficult terms this is called concatenation. We can call the function in several ways. printText("Hello World!") or if you wish to use a commandhandler... addCommandHandler( "shout", printText ) This command handler allows us to type this in-game: /shout "Hello World!" in both cases the message "Hello World!" is sent to everyone on the server. in your code that would look like: for the normal function call: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end printText("Hello World!") for the command handler: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end addCommandHandler( "shout", printText )
  24. What terenex meants was the following I think: this will mainly send the message to getRootElement(), which basically is your universe, it contains everything: players, vehicles, objects, elements, etc. You can see it as a tree of which the result of getRootElement() is the tree-root. players, vehicles, objects, etc are all sub-trees of this. So if you would use the root element to send the message to it will also reach ALL players (correct me if this is wrong) note: the argument of getClientName MUST be a player-object. a vehicle or blip for instance are of different types and conflict in their data structures, for this reason the root element cannot be used as argument of that function.
×
×
  • Create New...