ShayF

Members
  • Content count

    98
  • Joined

  • Last visited

Community Reputation

17 Decent

2 Followers

About ShayF

  • Rank
    Punk-@ss B*tch

Details

  • Gang
    Grove
  • Location
    Grove St
  • Occupation
    Drifting
  • Interests
    Scripting

Recent Profile Visitors

703 profile views
  1. [Help]Panel open command

    god i hate it when people format code in a :Oed up way
  2. Nearest Element

    I was working on a script getting nearest elements, maybe someone will find this of use. This code is NOT tested, so it may need some modifications, but it's a basic platform. Note it contains a lot of looping and is set clientside so it may suck quite a bit of work out of a users computer, causing an fps drop. However I made it so that only rendered elements are checked, so that should reduce the amount of work. Here's the code. local timers = {} local positions = {} local objectids = {'1221'} function checkElements(element,x1,y1,z1) local x2,y2,z2 = getElementPosition(v) local distance = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) table.insert(postions,{element,x2,y2,z2,distance}) end function getNearestElement(element) if isElement(element) then local elementTypes = {'vehicle','player','ped','object'} local x1,y1,z1 = getElementPositon(element) positions = {} for i=0,#elementTypes do for k,v in pairs(getElementsByType(elementTypes[i])) if isElementOnScreen(element) then if elementTypes[i] == 'object' then for l=0,#objectids do if getElementModel(v) == objectids[l] then checkElements(v,x1,y1,z1) end end else checkElements(v,x1,y1,z1) end end end end end local distances = {} for s,t in ipairs(positions) do table.insert(distances,t[5]) end table.sort(distances) for c,d in pairs(positions) do if d[5] == distances[1] then return d end end end addEventHandler('onClientPlayerJoin',root,function() source = source timers[source] = setTimer(function() getNearestElement(source) end,1000,0) end) addEventHandler('onClientPlayerQuit',root,function() if isTimer(timers[source]) then killTimer(timers[source]) end end)
  3. how to convert from luac to lua

    Whenever there's a script I like that's compiled or one i found on a server I either get rid of it, or rescript it myself and add some cool new features.
  4. My Code

    This isn't a help thread, more of an information thread, considering I post a lot on here to help people. I want everyone to know that when I provide code that it is NOT tested, unless I say it is in the thread. I do use forms of oop, and advanced/organized code, without unnecessary spaces and using ' instead of " quotes when working with strings. This is professional styled lua code, however it is taught in coding schools when using tabs to space the code that you should use 2 spaces instead of a tab and also use spaces when separating elements commonly after commas, I do not do either of these, I use tabs in order to make the code fast and simple to edit, and I do not use spaces after separating elements to make the code as compact and organized as possible. If I do not post code to help you, it will be a brief comment (possibly with a redirection) due to lack of information and or too much to decipher. I am good at coding lua, I'm not by any means a professional, but I am good. If you need help just let me know. I will not code big scripts, only parts of scripts. You can contact me by email, skype, or discord. I made this thread because many people have been making rude comments towards me and I felt like justifying. Have a nice day everyone.
  5. HELP! Database ( ID System )

    I'd save player data to the sql and use the save's index number as the players id.
  6. Random Postion

    You can only use unpack with a function that allows multiple OPTIONAL values. Maybe this will work better for you. local position = { {816.59997558594,-7209.2998046875,32.799999237061}, {707.20001220703,-7272.6000976563,32.700000762939}, {710.5,-7412.8999023438,32.799999237061}, {798.70001220703,-7654,32.5}, {816.09997558594,-7471.3999023438,30}, {812.40002441406,-7321.6000976563,32.799999237061} } function getRandomPosition() local r = math.random(#position) return position[r][1],position[r][2],position[r][3] end function myteleport(player,command) local element local x,y,z = getRandomPosition() local vehicle = getPedOccupiedVehicle(player) if vehicle then element = vehicle else element = player end if isElement(element) then setElementPosition(element,x,y,z) end end addCommandHandler('test',myteleport)
  7. ElementData

    addEventHandler('onClientPedDamage',root,function(attacker,weapon,bodyPart,loss) if loss then local boss = getElementData(source,'boss') if boss then -- if you want to get its actual data.. if boss == 'yes its the :Oin boss xD' then cancelEvent() setElementHealth(source,(getElementHealth(source)-(loss%5))) -- this is if you want the boss to SLOWLY lose health.. end end end) --[[ getElementData(element element, string dataName [, inherit = true/false]) setElementData(element element, string dataName, var value [, bool sync = true/false]) ]] Everything inside [] are optional arguments, the rest is required (usually). Note that it is Element First, meaning ped, player, vehicle, whatever you are targeting.. Then after element is the data name..
  8. Help me

    Check a decompiled version of MTA DayZ for reference on element data.
  9. Vehicle shot

    addEventHandler('onClientPlayerWeaponFire',root,function(weapon,ammo,aic,x,y,z,hitElement) if hitElement then if getElementType(hitElement) == 'vehicle' then local components = getVehicleComponents(hitElement) for i=1,#components do local 2x,2y,2z = getComponentWorldPosition(components[i]) if x == 2x and y == 2y and z == 2z then return components[i] end end end end end) function getComponentWorldPosition(vehicle,component) local m = getElementMatrix(vehicle) local x,y,z = getVehicleComponentPosition(vehicle,component) local wX = x*m[1][1]+y*m[2][1]+z*m[3][1]+m[4][1] local wY = x*m[1][2]+y*m[2][2]+z*m[3][2]+m[4][2] local wY = x*m[1][3]+y*m[2][3]+z*m[3][3]+m[4][3] return wX,wY,wZ end This only works if you shoot dead center of the component. So you may have to modify it to do what you want. This is as far as I can help. Sorry.
  10. MySQL login not working

    Use an app called Solo Learn, for sql teachings, the class is short and fast. It tell's everything about sql. This might help you. SELECT password,username,user_id,token FROM users WHERE username = ?
  11. On downloading

    Use source, source is the player...
  12. function compareStringToNumber(text) if text then local number = tonumber(text) if number then return number else return false end end end -- Then use it like so local comparedNumber = compareStringToNumber('250') --[[ comparedNumber is now 250, instead of '250' This will return false instead of nil so that no errors are produced. If you try compareStringToNumber('text') or compareStringToNumber('this is text') then it will return false You can also use this as a check, Like shown below. --]] local num = '5000' if compareStringToNumber(num) then outputChatBox(num..' is a number!') end
  13. [HELP] dxDraw3DText

    nothing is outputted to chatbox? or what?
  14. [HELP] Marker

    I think it would be better to replace a model that doesn't have collisions and detects when your player hits it. Much more simple than coding 40 lines of dx.
  15. Help Me!!

    local daily = {} addEventHandler('onPlayerLogin',resourceRoot,function runEvent() local serial = getPlayerSerial(source) if not daily[serial] then daily[serial] = false end if daily[serial] == false then daily[serial] = true local newMoney = math.random(1000) setPlayerMoney(source,getPlayerMoney(source)+newMoney) outputChatBox('You have received your daily reward of $'..newMoney..' enjoy!',source,0,255,255) setTimer(function() daily[serial] = false end,86400000,1) end end) 86,400,000 is milliseconds, it represents a day. 1 second = 1,000 milliseconds 1 minute = 60 seconds 1 hour = 60 minutes 1 day = 24 hours 1,000*60*60*24 = 86,400,000