Jump to content

dn83

Members
  • Posts

    14
  • Joined

  • Last visited

dn83's Achievements

Square

Square (6/54)

0

Reputation

  1. dn83

    Lua functions

    Ok, thanks Hmm, didn't think of comparing them individually. That of course needs more fields wherever they are saved..
  2. dn83

    Lua functions

    Ok, millisecond accuracy isn't needed, I just wrote (milli)seconds because thats what getTickCount returns.. Perhaps I can even do without seconds. Anyway, what I wanted is something like this: currentTime = os.time() futureTime = currentTime + 60*60*24*3 (to set the futureTime 3 days later if we are dealing with seconds) storeTimeSomewhere(futureTime) and then later I can check if we are past the set time or not simply using currentTime = os.time() theTime = getTheStoredTimeFromSomewhere(futureTime) if( currentTime > theTime ) then something else keep waitin end... Get it?
  3. Hmm, how about this function? function spawnProtectEnd (player) setElementData ( player, "spawnprotected", false ) local elements = getAttachedElements(player) -- get all elements attached to the player as a table (shouldn't be any others, but hey, you never know.. : ) ) for k,v in ipairs(elements) do -- search the table... if(getElementType(v) == "marker") then -- ... and when a marker-element is found -- detachElementFromElement(v, player) -- try with and without this line destroyElement(v) -- delete it. end end end
  4. I was thinking, how about making a custom clock: remove the ingame-clock (showPlayerHudComponent() ), and make a new clock (createTextDisplay() ), and update it once a minute along with setting a new game-time with setTime().. Anybody understand what I mean? I'm not surprised if you don't That would probably stop the flickering, as the time is set only once a minute. The sun/moon might skip slightly backwards when the new time is set, but is it noticeable? Don't know. Now I really need to sleep, I might try and do this some other day when I have time. If someone else hasn't made it already by then.
  5. is that right? and also, how would i go about running this on the server to test, like, is that the only stuff to go in the .lua file? or is more code neded or what? Not quite, it's setTimer( function , delay , iterations ) -- 0 iterations are infinite, a loop so it would be setTimer( syncTime , 500 , 0 )
  6. 83, not 68.. Hmm, try naming the function something else than setTime(), as it's already reserved.. Now I also noticed what was written further down on the page. But on the top of the wiki-page it still clearly says: "This function gets the real server time and returns it in a table."
  7. dn83

    Lua functions

    This native lua-function doesn't seem to work: os.time() - (http://www.lua.org/manual/5.1/manual.html#pdf-os.time) getRealTime() won't help in this case, since I need to have the time in (milli)seconds since some predefined time (1-1-1970_00-00 ?) getTickCount() won't do it either, it only returns milliseconds from when the server was started..? I need to easily be able to compare two times ( < or > ) even though the server has been shut down between these two events. Any ideas? (besides calculating these seconds from getRealtime() -.year -.month etc. as that wouldn't be completely accurate because of leap years and months having different amount of days)
  8. replace the eventhandler with a setTimer() The wiki says getRealTime() returns the servertime, also when run as a client script. Don't know if it's true (and don't know why it wouldn't be ), but if it is true then all players will have the same time on their screen (server-time)
  9. I think I saw a discussion about this exact same thing somewhere, but I can't remember where.. (some other thread probably) Try this one: (client-side) function syncTime() local realTime = getRealTime() local hour = realTime.hour local minute = realTime.minute setTime( hour , minute ) end addEventHandler( "onClientRender" , rootElement , syncTime ) I tried it and it works, but I think sky flickering is increased and fps decreased.. Could be my imagination.. Might work better serverside, with a timer instead of the onClientRender (there has to be something to stop the ingame-time from running at 60x speed again) Edit: ok, so it's not just my imagination then
  10. Try detaching the marker from the player before destroying it.
  11. Exactly. The developers have probably tried anything they can think of to find bugs, so what's left to do is try the unthinkable!
  12. Yes I noticed your script, Rabbit. My script was never intended for an actual release, I don't even have a public server.. I'm just trying to learn scripting on my own So don't feel threatened that I'm trying to take over your business My real question however was why the vehicles aren't always completely removed.. Seems like you have also encountered this (quoted from your help.xml): "-During our last tests it seemed that sometimes a vehicle really gets destroyed, but the model doesn't get despawned. We think however this is an external issue from another resource probably, but just to put this to your notice." Btw, pretty sneaky way to identify admins But can the script/resource itself be limited (through acl?) so only moderators or admins can use it? Acl is still unexplored territory for me..
  13. Especially freeroam spawnpoints can get pretty chaotic after a while when players create vehicles near the spawn, and those vehicles later respawn after being destroyed somewhere else. And some players just create alot of vehicles they never intend to use.. I thought, isn't there an easy way for admins to get rid of them vehicles? Oh wait, this is mta:dm, I can script that myself! Now, this is not a release, but rather a problem! You see, most of the time this script works perfectly! Sometimes though it might just say that the vehicle is removed, but it is still visible.. Thing is, I cannot get into the vehicle anymore, trying to re-remove it doesn't work.. And if I was driving it when I removed it, I cannot get out anymore! After a while being locked into that vehicle it might say 'Network trouble' (and I've only tested it on 127.0.0.1).. Can such a simple script have bugs, or are we looking at a bug in mta itself? I cannot exactly recreate the problem, it just happens - if it happens.. So here's mY 1sT sCrIpT: Vehicle removing script 1.0 - Just press and hold 'K' (default button), click on a vehicle with your mouse, and it is gone! The client part: local removeActive = 0 local localPlayer = getLocalPlayer() outputChatBox( "Vehicle removing script 1.0 loaded!\nHold 'K' and click on a vehicle to remove it." ) function activateRemoveCar() if ( removeActive == 0 ) then removeActive = 1 showCursor( true ) --outputChatBox( "Click on a vehicle to remove it" ) else removeActive = 0 showCursor( false ) end end bindKey( "k" , "down" , activateRemoveCar ) bindKey( "k" , "up" , activateRemoveCar ) function removeCar( button , state , absX , absY , wX , wY , Wz , theElement ) if ( removeActive == 1 and state == "up" ) then if ( theElement ) then local elementType = getElementType( theElement ) if ( elementType == "vehicle" ) then --outputChatBox( "Removing vehicle..." ) triggerServerEvent( "removeCar" , localPlayer , theElement ) else outputChatBox( "You can only remove vehicles" ) end else outputChatBox( "No vehicle selected" ) end end end addEventHandler( "onClientClick" , getRootElement() , removeCar ) And the server part: function removeCar( theVehicle ) if ( theVehicle ) then local removed = destroyElement( theVehicle ) if removed then outputChatBox( "Vehicle removed!" , source ) else outputChatBox( "Failed to remove vehicle." , source ) end end end addEvent( "removeCar" , true ) addEventHandler( "removeCar" , getRootElement() , removeCar ) What needs to be done: - Make it admin only! Someone show me how? Questions: - destroyElement has to be run on the server for this to work, right? - client-side outputChatBox is only shown to the local player, right?
  14. I totally agree with you, Sovetskeey. But remember, this is only a preview release, released one week ago. Most servers are probably running on default settings, with the included demo-gamemodes. I think, and hope, that we in the near future will see more servers dedicated to a specific gamemode, once the community gets their own scripts written.
×
×
  • Create New...