FLUSHBICEPS
Members-
Posts
100 -
Joined
-
Last visited
-
Days Won
4
Everything posted by FLUSHBICEPS
-
local sw, sh = guiGetScreenSize() local pw, ph = 300, 200 local px, py = (sw - pw) / 2, (sh - ph) / 2 local vis = false local pnl = guiCreateWindow(px, py, pw, ph, "Freeroam Panel", false) guiSetVisible(pnl, vis) local btn1 = guiCreateButton(10, 30, 280, 40, "Deathmatch", false, pnl) local btn2 = guiCreateButton(10, 80, 280, 40, "No Knife Kills", false, pnl) local btn3 = guiCreateButton(10, 130, 280, 40, "No Warp To You", false, pnl) function panel() vis = not vis guiSetVisible(pnl, vis) showCursor(vis) end bindKey("F1", "down", panel) function b1click() -- Add your Deathmatch function here end addEventHandler("onClientGUIClick", btn1, b1click, false) function b2click() -- Add your No Knife Kills function here end addEventHandler("onClientGUIClick", btn2, b2click, false) function b3click() -- Add your No Warp To You function here end addEventHandler("onClientGUIClick", btn3, b3click, false)
-
local msg = false function checkVehHealth() local veh = getPedOccupiedVehicle(localPlayer) if veh then local currHealth = getElementHealth(veh) if currHealth <= 0 and not msg then outputChatBox("Your vehicle HP is 0", 255, 0, 0) msg = true elseif currHealth > 0 then msg = false end end end addEventHandler("onClientRender", root, checkVehHealth) u can use a boolean variable to ensure the message is only displayed once
-
the event triggers because u dont use the loss parameter to check the amount of health the vehicle lost in onClientVehicleDamage addEventHandler("onClientVehicleDamage", root, function(loss) local vehHP = getElementHealth(source) if currentHealth - loss <= 0 then end end)
-
when you use the onPlayerJoin event you are trying to create a vehicle too quickly its not guaranteed that the player will have finished loading in before the event is called If you try to create a vehicle before the player has finished loading in the game will probably crash onClientResourceStart --//-- executeCommandHandler("fahrzeugErstellen") Those will Check if the resources has been loaded it will use the command
-
Update an Order from Woocommerce using fetchRemote
FLUSHBICEPS replied to MADD NØG's topic in Scripting
u need to include the data you want to send as the third argument to the fetchRemote, also the method should be in string local apiKey = "..." local forumAddress = "..." function testing(orderID, content) local sendOptions = { connectionAttempts = 5, connectTimeout = 7000, method = "POST", headers = { ["Content-Type"] = "application/json", }, } local postData = toJSON({ status = "completed", }) fetchRemote(forumAddress.."/wp-json/wc/v3/orders/"..orderID.."?key="..apiKey, sendOptions, function(responseData, error) if error == 0 then outputChatBox("success" .. responseData) else outputChatBox("failed, " .. error) end end, postData) end- 1 reply
-
- 1
-
local name = result["table"]["items"][1]["name"] fetchRemote("[...]", function(data) local result = fromJSON(data) local name = result["table"]["items"][1]["name"] print(name) -- should work end, nil, true)
-
addEventHandler("onClientCursorMove", getRootElement(), function(relativeX, relativeY, absoluteX, absoluteY) local browserX, browserY = absoluteX - posX, absoluteY - posY injectBrowserMouseMove(webBrowser, browserX, browserY) end)
-
function oyuncuspawn(oyuncu) if not isElement(oyuncu) then return end showChat(oyuncu, true) local hesap = getPlayerAccount(oyuncu) if hesap and not isGuestAccount(hesap) then if isObjectInACLGroup("user."..getAccountName(hesap), aclGetGroup(takim1)) then spawnPlayer(oyuncu, -2477.9606933594, 494.64392089844, 30.07054901123, 90, takim1skin) elseif isObjectInACLGroup("user."..getAccountName(hesap), aclGetGroup(takim2)) then spawnPlayer(oyuncu, 588.4067402835, 875.51007080078, -42.497318267822 , 90, takim2skin) elseif isObjectInACLGroup("user."..getAccountName(hesap), aclGetGroup(takim3)) then spawnPlayer(oyuncu, -1424.4116210938, 501.22912597556, 18.229438781738, 90, takim3skin) elseif isObjectInACLGroup("user."..getAccountName(hesap), aclGetGroup(takim4)) then spawnPlayer(oyuncu, 2290.4890136719, 581.04016113281, 7.78125, 90, takim4skin) else --added if the player is not assigned to any group spawnPlayer(oyuncu, 1959.55, -1714.43, 10, 90, 0) end end fadeCamera(oyuncu, true) setCameraTarget(oyuncu, oyuncu) end addEventHandler("onPlayerJoin", root, function() oyuncuspawn(source) end) addEventHandler("onPlayerWasted", root, function() --fixed a typo arg1 setTimer(oyuncuspawn, 2500, 1, source) end) I recommend you to create a table and loop over the groups that would be much easier to modify the groups
-
“randomfoliage“ is the property name you are looking for
-
function rotatePos(x, y, w, h, rot) local cx = x + w / 2 local cy = y + h / 2 local ox = x - cx local oy = y - cy local rad = math.rad(rot) local cos = math.cos(rad) local sin = math.sin(rad) local nx = cx + ox * cos - oy * sin local ny = cy + ox * sin + oy * cos return nx, ny end --use local iW = -- item width local iH = -- item height local iX = -- item x position local iY = -- item y position local rot = 90 -- rotation local rX, rY = rotatePos(iX, iY, iW, iH, rot) dxDrawImage(rX, rY, iW, iH, "item.png", rot)
-
u can use onVehicleDamage to store the last player who damaged the vehicle function vehicleDamage(attacker) if attacker and getElementType(attacker) == "player" then setElementData(source, "lastVehicleDamager", attacker) end end addEventHandler("onVehicleDamage", getRootElement(), vehicleDamage) when the vehicle gets exploded u can get the last player who damaged it function vehicleExplode() local attacker = getElementData(source, "lastVehicleDamager") setElementData(source, "lastVehicleAttacker", attacker) end addEventHandler("onVehicleExplode", getRootElement(), vehicleExplode) now to check if the attacker is a vehicle or unknown you need to modify playerwasted_reward func function playerWasted_reward(ammo, attacker, weapon, bodypart) if attacker and attacker ~= source then local tempString if getElementType(attacker) == "player" then tempString = getPlayerName(attacker) .. " killed " .. getPlayerName(source) .. " (" .. getWeaponNameFromID(weapon) .. ")" elseif getElementType(attacker) == "vehicle" then local vehicleAttacker = getElementData(attacker, "lastVehicleAttacker") if vehicleAttacker then tempString = getPlayerName(vehicleAttacker) .. " killed " .. getPlayerName(source) .. " (" .. getWeaponNameFromID(weapon) .. ")" else tempString = "A vehicle killed " .. getPlayerName(source) .. " (" .. getWeaponNameFromID(weapon) .. ")" end end if bodypart == 9 then -- give a special reward for headshots tempString = tempString .. " (Headshot)" else -- give him / her a normal reward tempString = tempString .. " (" .. getBodyPartName(bodypart) .. ")" end outputChatBox(tempString) else outputChatBox(getPlayerName(source) .. " died.") end end addEventHandler("onPlayerWasted", getRootElement(), playerWasted_reward) also recommending to reset the elementdatas when a vehicle is repaired or respawned to avoid old data from being used in future events
-
The browsers content might not be fully loaded when resizeBrowser is called Try this one local browser local size = 200 local newSize = size local function getFakeHtml() iprint("ok") return "<html><body><h2>Hello world<h2></body></html>" end addCommandHandler("createTestBrowser", function() browser = createBrowser(size, size, true, false) setBrowserAjaxHandler(browser, "assets/index.html", getFakeHtml) addEventHandler("onClientBrowserCreated", browser, function () loadBrowserURL(browser, "http://mta/local/assets/index.html") addEventHandler("onClientRender", root, function() if newSize ~= size then resizeBrowser(browser, newSize, newSize) size = newSize end dxDrawImage(200, 200, size, size, browser) end) iprint("created") end) end) addEventHandler("onClientResourceStart", resourceRoot, function() local scx, scy = guiGetScreenSize() local width, height = 200, 20 local scroll = guiCreateScrollBar((scx - width)/2, (scy - height)/2, width, height, true, false) showCursor(true) addEventHandler("onClientGUIScroll", scroll, function() local scrollAmount = guiScrollBarGetScrollPosition(scroll) newSize = 200 + (scrollAmount/100 * 200) end) end) Not sure if it will solve the prob but you can give it a try
-
u need to loop through all players and set the visibility for each player individually pd_blip[player] = createBlipAttachedTo(player, 0, 3, 255, 0, 0, 255, 32767) -- invisible to the player setElementVisibleTo(pd_blip[player], player, false) -- loop and make the blip visible to everyone except the playet for _, otherPlayer in ipairs(getElementsByType("player")) do if otherPlayer ~= player then setElementVisibleTo(pd_blip[player], otherPlayer, true) end end
-
-- clientside function setSkinFromList(button, state) if button == "left" and state == "up" then local selectedRow, selectedCol = guiGridListGetSelectedItem(skins) if selectedRow and selectedRow ~= -1 then local skinID = tonumber(guiGridListGetItemText(skins, selectedRow, 2)) if skinID then triggerServerEvent("applySkin", localPlayer, skinID) end end end end addEventHandler("onClientGUIDoubleClick", skins, setSkinFromList, false) --serverside function applySkinHandler(thePlayer, skinID) if thePlayer and skinID then setElementModel(thePlayer, skinID) end end addEvent("applySkin", true) addEventHandler("applySkin", root, applySkinHandler)
- 6 replies
-
- skin save
- save system
- (and 4 more)
-
onPlayerQuit, quitType = "Kicked"
-
u should close ur "<options>" tags afaik
- 2 replies
-
- datalist html
- datalist
-
(and 1 more)
Tagged with:
-
handler help creating a shift drift script.
FLUSHBICEPS replied to weverton gabriel's topic in Scripting
You can use the isPlayerActuallyInVehicle useful function to check if a player is fully inside a vehicle, onEnter function is being called before the vehicle is fully loaded -
How your server stores job info? If it’s a team use getPlayerTeam
-
getPlayerJobs then I guess
-
You are calling in setTimer “SendTurfPayout” function and the function is sendJobPayout
-
function setWeatherHour() local hour, minute = getTime() local rHour = math.floor(hour) local weatherID = weatherHour[rHour] if weatherID then setWeather(weatherID) end end setTimer(setWeatherHour, 3600000, 0) addEventHandler("onResourceStart", resourceRoot, setWeatherHour)
-
use dxDrawRectangle instead
-
function sendTurfPayout() local playerJobs = {} -- getting all police for i, player in ipairs(getElementsByType('player')) do local job = exports.NGJobs:getPlayerJob(player) if (job == 'Police Officer') then if (playerJobs[player] == nil) then playerJobs[player] = 0 end playerJobs[player] = playerJobs[player] + 1 end end -- pay the players for player, count in pairs(playerJobs) do local cash = count * tonumber(get("*PAYOUT_CASH")) givePlayerMoney(player, cash) exports.NGMessages:sendClientMessage("Police: Here is $" .. tostring(cash) .. " payout.", player, 0, 255, 0) end end -- set the timer local payoutTime = tonumber(get("*PAYOUT_TIME")) if payoutTime then setTimer(sendTurfPayout, 60 * payoutTime * 1000, 0) end
-
u will need to create separate marker and blip for each player local markers = {} local blips = {} function woodCut(thePlayer) local one = math.random(#table) local x = table[one][1] local y = table[one][2] local z = table[one][3] local marker = createMarker(x, y, z-1, "cylinder", 2.0, 0, 255, 0) local blip = createBlipAttachedTo(marker, 22) markers[thePlayer] = marker blips[thePlayer] = blip setElementVisibleTo(blip, getRootElement(), false) setElementVisibleTo(blip, thePlayer, true) setElementVisibleTo(marker, getRootElement(), false) setElementVisibleTo(marker, thePlayer, true) outputChatBox("now Wood Man"..x..y..z, thePlayer, 0, 255, 255) check(thePlayer) end function check(thePlayer) local marker = markers[thePlayer] addEventHandler("onMarkerHit", marker, function(hitElement, matchingDimension) if hitElement == thePlayer and matchingDimension then outputChatBox("Hitted", hitElement, 0, 255, 255) destroyElement(marker) destroyElement(blips[thePlayer]) woodCut(thePlayer) end end ) end I’ve added two tables to store players markers and blips and made a few changes to both funcs
-
oops didn’t see, ur using getRealTime func, u should use getTime function to get in game time, also add if statement on weather variable to avoid any kind of error