Jump to content

βurak

Members
  • Posts

    370
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by βurak

  1. hello you can use events you can create an event on client side and run it with triggerClientEvent on server side example: server addEventHandler("onPlayerJoin", root, function() triggerClientEvent(source, "testEvent", source) -- execute event end ) client addEvent("testEvent", true) addEventHandler("testEvent", root, function() --do something here end ) or you can browse this script of IIYAMA I also suggest you to use "onPlayerJoin" Event for key binding.
  2. can you show the code and tell us where and what you want to do?
  3. try to do it like this <min_mta_version server="1.5.4-9.11342" client="1.5.4-9.11342" />
  4. what is not working? i tested it works fine for me
  5. I'm not sure but you can try this local allCommands = {} addEventHandler("onResourceStart", resourceRoot, function(res) -- res = the resource that just started local resourceName = getResourceName(res) local commands = getCommandHandlers(res) -- get all commands from the resource if not (allCommands[resourceName]) then allCommands[resourceName] = {} end for _, command in pairs(commands) do table.insert(allCommands[resourceName], command) outputDebugString("Comand found in "..resourceName.." : "..command) end end) addCommandHandler("testing",function() end)
  6. By the way, if the player suddenly jumps out of the car while driving at 100 kilometers speed, the sound may still work, you can add the following code line for this if(isPedInVehicle(localPlayer) == false) then setSoundPaused(soundChime, true) end
  7. hello you can use timer I edited Tekken's code, you can do it like this function getElementSpeed(theElement, unit) -- Check arguments for errors assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") local elementType = getElementType(theElement) assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) -- Setup our multiplier to convert the velocity to the specified unit local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit return (Vector3(getElementVelocity(theElement)) * mult).length end local soundChime = playSound("speedchime.mp3", true, false) setSoundPaused(soundChime, true) function speedchime() local theVehicle = getPedOccupiedVehicle(localPlayer) if(theVehicle and getElementModel(theVehicle) == 560) then -- is player have vehice and id is 560 ? if(getElementSpeed(theVehicle, 1) >= 100) then -- is speed equal or greater then 100 ? if(isSoundPaused(soundChime) == true) then -- is sound Paused ? setSoundPaused(soundChime, false) -- play sound end else if(isSoundPaused(soundChime) == false) then -- is sound not paused setSoundPaused(soundChime, true) -- pause sound end end end end local soundStatusUpdater = setTimer(speedchime, 200, 0)
  8. addEventHandler("onResourceStart", resourceRoot, function(res) local commandsList = {} --table to store commands for _, subtable in pairs( getCommandHandlers() ) do local commandName = subtable[1] local theResource = subtable[2] if not commandsList[theResource] then commandsList[theResource] = {} end table.insert( commandsList[theResource], commandName ) local commands = getCommandHandlers( theResource ) for _, command in pairs( commands ) do commandFound = command if commandFound then local resourceName = getResourceName(theResource) outputDebugString("Commands found in "..resourceName..": "..commandFound, 3, 255, 0, 0) end end end end)
  9. hi you can use textlib for this kind of stuff I use it too it works example local screenW, screenH = guiGetScreenSize() test = dxText:create("Test", screenW/2, screenH/2, false) test:font("default-bold") test:scale(4.0) test:color(255,255,255,255) test:visible(false) addCommandHandler("fade", function() test:visible(true) Animation.createAndPlay(test, dxTextFadeIn(3000)) end )
  10. local blip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000) local finishMarker = createMarker(-715.8314, 2328.1269, 125.6, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", finishMarker, function(hitElement) if(getElementType(hitElement) == "player" and isElement(blip)) then destroyElement(blip) end end )
  11. function removeBlip(posX, posY, posZ) for _,blip in ipairs(getElementsByType("blip")) do local x,y,z = getElementPosition(blip) if(posX == x and posY == y and posZ == z) then destroyElement(blip) end end end local blip = createBlip (-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000) setTimer(function() addCommandHandler ( "blip", function ( thePlayer ) for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end ) end, 5000, 0) end function finish() removeBlip (-715.8314, 2328.1269, 44.1525) end maybe something like this?
  12. I don't understand. Do you want to create a panel for this function?
  13. local theBlip = createBlip(0, 0, 4, 2, 255, 255, 255, 255) function removeBlip(posX, posY, posZ) for _,blip in ipairs(getElementsByType("blip")) do local x,y,z = getElementPosition(blip) if(posX == x and posY == y and posZ == z) then destroyElement(blip) end end end removeBlip(0, 0, 4)
  14. merhaba bu şekilde yapabilirsin eğer freeroam scripti gibi scriptler kullanmıyorsanız sorunsuz çalışacaktır. local playerBlips = {} function setPlayerColorAndClearNick(player) local clearedNick = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") setPlayerName(player, clearedNick) local randomR = math.random(0, 255) local randomG = math.random(0, 255) local randomB = math.random(0, 255) if(not isElement(playerBlips[player])) then playerBlips[player] = createBlipAttachedTo(player, 0, 2, randomR, randomG, randomB, 255) end setPlayerNametagColor(player, randomR, randomG, randomB) end addEventHandler("onResourceStart", resourceRoot, function() for _,player in ipairs(getElementsByType("player")) do setPlayerColorAndClearNick(player) end end ) addEventHandler("onPlayerJoin", root, function() setPlayerColorAndClearNick(source) end ) addEventHandler("onPlayerQuit", root, function() if(isElement(playerBlips[source])) then destroyElement(playerBlips[source]) playerBlips[source] = nil end end )
  15. thank you yes i thought of doing that too
  16. hello, I tried your solution but it didn't work, instead I transferred the rotation finder codes to the client side and ran it with triggerClientEvent on the server side, no problems at the moment. works interestingly server function zombieBehaviour() for i=1,#zombies do -- face toward zombie to player if(zombieDatas[zombies[i]].Target ~= nil) then if(isElement(zombies[i])) then triggerClientEvent(root, "faceTowardZombie", zombies[i], zombies[i], zombieDatas[zombies[i]].Target) end end end end behaviourUpdater = setTimer(zombieBehaviour, 130, 0) client function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end addEvent("faceTowardZombie", true) addEventHandler("faceTowardZombie", root, function(theZombie, theTarget) local zombieX, zombieY, zombieZ = getElementPosition(theZombie) local playerX, playerY, playerZ = getElementPosition(theTarget) local rotX, rotY, rotZ = getElementRotation(theZombie, "default") setElementRotation(theZombie, rotX, rotY, findRotation(zombieX, zombieY, playerX, playerY), "default", true) end ) I think I'll have to rewrite these script, thank you for your answers.
  17. https://streamable.com/y18hzw what I'm talking about is a bug like this, this bug never happens on the client side, I tested it many times, the script in the video is server side distortion occurs in the rotation of the ped as in the video
  18. Let me take a video of this
  19. The problem is that if you hit the peds with a fist from the face, the rotation will break down at some point, I know it will work fine you can try it it. is not possible for scripts to mix because I only run this script, all other scripts are default scripts
  20. I simplified the code but it still makes the same error function findRotation(x1, y1, x2, y2) local t = -math.deg(math.atan2(x2 - x1, y2 - y1 )) return t < 0 and t + 360 or t end local zSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287} local zombies = {} local zombieDatas = {} local behaviourUpdater local theZombie = createPed(0, 0, 0, 4) local theTarget = getPlayerFromName("Burak2346") function zombieBehaviour() local zombieX, zombieY, zombieZ = getElementPosition(theZombie) local playerX, playerY, playerZ = getElementPosition(theTarget) setElementRotation (theZombie, zombieX, zombieY, findRotation(zombieX, zombieY, playerX, playerY), "default", true) end behaviourUpdater = setTimer(zombieBehaviour, 130, 0) I'm sure there is something on the server side peds
  21. yes I tried it, but the result has not changed. The interesting thing is that this error does not occur on the client side. I don't know what the error is caused by, but there is something on the server side. or I'm doing something wrong
  22. hello when the zombie amount is 100 or above, when I attack the zombie, the rotation corruption occurs as in the picture. function findRotation(x1, y1, x2, y2) local t = -math.deg(math.atan2(x2 - x1, y2 - y1 )) return t < 0 and t + 360 or t end local zSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287} local zombies = {} local zombieDatas = {} local behaviourUpdater function createZombie(posX, posY, posZ, targetPlayer, typeZombie) local randomSkin = math.random(1, #zSkins) local theZombie = createPed(randomSkin, posX, posY, posZ) if(typeZombie == "green") then local randomWalkstyle = math.random(1, 2) if(randomWalkstyle == 1) then randomWalkstyle = "walk_old" elseif(randomWalkstyle == 2) then randomWalkstyle = "run_old" end zombieDatas[theZombie] = {TypeZombie = "green", Walkstyle = randomWalkstyle, State = "idle", Target = targetPlayer} table.insert(zombies, theZombie) outputDebugString("Zombie Type: "..zombieDatas[theZombie].TypeZombie) outputDebugString("Zombie Walkstyle: "..zombieDatas[theZombie].Walkstyle) outputDebugString("State: "..zombieDatas[theZombie].State) outputDebugString("Target: "..getElementType(zombieDatas[theZombie].Target)) return theZombie end end function removeZombie(theZombie) if(isElement(theZombie)) then if(zombieDatas[theZombie].TypeZombie ~= nil) then zombieDatas[theZombie] = nil for k,_ in pairs(zombies) do if(theZombie == zombies[k]) then destroyElement(zombies[k]) zombies[k] = nil break end end end end end addCommandHandler("removezombie",function() for k,v in pairs(zombies) do removeZombie(zombies[k]) end end) addCommandHandler("createzomb", function(player) for i=1,10 do local x,y,z = getElementPosition(player) createZombie(x, y +1, z, player, "green") end end) function zombieBehaviour() for i=1,#zombies do -- face toward zombie to player if(zombieDatas[zombies[i]].Target ~= nil) then if(isElement(zombies[i])) then local zombieX, zombieY, zombieZ = getElementPosition(zombies[i]) local playerX, playerY, playerZ = getElementPosition(zombieDatas[zombies[i]].Target) setElementRotation (zombies[i], zombieX, zombieY, findRotation(zombieX, zombieY, playerX, playerY), "default", true) end end end end behaviourUpdater = setTimer(zombieBehaviour, 130, 0) Red marked peds have a broken rotation while others are facing the player I did not see this error on the client side, it happens on the server side
  23. Since the vehicle was exploded by you, the same event is triggered again, that is, because the white vehicle did not explode, 1 time because the black vehicle exploded 2 I'm not sure you can use this to solve this problem if(getElementHealth(source) > 0) then outputChatBox("boom") end
×
×
  • Create New...