-
Posts
525 -
Joined
-
Last visited
-
Days Won
3
justn's Achievements
Playa Partner (27/54)
18
Reputation
-
justn changed their profile photo
-
The hash is the second argument in 'passwordVerify'. Not the first. So replace with: local passVerified = passwordVerify(pass, passHashFromDB)
-
Ah , a client sided blip, that explains why my code didn't work for you. Nice to hear you got it working though. topic can be locked now then
-
Just tested it, works perfectly for me when I attached a blip to myself via command. Could you show your current code ?
-
Correct me if I'm wrong but I'm assuming all you're wanting here is that when the player hits the hunter then he gets the hunter bonus ? If this is the case then the only issue with your code is that in your getHunter function, you need to change addWinnerBonus to addHunterBonus
-
Your getBlipAttachedTo function only returns the first blip that it finds attached to the player. (Also I wouldn't loop through every blip in the server as this can have an impact on performance depending on how many blips there are) What I would advise is looping through the attached elements of the player , adding all the blips to a table then returning the table(instead of only returning the first found attached blip). Then in your onPlayerQuit event, you loop through that table destroying everything. Pretty much the code I have below, hope this helps you! addEventHandler("onPlayerQuit",getRootElement(), function() local blips = getBlipsAttachedTo(source) if blips then for i,theBlip in ipairs(blips) do destroyElement(theBlip) end end end ) function getBlipsAttachedTo( thePlayer ) local attached = {} local blips = getAttachedElements(thePlayer) for k, theBlip in ipairs( blips ) do if isElement(theBlip) and getElementType(theBlip) == 'blip' then table.insert(attached,theBlip) end end return attached end
-
The code provided by HiroShi isn't going to work. Cancelling onPlayerDamage has no effect. Also looping is unnecessary in that case. Try this: addEventHandler("onClientPlayerDamage",root, function(attacker,w,body) if attacker then if body ~= 9 then cancelEvent() end end end )
-
local sx_, sy_ = 1920, 1080 local sx__, sy__ = guiGetScreenSize() local xm, ym = sx__/sx_, sy__/sy_ local hudElements = {} function _dxDrawImage(x,y,w,h,image,rot,rotOffsetX,rotOffsetY,color,postgui) local btn = guiCreateButton(x,y,w,h,"",false) if btn then setElementData(btn,"hudElement",true) guiSetAlpha(btn,0) table.insert(hudElements,{element=btn,type='image',dx={}}) hudElements[#hudElements].dx[1] = x hudElements[#hudElements].dx[2] = y hudElements[#hudElements].dx[3] = w hudElements[#hudElements].dx[4] = h hudElements[#hudElements].dx[5] = image hudElements[#hudElements].dx[6] = tonumber(rot) or 0 hudElements[#hudElements].dx[7] = tonumber(rotOffsetX) or 0 hudElements[#hudElements].dx[8] = tonumber(rotOffsetY) or 0 hudElements[#hudElements].dx[9] = tonumber(color) or tocolor(255,255,255,255) hudElements[#hudElements].dx[10] = ( postgui == true ) or false return true end end function _dxDrawRectangle(x,y,w,h,color,postgui) local btn = guiCreateButton(x,y,w,h,"",false) if btn then setElementData(btn,"hudElement",true) guiSetAlpha(btn,0) table.insert(hudElements,{element=btn,type='rectangle',dx={}}) hudElements[#hudElements].dx[1] = x hudElements[#hudElements].dx[2] = y hudElements[#hudElements].dx[3] = w hudElements[#hudElements].dx[4] = h hudElements[#hudElements].dx[5] = tonumber(color) or tocolor(255,255,255,255) hudElements[#hudElements].dx[6] = ( postgui == true ) or false return true end end addEventHandler('onClientRender',root, function() for i,v in ipairs(hudElements) do if targetElement and targetElement == v.element then if getKeyState("mouse1") ~= true then targetElement = nil end if isCursorShowing() == true then local positionX, positionY, worldX, worldY, worldZ = getCursorPosition() local screenx, screeny = getScreenFromWorldPosition(worldX,worldY,worldZ) if screenx and screenx < sx__ and screeny < sy__ then v.dx[1],v.dx[2] = screenx,screeny end guiSetPosition(v.element,v.dx[1],v.dx[2],false) else targetElement = false end end if v.type == 'rectangle' then dxDrawRectangle( v.dx[1], v.dx[2], v.dx[3], v.dx[4],v.dx[5], v.dx[6]) elseif v.type == 'image' then dxDrawImage( v.dx[1], v.dx[2], v.dx[3], v.dx[4],v.dx[5], v.dx[6], v.dx[7], v.dx[8], v.dx[9], v.dx[10] ) end end end ) addEventHandler("onClientGUIMouseDown",resourceRoot, function(btn) if btn == "left" then if getElementData(source,"hudElement") == true then targetElement = source end end end ) bindKey("m","down",function() if isCursorShowing() then showCursor(false) else showCursor(true) end end) _dxDrawRectangle( (sx_-245) * xm, (sy_/2-460) * ym, 220 * xm, 10 * ym,tocolor(0,0,0,120),true) Made you this real quick so you have an idea of what to do, it's not all perfect at the moment but it's something you could use as a start. It's much simpler than you attempting to calculate for every single thing you'd want to draw. You can use what you have there to help you with doing the texts, good luck.
-
To start off, something wrong with your code that you should be careful of doing, for instance: Error: -- Replacing this: local sx__, sy__ = guiGetScreenSize() -- keep this -- With this: sx__, sy__ = xs, ys -- = no no To avoid positioning/scaling issues, I wouldn't recommend replacing the value of the variable which you're gonna be using for further calculations with the position of the cursor. Now what you could do is use the onClientClick with a variable to enable/disable the dragging, using onClientRender and getCursorPosition when the cursor is showing , then using the screen position from the cursor to set the value for your hud. A little example below, something like this should work: local sx_, sy_ = 1920, 1080 local sx__, sy__ = guiGetScreenSize() local xm, ym = sx__/sx_, sy__/sy_ local hudX, hudY = (sx_-245) * xm, (sy_/2-460) * ym local isMovingHud = false addEventHandler('onClientClick',root, function(btn,state,posX,posY) if btn == 'left' then if state == 'down' then isMovingHud = true else isMovingHud = false end end end ) addEventHandler('onClientRender',root, function() if isMovingHud == true then if isCursorShowing() == true then local positionX, positionY, worldX, worldY, worldZ = getCursorPosition() hudX,hudY = getScreenFromWorldPosition(worldX,worldY,worldZ) else isMovingHud = false end end dxDrawRectangle( hudX, hudY, 220 * xm, 10 * ym,tocolor(0,0,0,120)) end ) bindKey("m","down",function() if isCursorShowing() then showCursor(false) else showCursor(true) end end)
-
You could start off with xXMADEXx's tutorial for the basics. Then you can move forward to learning from the mtasa wiki page as well as the lua reference manual. (https://www.lua.org/manual/5.4/) . Hopefully this helps, good luck.
-
You put 'elseif' as in if the job wasn't the 'RS Haul Delivery' then it would check if the hours played is below 50, which is why you were able to get the job regardless of how many hours played. Here you go though. local hoursplayed = tonumber(getElementData(localPlayer, "hoursplayed")) or 0 if (jobtext=="RS Haul Delivery") then if hoursplayed < 50 then outputChatBox("You must play at least 50 hours to work as a RS haul delivery driver", 255, 0,0) return true end end
-
Once you've set the element data on the server you can use getElementData on the client to receive the set data. Or triggerClientEvent , whatever you decide
-
removePedFromVehicle setElementPosition
-
I believe this is what you're trying to do. marker = createMarker(-662.33703613281,2365.9025878906,178.9553527832, "cylinder", 1.5, 0, 100, 100, 200) function Texto() local x,y,z = getElementPosition(localPlayer) local distance = getDistanceBetweenPoints3D(-662.33703613281,2365.9025878906,178.9553527832,x,y,z) if distance < 20 then local sx,sy = getScreenFromWorldPosition(-662.33703613281,2365.9025878906,178.9553527832) if sx and sy then local coords = {sx,sy} if coords[1] and coords[2] then dxDrawText("CJ", coords[1], coords[2], coords[1], coords[2], tocolor(255,0,0,255), 10, "sans", "center", "center", false, false, false, false) end end end end addEventHandler("onClientRender", root, Texto)
-
PM me with your contact information(preferably Discord) and we can discuss further.
-
When the map is starting you loop through all the players(or you can just use onClientMapStarting and check the localPlayer) , then check if the player is in the garage before killing.