Jump to content

βurak

Members
  • Posts

    370
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by βurak

  1. combine it with zombieHealth here's how triggerClientEvent(source, "add:notification", source, "bot hp: "..zombieHealth, "info", true)
  2. There is a typo in your code, change it like this You are passing getElementData to the parameter completely as a string local zombieHealth = tostring(getElementData(zomb, "blood")) triggerClientEvent(source, "add:notification", source, zombieHealth, "info", true)
  3. take a look at this https://wiki.multitheftauto.com/wiki/CreateMarkerAttachedTo
  4. Can you change root to localPlayer? I'm not sure but it might work addEventHandler("onClientWeaponFire", localPlayer, noDamageToPlayersFromCustomWeapons)
  5. you already got what you want here what more do you want?
  6. The blue team and the red team are separate teams, your code only checks the red team, and if you want to turn off friendlyFire for the blue team, you can do it this way function noDamageToPlayersFromCustomWeapons(target) if(target and getElementType(target) == "player") then local playerTeam = getPlayerTeam(localPlayer) local targetTeam = getPlayerTeam(target) local playerTeamName local targetTeamName if(playerTeam and targetTeam) then playerTeamName = getTeamName(playerTeam) targetTeamName = getTeamName(targetTeam) if (playerTeamName == targetTeamName) then cancelEvent() end end end end addEventHandler("onClientWeaponFire", root, noDamageToPlayersFromCustomWeapons) but remember this will be valid for all teams if you want to create a team with friendly fire on except for blue and red you will need to edit the code
  7. Change the if structure where getElementType is like this if(target and getElementType(target) == "player") then
  8. try this function noDamageToPlayersFromCustomWeapons(target) if(getElementType(target) == "player") then local playerTeam = exports.Teams:isPlayerInTeam(localPlayer, "Red") local targetTeam = exports.Teams:isPlayerInTeam(target, "Red") if (playerTeam == targetTeam) then cancelEvent() end end end addEventHandler("onClientWeaponFire", root, noDamageToPlayersFromCustomWeapons)
  9. βurak

    Marker

    yes it is possible getTickCount maybe will work for you? example: local DELAY_TELEPORT = 5000 -- millisecond delay local IntervalTeleport = 0 local teleportMarker = createMarker(0, 0, 3, "cylinder", 3.0, 255, 0, 0, 255) addEventHandler("onMarkerHit", teleportMarker, function(hitElement) if(getElementType(hitElement) == "player") then if(IntervalTeleport and getTickCount() - IntervalTeleport > DELAY_TELEPORT) then --teleport player every 5 second setElementPosition(hitElement, 106.99030, 1924.18860, 18.52914) IntervalTeleport = getTickCount() else outputChatBox("You need to wait 5 seconds!", hitElement, 255, 0, 0, false) end end end )
  10. spfont = dxCreateFont("fonts/font.ttf", 21) local isAdded = false function speed() if(isAdded == false) then addEventHandler ("onClientRender", root, getspeed) isAdded = true end end addEventHandler("onClientVehicleEnter", root, speed) function wylacz () if(isAdded == true) then removeEventHandler("onClientRender", root, getspeed) isAdded = false end end addEventHandler("onClientVehicleExit", root, wylacz) function getspeed() local playerVehicle = getPedOccupiedVehicle(localPlayer) if(playerVehicle) then local sx, sy, sz = getElementVelocity(playerVehicle) kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) mphs = math.floor((((sx^2 + sy^2 + sz^2)^(0.5))*180)/1.6) health = getElementHealth(playerVehicle) name = getVehicleName(playerVehicle) currenthealth = math.floor(health/10) screenWidth, screenHeight = guiGetScreenSize() windowWidth, windowHeight = 300,170 left = screenWidth/1.18 - windowWidth/9.8 top = screenHeight/1.03 - windowHeight/20 dxDrawText ( " "..tostring(kmhs).."km/h", left , top +2, screenWidth +2, screenHeight , tocolor ( 255, 255, 255, 255 ), 1, spfont ) dxDrawText ( " "..tostring(kmhs).."km/h", left -2, top, screenWidth, screenHeight -2, tocolor ( 255, 255, 0, 255 ), 1, spfont ) dxDrawText ( " "..tostring(mphs).."mph", left , top -23, screenWidth +2, screenHeight , tocolor ( 255, 255, 255, 255 ), 1, spfont ) dxDrawText ( " "..tostring(mphs).."mph", left -2, top -25, screenWidth, screenHeight -2, tocolor ( 255, 255, 0, 255 ), 1, spfont ) end end try this
  11. use getPedMaxHealth function to find player's max health also use server side to set player's money I'm not sure but it could be like this client: function getPedMaxHealth(ped) -- Output an error and stop executing the function if the argument is not valid assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") -- Grab his player health stat. local stat = getPedStat(ped, 24) -- Do a linear interpolation to get how many health a ped can have. -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. local maxhealth = 100 + (stat - 569) / 4.31 -- Return the max health. Make sure it can't be below 1 return math.max(1, maxhealth) end addEventHandler("onClientClick", root, function(btn, state) if btn == 'left' and state == 'down' then if data.open == true then if isMouseInPosition(screenW * 0.4081, screenH * 0.3932, screenW * 0.1846, screenH * 0.0560) then if (getElementHealth(localPlayer) >= getPedMaxHealth(localPlayer)) then outputChatBox("Your hp is full!") return end if (getPlayerMoney(localPlayer) < 500) then outputChatBox("No money") return else if(getPlayerMoney(localPlayer) > 500 and getElementHealth(localPlayer) < getPedMaxHealth(localPlayer)) then triggerServerEvent("takeMoneyFromPlayer", localPlayer, 500) setElementHealth(localPlayer, getPedMaxHealth(localPlayer)) outputChatBox("Transaction completed") end end end if isMouseInPosition(screenW * 0.6007, screenH * 0.2943, screenW * 0.0176, screenH * 0.0352) then showGUI() end end end server: addEvent("takeMoneyFromPlayer", true) addEventHandler("takeMoneyFromPlayer", root, function(amount) local theAmount = tonumber(amount) takePlayerMoney(source, theAmount) end )
  12. You are using getElementData incorrectly, you should write the key you will receive. getElementData(localPlayer, "Key")
  13. You can solve this problem by creating an event on client side and running it with triggerClientEvent on server side client: local sound addEventHandler("onClientResourceStart", resourceRoot, function() setTimer(function() sound = playSound("winsound.mp3") end, 2000, 1) end ) addEvent("stopLoginMusic", true) addEventHandler("stopLoginMusic", root, function() if isElement(sound) then stopSound(sound) end end ) server: addEventHandler("onPlayerLogin", root, function() triggerClientEvent(source, "stopLoginMusic", source) end )
  14. you can check it with a variable local isAdded = false function speed() if(isAdded == false) then addEventHandler ("onClientRender", root, getspeed) isAdded = true end end addEventHandler("onClientVehicleEnter", root, speed)
  15. it will work like this function getVehicleInformation () local vehicle = getPedOccupiedVehicle(localPlayer) local vehicleModel if(vehicle) then vehicleModel = getElementModel(vehicle) end if (vehicle and vehiclesNoEngine[vehicleModel]) then setVehicleEngineState(vehicle, true) return false end if isPedInVehicle(localPlayer) and getPedOccupiedVehicleSeat(localPlayer) == 0 and getKeyState(e_KEY) then return true else return false end end
  16. getPedOccupedVehicle function returns false if player is not found in car so check if player is in car I'm not sure but it should be like this function getVehicleInformation () local vehicle = getPedOccupiedVehicle(localPlayer) local vehicleModel = getElementModel(vehicle) if (vehicle and vehiclesNoEngine[vehicleModel]) then setVehicleEngineState(vehicle, true) return false end if isPedInVehicle(localPlayer) and getPedOccupiedVehicleSeat(localPlayer) == 0 and getKeyState(e_KEY) then return true else return false end end
  17. βurak

    repet

    are you sure no other resource is causing this because only this code is not causing something like this I don't know what you are trying to do but you can do this code without a for loop
  18. βurak

    repet

    can you show the full code?
  19. hi, have you tried multiplying the coordinates by x and y instead of multiplying by screenW and screenH? example: dxDrawRectangle(x * 0.7727, y * 0.0208, x * 0.0547/100*vida, y * 0.1028, tocolor(255, 0, 0, 255), false)
  20. βurak

    repet

    If I'm not mistaken, you want to exit the loop when the condition is met, if so, you can exit the loop with the return command. if you want to continue the code from the bottom line you can also use break command setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') return else outputChatBox('false') end end end,1000,1)
  21. If you are talking about the market text, it is not possible, you can hide and open it, but you cannot change the coordinates, for this you have to do it from scratch.
  22. hello you don't need to use event, change thePlayer to hitElement in your first code and of course delete thePlayer from the parameter warpPedIntoVehicle(hitElement, jobVehicle)
×
×
  • Create New...