Jump to content

t3wz

Members
  • Posts

    149
  • Joined

  • Last visited

Everything posted by t3wz

  1. t3wz

    Help MTA Browser

    I had this problem some time ago you have to use injectBrowserMouseMove before inject clicks.
  2. addEvent ( "onPlayerTeamChange" ) addDebugHook( "postFunction", function ( _, _, _, _, _, player, team ) triggerEvent ( "onPlayerTeamChange", player, team ) end, { "setPlayerTeam" } ) then you use this (↑) custom event: addEventHandler ( "onPlayerTeamChange", root, function ( team ) setElementVisibleTo( criminalBlip, source, team == getTeamFromName ( "Criminal" ) ) end ) but as cited in the wiki "it may degrade script performance", there's other ways (timers, editing the admin panel² etc).
  3. There's no event which is triggered when the player change his team, then you need to edit the admin panel (or the script you use) to set the visibility of the blip when player change the team.
  4. Nope, you have to destroy the 'old' pickup, create another one and re-add the event handler. also use numeric indexes in the table isn't necessary. this might work: money = { { 31, -16, 4 }, { 4, 7, 4 }, { 19, 1, 3 } } local pickup, blip -- variables that will store the pickup and the blip function generatePickup ( ) -- function that will generate a new pickup -- Check if old pickup exists if pickup and isElement ( pickup ) then destroyElement ( pickup ) -- destroy the pickup destroyElement ( blip ) -- destroy the blip end -- get a position local pos = math.random ( 1, #money ) local x, y, z = unpack ( money[pos] ) -- Create a new pickup and store him in the 'pickup' variable pickup = createPickup ( x, y, z, 3, 1274, 20 ) -- Create the blip... blip = createBlipAttachedTo ( pickup, 52 ) end function pickupUse ( player ) -- Check if source is the pickup created in this script if source == pickup then givePlayerMoney ( player, 1000 ) end end addEventHandler ( "onPickupUse", root, pickupUse) -- for every pickup add the event handler generatePickup() -- call the function to create a pickup for the first time setTimer ( generatePickup, 1 * 60000, 0 ) -- every 1 minute the timer will call the function again, infinite times
  5. where's source defined? i think you've to use player in the lines 2-3 instead of source.
  6. yeah, if you want it invisible for only one player you've to use my previous code with one loop with getElementsByType + setElementVisibleTo ... true.
  7. you've to remove the visibility of the root element before. setElementVisibleTo( source, root, false ) setElementVisibleTo( source, hit, false )
  8. That's helpful, mainly the indentation part, great tutorial
  9. t3wz

    Ped distance

    Just to explain more... getDistanceBetweenPoints3D returns a float wich you can check if is lower or equal to 30 with the operator <= . if you want, here's a list of all operators of Lua, this might help in the future.
  10. t3wz

    Ped distance

    getDistanceBetweenPoints3D
  11. moveObject ( obj, 60000, 741.53302001953,-3456.9826660156,6.0948004722595 ) setTimer ( destroyElement, 60000, 1, obj ) obs: there's a portuguese section, you could post there if your english isn't good.
  12. cmd always will be delpump, you've to add id to the parameters of the pump_ren function (after cmd). function pump_rem ( p, cmd, id ) also you've to check if id is different than nil, if it's a number etc wiki have a well made explanation about parameters, check it.
  13. t3wz

    I need help

    Just check if the index is equal to 1, if is you draw the text with alpha 240, otherwise with alpha 140 if index == 1 then dxDrawText ( v1, 700, (-21)+(index*42), sx/2, 0, tocolor( 0, 0, 0, 240), 0.85, "default-bold", "center", "center", false, true, false, v8 ) else dxDrawText ( v1, 700, (-21)+(index*42), sx/2, 0, tocolor( 0, 0, 0, 140), 0.85, "default-bold", "center", "center", false, true, false, v8 ) end lines 38~49. is this what you want?.
  14. t3wz

    Help

    x, y, z = 0, 0, 3 function tentadayz() tent = createObject(964, x + 5, y, z - 1) tentCol = createColSphere(x + 5, y, z, 4) attachElements(tentCol, tent, 0, 0, 0) setElementData(tentCol, "parent", tent) setElementData(tent, "parent", tentCol) setElementData(tentCol, "tent", true) setElementData(tentCol, "vehicle", true) setElementData(tentCol, "MAX_Slots", 500) setElementData(tentCol, "M4", 100) setElementData(tentCol, "Dmr", 100) setElementData(tentCol, "Dmr Mag", 300) setElementData(tentCol, "M4 Mag", 100) setElementData(tentCol, "AK-47", 400) setElementData(tentCol, "AK Mag", 100) setElementData(tentCol, "Coyote Backpack", 50) setElementData(tentCol, "Toolbox", 100) setElementData(tentCol, "Desert Eagle Mag", 100) setElementData(tentCol, "Desert Eagle", 100) setElementData(tentCol, "Ghillie Suit", 50) setElementData(tentCol, "DMR Mag", 100) setElementData(tentCol, "DMR", 100) end tentadayz() setTimer ( tentadayz, 30 * 1000, 0 )
  15. you've to check if killer isn't false. addEventHandler( "onPlayerWasted", root, function( _, killer ) if killer and isElement ( killer ) and killer ~= source then local alivetime = getElementData( source, "alivetime" ) local name = getPlayerName( killer ) if tonumber( alivetime ) > 3 then outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) end end end )
  16. isElementWithinColShape
  17. ehh serverIP = false fetchRemote ( "http://ip4.telize.com/", function(r,e) if e == 0 then serverIP = r else print ( "error "..e.." when getting serverip !" ) end end ) function getServerIP ( ) return serverIP; end obs: setTimer need a number higher than -1 in the third parameter also make sure you're using this code in server side.
  18. you can use the clickedWorld parameter, something like this: function change ( b, s, x2, y2, _, _, _, clickedWorld ) if (b == 'left' and s == 'up') then for i = 1, #torso do if (x >= torso[i].x and x <= torso[i].w) and (y >= torso[i].y and y <= torso[i].h) then if (torso[i].tex and torso[i].mod) then if clickedWorld and isElement ( clickedWorld ) and getElementType ( clickedWorld ) == "ped" then addPedClothes ( clickedWorld, torso[i].tex, torso[i].mod, 0 ) end end end end end end
  19. That's because you're using source (in addPedClothes) when it is the "client's root element" and not a specific ped. see the wiki.
  20. Probably you use the freeroam resource, which has your own 'tag' script. if this is your case, you will need to remove these lines: addEventHandler('onPlayerChat', g_Root, function(msg, type) if type == 0 then cancelEvent() if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then outputChatBox("Stop spamming main chat!", source, 255, 0, 0) return else chatTime[source] = getTickCount() end if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then outputChatBox("Stop repeating yourself!", source, 255, 0, 0) return else lastChatMessage[source] = msg end local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. msg:gsub('#%x%x%x%x%x%x', ''), g_Root, r, g, b, true) outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) end end ) From fr_server.lua (lines 404~425). obs: this topic is about scripting, then you should have posted on this section.
  21. Well, this code: theTimer = setTimer(function() theTimer = nil end, 2000, 1) function timerDetails() if theTimer and isTimer ( theTimer ) then local remaining = getTimerDetails ( theTimer ) /1000 dxDrawText("Time : "..remaining, 574, 543, 790, 590, tocolor(255, 187, 23, 255), 1.50, "bankgothic", "left", "top", false, false, false, false, false) end end addEventHandler("onClientRender", root, timerDetails) works here.
  22. and? nobody will do all the work for you https://wiki.multitheftauto.com
  23. what about getting timer details after checking if it exists? if theTimer and isTimer ( theTimer ) then local remaining = getTimerDetails ( theTimer )
  24. t3wz

    Help

    you want to change the player's dimension? if yes... in "onMarkerHit" event source is "[...] the marker that got hit by the element." (you can see this at the wiki), you want the player to go to another dimension, not the marker, right? so you have to use the first parameter of onPlayerEnterVehicle function (which is attached to the event "onMarkerHit"). your final code will be like this: local marker = createMarker(13,1,3,"checkpoint",4.0,0,0,255,255) function onPlayerEnterVehicle ( hitElement, matchingDimension ) --local elementType = getElementType( hitElement ) -- this is unnecessary because you never use 'elementType' setElementDimension ( hitElement, 1 ) -- < see, i replaced [b]source[/b] (marker) with [b]hitElement[/b] (player, or vehicle maybe) end addEventHandler ( "onMarkerHit", marker, onPlayerEnterVehicle ) Sorry if my english isn't very well, i've done my best regards.
  25. it's the time (in minutes) to function be called. for example, "Message 1" will be called every 2 minutes, "another msg" every 1 etc
×
×
  • Create New...