LonelyRoad
Members-
Posts
116 -
Joined
-
Last visited
Everything posted by LonelyRoad
-
That will at least prevent any damage from when someone is attacked inside an interior. Preventing the player equipping a weapon, I suppose could be done with this event OnPlayerWeaponSwitch and with function setPedWeaponSlot.
-
addEventHandler("onClientPlayerDamage", root, function(player) if (getElementInterior(player) > 0) then cancelEvent() end end) The above code should work, run it client side.
-
Doing cancelEvent() on the server-side event onPlayerDamage has no effect, see the wiki page. Read the 'Cancel Effect' section of OnClientPlayerDamage. What you probably want to do is set element data on 'theAttacker' to indicate he is a medic when they accept the medic job, then on the client side you should do your cancelEvent() and call the server function with your own event using addEvent and addEventHandler.
-
Your script assumes that an entry in the table 'vehicleSpawnCounter' exists for 'source'...you need to separate that check from line 15 and do something like: local counter = vehicleSpawnCounter[source] or 0 An equation like that should also really have brackets ( ) round it, so: if (vehicleSpawnCounter[source] < vehicleSpawnLimit) then
-
To write a string over multiple lines you need to use double squared brackets ( [[ ]] ) IIRC.
-
What is the error message this time?
-
Is the output of this function relative to the world, or relative to the base model? (A question which I thought you might want to be careful of)
-
callServerFunction is a useful function, as the wiki page says at the top. Have you included this function anywhere in your script? You'd probably be better off using addEvent and addEventHandler instead for something like this (with, in this case triggerServerEvent).
-
Hey all, Are MTA Serials reliably unique? I've been developing a login/register system and I was thinking about implementing a remember me option or an autologin based on the user's serial. I want to know how 'safe' this would be, or if it is better to generate my own hash and identify them based on that instead?
-
With the Event onVehicleExplode the Source is the vehicle that exploded. Use respawnVehicle (See Also: setTimer) on the source to respawn the vehicle back to where-ever you did createVehicle (See Also: setVehicleRespawnPosition)
-
Detecting the 'responsible resource' for an element?
LonelyRoad replied to LonelyRoad's topic in Scripting
That worked perfectly, I didn't think that getElementParent would behave like that, based on the example. If it intrigues you, I changed the behaviour of the EngineToggle function slightly: function EngineToggle(src, key, state) local occuVeh = getPedOccupiedVehicle(src) local vehState = getVehicleEngineState(occuVeh) if ( not isValidVehicle ( occuVeh ) ) then setVehicleEngineState(occuVeh, not vehState) return end if (occuVeh ~= false) then local vehOwner = tonumber(getElementData(occuVeh, "veh:owner")) local charID = tonumber(getElementData(src, "character:id")) if (vehOwner == charID) then setVehicleEngineState(occuVeh, not vehState) setVehicleLocked(occuVeh, not vehState) else if (getPedOccupiedVehicleSeat(src) == 0) then outputChatBox("This ain't your car!", src) if (isPedInVehicle(src)) then local x, y, z = getElementPosition(src) removePedFromVehicle(src) setElementPosition(src, x, y, z+5) local x, y, z = nil, nil, nil end end end end end Either way, thank you! -
Detecting the 'responsible resource' for an element?
LonelyRoad replied to LonelyRoad's topic in Scripting
That's kind of what I'm looking for, and has given me a good idea of another way in which that could be useful Snake. However the context I want to apply it to is as below: function EngineToggle(src, key, state) local occuVeh = getPedOccupiedVehicle(src) if (occuVeh ~= false) then local vehOwner = tonumber(getElementData(occuVeh, "veh:owner")) local charID = tonumber(getElementData(src, "character:id")) if (vehOwner == charID) then local vehState = getVehicleEngineState(occuVeh) setVehicleEngineState(occuVeh, not vehState) setVehicleLocked(occuVeh, not vehState) else if (getPedOccupiedVehicleSeat(src) == 0) then outputChatBox("This ain't your car!", src) if (isPedInVehicle(src)) then local x, y, z = getElementPosition(src) removePedFromVehicle(src) setElementPosition(src, x, y, z+5) local x, y, z = nil, nil, nil end end end end end Notice line 9 I check if the owner info matches, and then on lines 14-23 I eject the guy from the car if he doesn't own it. I want to only do that on vehicles created by the vehicle-system resource. -
Detecting the 'responsible resource' for an element?
LonelyRoad replied to LonelyRoad's topic in Scripting
That seems like a long-winded way to do it, and its a lot of element data. Kinda surprised there's not a better way (as yet) to do this? -
I have some scripts to apply protection to player's vehicles, but I only want it to 'recognize' vehicles created by the 'vehicle-system' resource... How, if at all - is this possible?
-
If I'm not mistaken, getRealTime() on the client gets the Client's time and not the Server.
-
My apologies, I misread the code - I am not exactly sure how that script will behave with the timer created outside of a function like that. I would still recommend the method I have explained though, you will get much better results.
-
You're hooking onClientVehicleEnter, which will only trigger once as you don't have any Timers (this event is called when the player enters the vehicle, as the name implies). You need to either use a Timer to trigger your function (separately) to constantly decrease fuel, or a better option would be something like I've done here (please don't copy-paste this code, as it isn't guaranteed to work literally as I've wrote it here, as it is untested): function ExitEngineStop(theVeh, seat, hijacked) if seat == 0 and not hijacked then setVehicleEngineState(theVeh, false) setVehicleLocked(theVeh, false) end end addEventHandler("onPlayerVehicleExit", getRootElement(), ExitEngineStop) function EnterEngineStop(theVeh, seat, hijacked) if seat == 0 and not hijacked then setVehicleEngineState(theVeh, false) setVehicleLocked(theVeh, false) end end addEventHandler("onPlayerVehicleEnter", getRootElement(), EnterEngineStop) Create your own events inside those functions (with addEvent) and then use an addEventHandler so that you only deduct the fuel whilst the vehicle's engine is actually running (using setVehicleEngineState). This would be more player friendly as they are no longer forced to use up fuel if they just sit in their car.
-
I am trying to find a way to shorten the args used by setVehicleColor, but I want to do it dynamically. I actually in this case want to, if possible, mimic the behaviour of the < 1.0.5 setVehicleColor command. The reason is I am currently asking for 6 args from an addCommandHandler() just to specify a vehicle's colour when its created, it makes it one heck of a long command. I suppose one question is how many vehicles actually used two colours? Come to think of it I don't believe there is many..?
-
Correct files to update for new server version?
LonelyRoad replied to LonelyRoad's question in Server
bump -
What are you trying to do, exactly?
-
You need to find a way to control money, that includes storing it to the play in some way. After you've stored money you can simply use a little bit of timer-based magic to deduct the money from the client and give the money to the driver. You just need to check if the cab has a driver and a passenger, and store those two players in some way and continually pay them whilst continuing to check if they are both inside the vehicle.
-
Correct files to update for new server version?
LonelyRoad replied to LonelyRoad's question in Server
Windows -
Correct files to update for new server version?
LonelyRoad replied to LonelyRoad's question in Server
bump -
Correct files to update for new server version?
LonelyRoad replied to LonelyRoad's question in Server
I couldn't seem to find what exactly you were referring to CiBeR. Furthermore it would be much more awesome if I could possibly update the relevant files manually, I don't have it properly installed 'as such' on the server it the updater might derp out on me. -
What files do I need to update each time I want to update the server? I don't want to be doing anything like overwriting configs etc. Regards.
