
Den.
Members-
Posts
64 -
Joined
-
Last visited
Everything posted by Den.
-
The player is always going to be in the marker when that event is triggered, because he just entered it. You CAN use a timer to check if the player is still in the marker after a certain time; However, You need to take care and not duplicate the timers, because the player can enter the marker over and over again, in turn creating new timers each hit. So if you are going to use timers, check if one already exists or not.
-
Line 41 in the server-side script should be : triggerClientEvent (source, "mechanictriggernow1", source) Instead of triggerServerEvent. onClientTrailerAttach probably works, you were likely using it incorrectly.
-
"onPlayerTeamChange" is a non-existent event. You're going to need to make a custom one by following Cheez3D's solution;However, You need to find the script where you set the player's team ( where you use setPlayerTeam ) and trigger your new custom event "onPlayerTeamChange".
-
You can call this testejam function by simply doing this: testejam() --If you wish to give it arguments, for example: testejam(thePlayer)
-
You can use: string.find(message, "mtasa://%d+.%d+.%d+.%d+") -- Matches a complete mtasa IP string.find(message, "mtasa://") -- if "mtasa://" exists in the message. string.find(message, "%d+.%d+.%d+.%d+") -- if there is an IP in the message.
-
Error is on line 7: v[1] refers to 1, which is inside v ( {1, 2} ), v[1][2] is trying to index 1, which is a number value. If you want the SECOND value, then use v[2], as in the following snippet: function check () local number = 3 for i,v in ipairs (numbers) do if number == v[1] then outputChatBox(v[1].." | "..v[2]) break end end end addCommandHandler("check", check)
-
Look at the tutorial, and this: 8704 is the second value, of the fourth table in numbers. numbers[4][2] -- will return 8704 in your example --If you want the key of 8704 to be 7 then you can do one the following: numbers = {[7] = 8704,...} numbers[7] = 8704
-
Does this work for you? function shout ( player, cmd, ... ) local accountname = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then local message = table.concat ( { ... }," " ) local name = getPlayerName(player) local r, g, b = getPlayerNametagColor(player) textDisplay = textCreateDisplay ( ) outputChatBox ( "#FF0000(Shoutall) [FO]"..name..": #FFFFFF".. message, root, r, g, b, true ) message = '[FO]'..name..': '..message textItem = textCreateTextItem (message, 0.5, 0.5, 2, 225, 0, 0, 255, 4, "center", "center", 50 ) textDisplayAddText ( textDisplay, textItem ) for _, thePlayer in ipairs ( getElementsByType ( "player" ) ) do textDisplayAddObserver ( textDisplay, thePlayer ) end setTimer ( function ( ) textDestroyTextItem ( textItem ) textDestroyDisplay ( textDisplay ) end ,10000, 1 ) else outputChatBox ( "You cannot use this command!", player, 255, 12, 15 ) end end addCommandHandler ( "shoutall", shout )
-
You can use the lua function unpack to return all values of a table. Following your example: local numbers = {{1,240},{3,4670},{5,64343},{7,8704},{9,10476}} for key, number in ipairs(numbers) do local first, second = unpack(number) --first and second denote to the first and second numbers in the table, so 1 and 240 respectively, etc. --An alternative method would be: local first, second = number[1], number[2] end You might also want to refer to this tutorial.
-
Use the following: function shout(thePlayer, cmd, ...) local accountname = tostring(getAccountName(getPlayerAccount(thePlayer))) --Get the player's account name if isObjectInACLGroup("user."..accountname, aclGetGroup("Admin")) then --Check if he is in an admin local msg = table.concat({...}, " ") --Form the ... into a string by table.concat if msg and msg ~= "" then --If msg isn't empty msg = getPlayerName(thePlayer)..': '..msg --Add the player's name to the msg outputChatBox(msg, root, 205, 0, 0) --output the message to everyone end end end addCommandHandler("shout", shout)
-
Actually I was probably slightly wrong. If you make the marker small enough, that would indicate that the player is definitely landing in that area.
-
You can use the following: if getVehicleOccupant(theVehicle, seat) then --Code to execute when this seat is occupied end Check the wiki for the arguments and seat numbers.
-
parachuteLandMarker was defined and created in the function landingMarker, which is triggered when parachuteLandMarker is hit. So how can the event onClientMarkerHit be triggered for parachuteLandMarker when it isn't created yet? Use the following: local parachuteLandMarker = createMarker(1978.2177734375, -2352.3857421875, 13, "cylinder", 10, 255, 0, 0, 255) function landingMarker() if isPlayerOnGround (localPlayer) then if isElementWithinMarker(localPlayer, parachuteLandMarker) then outputChatBox("succes") else outputChatBox("failure") end end end addEventHandler("onClientMarkerHit", parachuteLandMarker, landingMarker) Your logic MAY be flawed, because I don't think the player will be on the ground the second he hits the marker if he's parachuting in on it; It might be worth testing/checking it out. isElementWithinMarker should ALWAYS return true because the player just triggered onClientMarkerHit when he hit the marker, which in turns instantly calls the function landingMarker; I'm not 100% sure about that though.
-
Read the function's arguments on the wiki. You can specify the index of the element you want to retrieve. getElementByID(element, 1) You can also get all elements who have the same type and same ID, and put them in a table. function getElementsByID(etype, id) if etype and id then local elements = getElementsByType(etype) local result = {} for key, element in ipairs(elements) do if getElementID(element) == id then table.insert(result, element) end end return result end return false end
-
onPlayerLogin is not a command, it is an event that is triggered when a player logs in.You can script your own client-side onPlayerLogin. You can use the following server-side: addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "onClientPlayerLogin", source) end) I've edited the script to include the custom onClientPlayerLogin event, client-side: local drawing = false local function drawPanel() dxDrawImage(306, 186, 399, 344, "wdspawn.png", 0, 0, 0, tocolor(0, 0, 0, 160), false) dxDrawText("Spawn", 405, 334, 605, 378, tocolor(255, 255, 255, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) end --Function to attach the onClientRender event to drawPanel, to draw your panel each frame. local function attachHandler() if not drawing then addEventHandler("onClientRender", root, drawPanel) drawing = true end end --Remove handler to stop drawing the panel local function removeHandler() if drawing then removeEventHandler("onClientRender", root, drawPanel) drawing = false end end --When the player dies addEventHandler("onClientPlayerWasted", localPlayer, attachHandler) --When the player logs in addEvent("onClientPlayerLogin", true) addEventHandler("onClientPlayerLogin", localPlayer, attachHandler) --When the player spawns addEventHandler("onClientPlayerSpawn", localPlayer, removeHandler) You are going to need to stop drawing the panel after the player logs in at some point, just hook the event that suits you to removeHandler to stop drawing the panel.
-
getElementData works perfectly, you're just using it incorrectly. Line 3: You had localplayer instead of localPlayer setMarkerIcon(getElementData(localPlayer, "meetingpoint"), "finish") Is thePlayer variable used in the second snippet defined? Also, check debug ( /debugscript 3 ) for warnings/errors and other info.
-
Blowing up a vehicle does not delete it's element data, as the vehicle element is still there. You can use respawnVehicle spawnVehicle to respawn the vehicle.
-
Here's an untested example that draws nametags above player's heads: addEventHandler("onClientRender", root, function() local players = getElementsByType("player") --Get all players currently in the server. local x, y, z = getElementPosition(localPlayer) --Get the position of the local player. for key, player in ipairs(players) do if player ~= localPlayer and isElementOnScreen(player) then --If the player is on localPlayer's screen local px, py, pz = getElementPosition(player) --Get position of player to draw nametag if isLineOfSightClear(x, y, z, px, py, pz) then --If the localPlayer can see the target player local distance = getDistanceBetweenPoints3D(x, y, z, px, py, pz) --Get the distance to determine scale if distance <= 50 then local sx, sy = getScreenFromWorldPosition(px, py, pz+1) --Get the localPlayer's screen position to draw the nametag at, from the target player's world positon. if sx then --Make sure the function didn't return false local scale = math.min(15 / distance, 1.4) --Determine text scale dxDrawText(tostring(getPlayerName(player)), sx, sy, sx, sy, tocolor(0, 0, 0), scale) --Draw the text end end end end end end) Another untested example which draws text at fixed locations given by a table: addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) --localPlayer's pos for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) --get the string to draw and the position to draw it at from the table. local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) --Distance between player and text position if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) --Get the local player's screen position to draw the text at, from the text's world position. if sx then --Make sure the function didn't return false. local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) It should be obvious now that you need to use getScreenFromWorldPosition to draw texts at positions relative to the world.
-
Here, use this client-side; This will draw your panel when the player dies, until he spawns again. Try to learn from it, if you have any questions, post them up. local function drawPanel() dxDrawImage(306, 186, 399, 344, "wdspawn.png", 0, 0, 0, tocolor(0, 0, 0, 160), false) dxDrawText("Spawn", 405, 334, 605, 378, tocolor(255, 255, 255, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) end --When the player dies addEventHandler("onClientPlayerWasted", localPlayer, function() addEventHandler("onClientRender", root, drawPanel) --Draw the panel each frame using onClientRender end) --When the player spawns addEventHandler("onClientPlayerSpawn", localPlayer, function() removeEventHandler("onClientRender", root, drawPanel) --Stop drawing the panel by removing the event handler end)
-
You are using spawnPlayer incorrectly. Check the link. It expects thePlayer, x, y, z, rotation, skin. You're forgetting rotation in every setTimer, it comes before skin.
-
Okay, I edited the code and took "local screenWidth, screenHeight = guiGetScreenSize()" out of loadingtravel() because there was no need to get the screen size every render. And anytime .
-
Try using this: local angle, handled local screenWidth, screenHeight = guiGetScreenSize() function loadingtravel() angle = angle +7 dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0) end addEvent("onClientMapStopping", true) addEventHandler("onClientMapStopping", root, function() if not handled then handled = true angle = 0 fadeCamera ( false, 0, 0, 0, 0 ) addEventHandler("onClientRender", root, loadingTavel) local sound = playSound("audio/xd.mp3") setSoundVolume(sound, 1.0) end end) addEvent("onClientMapStarting", true) addEventHandler("onClientMapStarting", root, function() if handled then fadeCamera(true, 0) removeEventHandler("onClientRender", root, loadingtravel) handled = false end end) I used race to find the events for the when the map stops and starts. You were also trying to play a sound each time GTA renders a frame, which could be 60 times a second by using playSound with onClientRender. Make sure .mp3 is in the folder audio, in your resouce. Also make sure it is correctly added in the meta.xml of your resource.
-
addEventHandler("onPlayerLogin", root, function(_, account) local name = getAccountName(account) setPlayerName(source, name) end)
-
Try this instead: function onPanelHideTagButtonClicked ( btn, state) if button == 'left' and state == 'up' then setPlayerNametagShowing(localPlayer, not isPlayerNametagShowing(localPlayer)) -- set the nametag visibility to exactly the opposite of the current visibility. end end The issue was on line 3, you used setPlayerNametagShowing in the if condition instead of isPlayerNametagShowing. As for the blip, You will need to find the script where it is defined, and then use setElementVisibleTo(blip, root, false) to hide it completely.
-
Line 49 in your server-side snippet. addEventHandler("pickupBall", true) should be corrected to: addEvent("pickupBall", true) You should also type /debugscript 3, ingame for info and errors.