Jump to content

mazarati21

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by mazarati21

  1. Hi, try this local colShapes = {} function DropWeapon() local _, _, r = getElementRotation(source) local x, y, z = getElementPosition(source) setPedAnimation(source, "BOMBER", "BOM_plant_loop", -1, true, false, false, false) setTimer(setPedAnimation, 1500, 1, source, false) takeWeapon(source, 2) local obj = createObject(333, x + math.sin(math.rad(-r)) * 1, y + math.cos(math.rad(-r)) * 1, z - 1, 90) local col = createColSphere(x + math.sin(math.rad(-r)) * 1, y + math.cos(math.rad(-r)) * 1, z, 0.5) colShapes[col] = obj -- Association of col with obj addEventHandler("onColShapeHit", col, function(hitter) if getElementType(hitter) == "player" then if colShapes[source] then outputChatBox("ENTER", hitter, 255, 255, 0, true) bindKey(hitter, "F", "down", TakeWeapon, source) end end end) addEventHandler("onColShapeLeave", col, function(hitter) if getElementType(hitter) == "player" then if colShapes[source] then outputChatBox("EXIT", hitter, 255, 255, 0, true) unbindKey(hitter, "F", "down", TakeWeapon) end end end) end addEvent("dropKatana", true) addEventHandler("dropKatana", root, DropWeapon) function TakeWeapon(player, key, keyState, col) local obj = colShapes[col] if isElement(obj) then giveWeapon(player, 2, 1, true) setPedAnimation(player, "BOMBER", "BOM_plant_loop", -1, true, false, false, false) setTimer(setPedAnimation, 1500, 1, player, false) unbindKey(player, "F", "down", TakeWeapon) -- Destroy the object and its associated collision shape destroyElement(obj) destroyElement(col) colShapes[col] = nil -- Clear the reference to avoid memory leaks end end
  2. Hi, try this local lastDeathTime = {} function onPlayerWasted(totalAmmo, killer) local playerName = getPlayerName(source) local currentTime = getTickCount() -- Check if the player has already been processed recently if lastDeathTime[playerName] and currentTime - lastDeathTime[playerName] < 1000 then return end lastDeathTime[playerName] = currentTime if isElement(killer) and getElementType(killer) == "player" then local killerName = getPlayerName(killer) local victimName = getPlayerName(source) if killer == source then -- suicide outputChatBox(playerName .. " died") else outputChatBox(killerName .. " killed " .. victimName) end else outputChatBox(playerName .. " died") end end addEventHandler("onPlayerWasted", root, onPlayerWasted)
  3. Try this way local playerVehicleCount = {} -- Table to keep track of player vehicle counts local maxVehiclesPerPlayer = 5 -- Maximum number of vehicles a player can spawn function makeVehicleCmd(thePlayer, cmd, id) id = tonumber(id) if not id then return outputChatBox("SYNTAX: /"..cmd.." [Vehicle ID]", thePlayer, 255, 194, 14) end if not playerVehicleCount[thePlayer] then playerVehicleCount[thePlayer] = 0 end if playerVehicleCount[thePlayer] >= maxVehiclesPerPlayer then return outputChatBox("You have reached the maximum number of vehicles you can spawn.", thePlayer, 255, 0, 0) end local x, y, z = getElementPosition(thePlayer) local rx, ry, rz = getElementRotation(thePlayer) local vehicle = createTestElement(thePlayer, "vehicle", id, x, y, z, rx, ry, rz) if vehicle then setElementPosition(thePlayer, x, y, z + 3) setElementInterior(vehicle, getElementInterior(thePlayer)) setElementDimension(vehicle, getElementDimension(thePlayer)) playerVehicleCount[thePlayer] = playerVehicleCount[thePlayer] + 1 -- Attach an event handler to decrease vehicle count when the vehicle is destroyed addEventHandler("onElementDestroy", vehicle, function() if playerVehicleCount[thePlayer] then playerVehicleCount[thePlayer] = math.max(0, playerVehicleCount[thePlayer] - 1) end end) end end addCommandHandler("cm", makeVehicleCmd, false, false) function resetPlayerVehicleCount() playerVehicleCount[source] = nil end addEventHandler("onPlayerQuit", getRootElement(), resetPlayerVehicleCount)
  4. Hi there try this: local playerVehicleCount = {} -- Table to keep track of player vehicle counts local maxVehiclesPerPlayer = 5 -- Maximum number of vehicles a player can spawn function makeVehicleCmd(thePlayer, cmd, id) id = tonumber(id) if not id then return outputChatBox("SYNTAX: /"..cmd.." [Vehicle ID]", thePlayer, 255, 194, 14) end -- Initialize player's vehicle count if not already done if not playerVehicleCount[thePlayer] then playerVehicleCount[thePlayer] = 0 end -- Check if player has reached the spawn limit if playerVehicleCount[thePlayer] >= maxVehiclesPerPlayer then return outputChatBox("You have reached the maximum number of vehicles you can spawn.", thePlayer, 255, 0, 0) end local x, y, z = getElementPosition(thePlayer) local rx, ry, rz = getElementRotation(thePlayer) local element = createTestElement(thePlayer, "vehicle", id, x, y, z, rx, ry, rz) if element then setElementPosition(thePlayer, x, y, z + 3) setElementInterior(element, getElementInterior(thePlayer)) setElementDimension(element, getElementDimension(thePlayer)) playerVehicleCount[thePlayer] = playerVehicleCount[thePlayer] + 1 -- Increment the vehicle count end end addCommandHandler("cm", makeVehicleCmd, false, false) -- Optional: Reset vehicle count when a player leaves the server function resetPlayerVehicleCount() playerVehicleCount[source] = nil end addEventHandler("onPlayerQuit", getRootElement(), resetPlayerVehicleCount)
  5. local sounds = {} addEventHandler("onClientResourceStart", getRootElement(), function() local isLoggedIn = getElementData(localPlayer, "loggedIn") if isLoggedIn then sounds[1] = { file = "files/tenger.mp3", x = 1382.8380126953, y = 479.56735229492, z = 20.468042373657, maxDistance = 50 } sounds[2] = { file = "files/city.mp3", x = 1362.4620361328, y = -22.705436706543, z = 95.041290283203, maxDistance = 5000 } for _, soundData in ipairs(sounds) do local soundElement = playSound3D(soundData.file, soundData.x, soundData.y, soundData.z, true) setSoundMaxDistance(soundElement, soundData.maxDistance) setSoundVolume(soundElement, 1) end end end ) Try this
  6. mazarati21

    Parachute

    Hi, what functions do i need to make a parachute open automatically if higher by 40 z position units from the ground.
  7. https://community.multitheftauto.com/index.php?p=resources&s=details&id=16113 Clone of the clan panel from SAAF server. ANSWER: cloning a script visually (reproduction with code from scratch) isn't forbidden, just like you he referred it's "like" the SAAF panel and you didn't present evidence to show it uses stolen code. Sorry, but we can't help
  8. Yeah like <clans> <clan name="Any" rules="sadsadsadasd"> </clan> <clan name="owadas" rules="text..."> </clan> </clans>
  9. Thanks, and how to save it for each team?
  10. Hello, i'd like to know what functions do i need to get the text from the memo on client side then trigger it to the server and get the team name to be able to save the text for each team and save in xml file.
  11. This function might help you: https://wiki.multitheftauto.com/wiki/ShowCursor
  12. Use this: https://wiki.multitheftauto.com/wiki/SetTimer
  13. mazarati21

    Armour Help

    You can use this. https://wiki.multitheftauto.com/wiki/DxDrawRectangle then dxDrawText("Armor: "..armor.."%" etc..
  14. mazarati21

    Armour Help

    Something like this to get the player health. local armor = math.ceil(getPedArmor(localPlayer))
  15. Have you tried this? https://wiki.multitheftauto.com/wiki/SetWeaponProperty
  16. Right here: https://community.multitheftauto.com/index.php?p=resources&s=details&id=693
  17. You a space between exports and Messages.
  18. Hello i'd like to know how do i save the checkbox state when the player logouts out / quit the server.
  19. Create a folder. Then create a meta.xml <meta> <info author="Name" description="Engineoff" version="1.0" type="script" /> <script src="server.lua" type="server" /> </meta> and create another file server.lua function engineoff (thePlayer, seat, jacked) if seat ==0 and not jacked then setVehicleEngineState(source, false) setVehicleLocked(source, false) end end addEventHandler("onVehicleExit", root, engineoff)
  20. local blocked_players = {} addEventHandler("onClientChatMessage",root,function() if (blocked_players[source]) then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you blocked him.") end end) function block(cmd,plyname) local target = getPlayerFromName(plyname) if (plyname and target) then if (not blocked_players[target]) then blocked_players[target] = true; outputChatBox("player"..plyname.." blocked!") else blocked_players[target] = nil; outputChatBox("player"..plyname.." unblocked!") end else outputChatBox("player not found") end end addCommandHandler("block", block)
  21. This code works fine here. function engineoff (thePlayer, seat, jacked) if seat ==0 and not jacked then setVehicleEngineState(source, false) setVehicleLocked(source, false) end end addEventHandler("onVehicleExit", root, engineoff) Server side.
  22. Try this: function MarkerHit (player,hitElement) local level = getPlayerWantedLevel (player) -- Get player stars if (level < 5) then return outputChatBox( "You must have 5 starts to reset them", player ) end if getPlayerMoney(player) < 500 then outputChatBox("You dont have enought money", player, 255, 0, 0) return end outputChatBox("You lost your stars", player, 255,255,0) setPlayerWantedLevel (player, 0 ) takePlayerMoney(player, 500) end addEventHandler( "onMarkerHit", Marker, MarkerHit )
  23. Better to use this: --This will disable original hud function hideall(player) setPlayerHudComponentVisible ( "ammo", false ) setPlayerHudComponentVisible ( "area_name", false ) setPlayerHudComponentVisible ( "armour", false ) setPlayerHudComponentVisible ( "breath", false ) setPlayerHudComponentVisible ( "clock", false ) setPlayerHudComponentVisible ( "health", false ) setPlayerHudComponentVisible ( "money", false ) setPlayerHudComponentVisible ( "vehicle_name", false ) setPlayerHudComponentVisible ( "weapon", false ) end addEventHandler ( "onClientResourceStart", getRootElement(), hideall )
×
×
  • Create New...