Jump to content

NeXuS™

Retired Staff
  • Posts

    1,134
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by NeXuS™

  1. local playerBlips = {} local playerNames = {} local sX, sY = guiGetScreenSize() local mainW, mainH = 700, 600 local mainX, mainY = (sX-mainW)/2, (sY-mainH)/2 local multX, multY = 1366/sX, 768/sY function removeHex (name) return type (name) == "string" and string.gsub (name, "#%x%x%x%x%x%x", "") or name end addEventHandler("onClientResourceStart", root, function() mainWindow = guiCreateWindow(mainX, mainY, mainW, mainH, "Teleport", false) guiWindowSetSizable(mainWindow, false) mapImg = guiCreateStaticImage(5, 20, mainW, mainH-60, ":freeroam/map.png", false, mainWindow) teleportButton = guiCreateButton(5, mainH-35, mainW-10, 30, "Teleport me", false, mainWindow) playerBlip = guiCreateStaticImage(0, 0, 10, 10, ":freeroam/localplayerblip.png", false, mapImg) end) bindKey("m", "down", function() showCursor(not isCursorShowing()) end) addEventHandler("onClientRender", getRootElement(), function() for i, k in ipairs(getElementsByType("player")) do local pX, pY = getElementPosition(k) local xPerc, yPerc = (pX+3000)/6000, (3000-pY)/6000 --outputChatBox(xPerc .. " " .. yPerc) guiSetPosition(playerBlip, xPerc-10/mainW/2, yPerc-10/mainH/2, true) end end) addEventHandler("onClientGUIDoubleClick", getRootElement(), function() if source == mapImg then local tW, tH = guiGetSize(mapImg, false) local tX, tY = guiGetPosition(mapImg, false) outputChatBox("Map size", 255, 0, 0) outputChatBox(tW .. " " .. tH) local cX, cY = getCursorPosition() local cX, cY = cX*sX, cY*sY outputChatBox("Click position", 255, 0, 0) outputChatBox(cX .. " " .. cY) outputChatBox("Image position", 255, 0, 0) outputChatBox(mainX+tX .. " " .. mainY+tY) local cX, cY = cX-(mainX+tX), cY-(mainY+tY) outputChatBox("Click position on image", 255, 0, 0) outputChatBox(cX .. " " .. cY) local aX, aY = cX/tW, cY/tH outputChatBox("Relative values", 255, 0, 0) outputChatBox(aX .. " " .. aY) local mapX, mapY = math.floor(aX*6000-3000), math.floor(3000-aY*6000) outputChatBox("Map position", 255, 0, 0) outputChatBox(mapX .. " " .. mapY) setElementFrozen(localPlayer, true) setElementPosition(localPlayer, mapX, mapY, 0) setTimer(function() local _, _, _, foundZ = processLineOfSight(mapX, mapY, 3000, mapX, mapY, -3000) setElementPosition(localPlayer, mapX, mapY, foundZ) setElementFrozen(localPlayer, false) end, 100, 1) end end) addEventHandler("onClientGUIClick", getRootElement(), function() if source == mapImg then local tW, tH = guiGetSize(mapImg, false) local tX, tY = guiGetPosition(mapImg, false) outputChatBox("Map size", 255, 0, 0) outputChatBox(tW .. " " .. tH) local cX, cY = getCursorPosition() local cX, cY = cX*sX, cY*sY outputChatBox("Click position", 255, 0, 0) outputChatBox(cX .. " " .. cY) outputChatBox("Image position", 255, 0, 0) outputChatBox(mainX+tX .. " " .. mainY+tY) local cX, cY = cX-(mainX+tX), cY-(mainY+tY) outputChatBox("Click position on image", 255, 0, 0) outputChatBox(cX .. " " .. cY) local aX, aY = cX/tW, cY/tH outputChatBox("Relative values", 255, 0, 0) outputChatBox(aX .. " " .. aY) mapX, mapY = math.floor(aX*6000-3000), math.floor(3000-aY*6000) outputChatBox("Map position", 255, 0, 0) outputChatBox(mapX .. " " .. mapY) elseif source == teleportButton and mapX then setElementFrozen(localPlayer, true) setElementPosition(localPlayer, mapX, mapY, 0) setTimer(function() local _, _, _, foundZ = processLineOfSight(mapX, mapY, 3000, mapX, mapY, -3000) setElementPosition(localPlayer, mapX, mapY, foundZ) setElementFrozen(localPlayer, false) mapX, mapY = nil, nil, nil end, 100, 1) end end) Left every debugging in, in case you want to see how it works.
  2. Working on it on my server, rewriting the whole script, give me a minute.
  3. addEventHandler ("onClientRender", root, function () for _,v in ipairs (getElementsByType ("player")) do if (BLIPS [v] and NAMES [v]) then local x, y = getElementPosition (v) x = math.floor ((x + 3000) / 6000 * 655) - 4*multX y = math.floor ((3000 - y) / 6000 * 654) - 4*multY guiSetPosition (BLIPS [v], x, y, false) guiSetText (NAMES [v], removeHex (getPlayerName (v))) guiSetPosition (NAMES [v], x + 13, y - 5, false) end end end )
  4. Is it only this way if you change the resolution?
  5. Can you do a picture in-game of the problem? It's kinda hard to understand what you are trying to stay.
  6. local BLIPS = { } local NAMES = { } local screenW, screenH = guiGetScreenSize () local multX, multY = 1366/screenW, 768/screenH function removeHex (name) return type (name) == "string" and string.gsub (name, "#%x%x%x%x%x%x", "") or name end addEventHandler ("onClientResourceStart", resourceRoot, function () win = guiCreateWindow ((screenW - 674) / 2, (screenH - 716) / 2, 674, 716, "Teleporter", false) guiWindowSetSizable (win, false) guiSetAlpha (win, 1.00) guiSetVisible (win, false) map = guiCreateStaticImage (9, 23, 655, 654, ":freeroam/map.png", false, win) for _,v in ipairs (getElementsByType ("player")) do blip = guiCreateStaticImage (347, 337, 10, 10, ":freeroam/localplayerblip.png", false, map) name = guiCreateLabel (347, 337, 123, 20, "", false, map) guiSetFont (name, "default-bold-small") guiLabelSetColor (name, 24, 230, 39) BLIPS [v] = blip NAMES [v] = name end spawn = guiCreateButton (243, 682, 188, 24, "Teleport Me", false, win) guiSetFont (spawn, "clear-normal") guiSetProperty (spawn, "NormalTextColour", "FF19E528") end ) addCommandHandler ("map", function () if getElementData (localPlayer, "allowed") then guiSetVisible (win, not guiGetVisible (win)) showCursor (guiGetVisible (win)) end end ) local XP, YP addEventHandler ("onClientGUIClick", resourceRoot, function (button, _, x, y) if (button == "left") then if (source == map) then local winx, winy = guiGetPosition (win, false) local imgw, imgh = guiGetSize (map, false) local x, y = x - winx - 7*multX, y - winy - 20*multY local nx, ny = (x / imgw), (y / imgh) XP = (nx * 6000) - 3000 YP = (3000 - ny * 6000) elseif source == spawn and XP and YP then setElementPosition (localPlayer, XP, YP, 0) setElementFrozen (localPlayer, true) setTimer (function (localPlayer) _, _, _, ZP = processLineOfSight (XP, YP, 3000, XP, YP, -3000) setElementPosition (localPlayer, XP, YP, (ZP or 0) + 1) setElementFrozen (localPlayer, false) end, 300, 1, localPlayer) end end end ) addEventHandler ("onClientGUIDoubleClick", resourceRoot, function (button, _, x, y) if (button == "left") then if (source == map) then local winx, winy = guiGetPosition (win, false) local imgw, imgh = guiGetSize (map, false) local x, y = x - winx - 7*multX, y - winy - 20*multY local nx, ny = (x / imgw), (y / imgh) XP = (nx * 6000) - 3000 YP = (3000 - ny * 6000) setElementPosition (localPlayer, XP, YP, 0) setElementFrozen (localPlayer, true) setTimer (function (localPlayer) _, _, _, ZP = processLineOfSight (XP, YP, 3000, XP, YP, -3000) setElementPosition (localPlayer, XP, YP, (ZP or 0) + 1) setElementFrozen (localPlayer, false) end, 300, 1, localPlayer) end end end ) addEventHandler ("onClientRender", root, function () for _,v in ipairs (getElementsByType ("player")) do if (BLIPS [v] and NAMES [v]) then local x, y = getElementPosition (v) x = math.floor ((x + 3000) / 6000 * 655) - 4 y = math.floor ((3000 - y) / 6000 * 654) - 4 guiSetPosition (BLIPS [v], x, y, false) guiSetText (NAMES [v], removeHex (getPlayerName (v))) guiSetPosition (NAMES [v], x + 13, y - 5, false) end end end ) Try this one. I'm not sure if it'll work.
  7. These bushes could be stay there because of:
  8. NeXuS™

    Wanted

    These are the basics mate. You should read the LUA 5.3 Reference Manual if you can understand english well. If you cannot, you should just start scripting, and check if you have any information about "Scripting in MTA" in your language. (MTA:SA wiki page)
  9. To actually use the data which was retrieved by dbQuery, you'll have to use dbPoll, which returns a table from the dbQuery's userdata. You'll want to know, if you got any data, because that table can be empty. (There is no data selected from the SQL table, and it's possible if you do a SELECT with WHERE = ?) local dbConnection = dbConnect(...) local nrQuery = dbQuery(dbConnection, "SELECT phoneNumber WHERE accID=?", playerData[thePlayer]["accID"]) -- Getting a data from the SQL table with a WHERE. local rQuery = dbPoll(nrQuery, -1) -- You can set a timeout here, if you are worried about timing out. if #rQuery > 0 then -- Do some work with the phone number. local phoneNumber = rQuery[1]["phoneNumber"] -- This would work only, if the player cannot buy more than one phone numbers, if he can, you'll have to cycle through the table. You can only access data got from a dbPoll's table by indexing it with the SQL Table's structure. end
  10. I think you could try using peds instead of actual players, as players fall under the "ped" element type.
  11. @Mr.Loki, because colshapes has a height value, but markers go up on height very high.
  12. function OpenWindow(thePlayer) local _, _, mZ = getElementPosition(source) -- Marker position local _, _, pZ = getElementPosition(hitElement) -- Player position if pZ <= mZ + 3 then if thePlayer == getLocalPlayer() and (getElementData(localPlayer,"Level")) <= 59 then outputChatBox("You must be atleast Level 60 to access the Special Weapon Shop!", 255, 0, 0) else if ( guiGetVisible ( specialWshop ) == false ) and thePlayer == getLocalPlayer() then guiSetVisible ( specialWshop, true ) showCursor ( true ) end end end end addEventHandler("onClientMarkerHit", special, OpenWindow) addEventHandler("onClientMarkerHit", specialSC, OpenWindow) This doesn't work at all?
  13. I'm sure it's not yours. Try implementing the in-built MTA SQL functions, or install the MySQL module made by ryden.
  14. Try this one. local markerE = createMarker(...) -- Creating the marker addEventHandler("onClientMarkerHit", markerE, function(hitElement) -- Event local _, _, mZ = getElementPosition(source) -- Marker position local _, _, pZ = getElementPosition(hitElement) -- Player position if pZ <= mZ + 3 then -- Checking if the player's position is below the marker position + 3 -- Do your code. end end)
  15. It's easier to remove data with the first method (especially, if the player disconnects).
  16. local spots = { {2488.32886, -1670.63599, 12.33595}, {2490.92886, -1670.63599, 12.33595}, {2495.92886, -1670.63599, 12.33595} } for k,v in ipairs (spots) do marker1 = createMarker(v[1],v[2],v[3], "cylinder", 1.2, 22, 22, 22) -- Creating the markers when the resource is started. addEventHandler("onMarkerHit", marker1, getHp) -- Handling markerhits for every marker which is created. end function getHp (player) local money = getPlayerMoney(player) local hpp = getElementHealth(player) if money >= 1000 and hpp < 100 then setElementHealth(player, 100) takePlayerMoney(player, 1000) elseif money >= 1000 and hpp >= 100 then outputChatBox("Your HP is already full", player, 222, 44, 22) elseif money < 1000 then outputChatBox("You don't have enough money", player, 222, 44, 22) end end I think this one should work.
  17. local modifier = 1 local day = getRealTime().weekday if day == 0 or day == 6 then -- 0 = sun 6 = sat outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m #FFFFFF || Exp: #32FF32"..experiences.."#F7FE2E 2x",killer,0,128,255,true) modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience",getElementData(killer,"experience") + experiences) I suppose you want this.
  18. Ahh, right. addCommandHandler("checktime", function(thePlayer) local purchaseDate = getAccountData(getPlayerAccount(thePlayer), "VIPPurchaseDate") if purchaseDate then local realTime = getRealTime().timestamp local remainingTime = purchaseDate + 86400 - realTime local minutesLeft = remainingTime/60 local hoursLeft = minutesLeft/60 outputChatBox("Your VIP expires in " .. string.format("%02d", math.floor(hoursLeft)) .. ":" .. string.format("%02d", math.floor(minutesLeft)%60), thePlayer) else outputChatBox("You haven't bought VIP in the past.", thePlayer) end end) Try this one.
  19. Server side function loginHandler ( usernamelogin, passwordlogin ) local accountlogin = getAccount ( usernamelogin, passwordlogin ) if ( accountlogin ~= false ) then logIn ( client, accountlogin, passwordlogin ) fadeCamera(client, false, 1.5) setTimer(fadeCameraDelay,1500,1,client) triggerClientEvent(client, "hideLogin", getRootElement()) else outputChatBox ( "Wrong username or password!", client, 255, 255, 0 ) -- the login failed end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) Client side function clientSubmitLogin(button,state) if button == "left" and state == "up" then local usernamelogin = guiGetText(UserLogin) local passwordlogin = guiGetText(PassLogin) triggerServerEvent("submitLogin", getRootElement(), usernamelogin, passwordlogin) end end addEvent("hideLogin", true) addEventHandler("hideLogin", getRootElement(), function() guiSetInputEnabled(false) guiSetVisible(LoginPanel, false) showCursor(false) stopSound(loginpanelsong) end Should work mate.
  20. addCommandHandler("checktime", function(thePlayer) local purchaseDate = getAccountData(getPlayerAccount(thePlayer), "VIPPurchaseDate") if purchaseDate then local realTime = getRealTime().timestamp local remainingTime = realTime - purchaseDate local minutesLeft = remainingTime/60 local hoursLeft = minutesLeft/60 outputChatBox("Your VIP expires in " .. string.format("%02d", math.floor(hoursLeft)) .. ":" .. string.format("%02d", math.floor(minutesLeft)%60), thePlayer) else outputChatBox("You haven't bought VIP in the past.", thePlayer) end end)
  21. addCommandHandler("checktime", function(thePlayer) local purchaseDate = getAccountData(getPlayerAccount(thePlayer), "VIPPurchaseDate") if purchaseDate then local realTime = getRealTime().timestamp local remainingTime = realTime - purchaseDate local minutesLeft = remainingTime/60 local hoursLeft = minutesLeft/60 outputChatBox("Your VIP expires in " .. string.format("%02d", math.floor(hoursLeft)) .. ":" .. string.format("%02d", math.floor(minutesLeft)), thePlayer) else outputChatBox("You haven't bought VIP in the past.", thePlayer) end end) I think this one should work.
  22. Are you using my method, or @Mr.Loki's method?
×
×
  • Create New...