Jump to content

Bonus

Members
  • Posts

    297
  • Joined

  • Last visited

Everything posted by Bonus

  1. Bonus

    2x Warning

    Try to put that outputDebugString at line 77. outputDebugString ( tostring (objx).."-"..tostring(objy).."-"..tostring(objz).." | "..tostring(offrx).."-"..tostring(offry).."-"..tostring(offrz) ) Check your debugscript when you get the error, which output comes before the errors?
  2. Oh sure, didn't notice that
  3. #1: ipairs sorts the table by index (integer) and goes from 1 to the highest number before an empty index. local table1 = { "hello", "my", "name" } local table2 = { [1] = "hello", [2] = "my", [4] = "name" } local table3 = { ["hello"] = 1, ["my"] = 2, ["name"] = 3 } for index, value in ipairs ( table1 ) do outputChatBox ( value ) end -- "hello" "my" "name" (sorted) for index, value in ipairs ( table2 ) do outputChatBox ( value ) end -- "hello", "my" (sorted, max index was 2 because of the nil value at [3]) for index in ipairs ( table3 ) do outputChatBox ( index ) end -- NOTHING for index in pairs ( table3 ) do outputChatBox ( index ) end -- "name", "hello", "my" (not sorted) But pairs doen't look at the index. It just iterates the table without looking at the index or sorting it. #2: The index would be player, the value would be player. Why has your mind blown up? #3: index #4: Yes You could remove from the table with integer index too. for i=1, #table1 do if table1[i] == yourvalue then table.remove ( table1, i ) break end end
  4. Don't write wrong things, it's clearly because of pairs here ...
  5. Oh, I forgot to use stopAnimDraw: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 if progress >= 1 then -- NEW stopAnimDraw() -- NEW return -- NEW end -- NEW end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
  6. Let the fProgress go from 1 to 0. Like that: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
  7. This time I was faster edited already
  8. Sry, but how can this work? Are Acc and Skin the new source? function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) -- source instead of Acc if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerskin = getElementModel ( source ) -- source instead of Acc setAccountData ( playeraccount, "player.skin", playerskin ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playerskin = getAccountData ( playeraccount, "player.skin" ) if ( playerskin ) then setElementModel ( source, playerskin ) -- source instead of Acc end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) This code should work ... The skins will be saved in the account database of your server. Edit: Walid was faster
  9. Depends on how you want to save it. Accountdata (when someone uses /login)? MySQL? File (save by serial or name) clientsided file
  10. I gave him the solution for the event he was using, he did not ask for better perfomance... And I didn't say your solution is wrong. Just wanted to say that he should better use the other event
  11. Maybe the blip is only getting created again because of onZombieSpawn? Try to ask there, if the ped is dead: if getElementData ( v, "zombie" ) and not isPedDead ( v ) then
  12. function Test( hitElement ) if getElementType ( hitElement ) == "player" then setElementData ( hitElement, "Test2", true ) end function markerLeave( leaveElement, matchingDimension ) if getElementData ( leaveElement, "Test2" ) then -- that should be better (optional) outputChatBox ( "Player has left a marker", getRootElement(), 255, 255, 0 ) setElementData ( leaveElement, "Test2", false ) -- You used hitElement here end end addEventHandler( "onMarkerLeave", myMarker, markerLeave )
  13. Use the addEventHandler when you create it (= use it after line 6). Also you can use local for the housemarker after you did that. Explanation: You create the marker after using the command. So you can't attach the addEventHandler before using the command, cause the marker isn't even created.
  14. Better do what Walid told you, better for the performance.
  15. Bonus

    [HELP] dxEdit

    Oh god, I'm fucking blind ... Hahaha
  16. Bonus

    [HELP] dxEdit

    Lets try this addEventHandler ( "onClientKey", root, function ( button, press ) if press and button == "backspace" then outputChatBox ( "Test" ) end end ) Put this in and try to delete like you normally do. Do you get an output in the chat?
  17. Bonus

    [HELP] dxEdit

    Hmm ... normally I don't use bindKey there, I use onClientKey. Test this: local text = "" addEventHandler ( "onClientKey", root, function ( button, press ) if press then if button == "tab" then text = text .. "\n" elseif button == "backspace" then if #text > 0 then string.sub ( text, 1, #text - 1 ) end end end end ) addEventHandler ( "onClientCharacter", root, function ( key ) text = text .. key end ) addEventHandler ( "onClientRender", root, function () dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) end )
  18. Bonus

    [HELP] dxEdit

    local text = "" bindKey ( "backspace", "down", function () if text ~= "" then string.sub ( text, 1, #text - 1 ) end end ) addEventHandler ( "onClientCharacter", root, function ( key ) text = text .. key end ) addEventHandler ( "onClientRender", root, function () dxDrawText ( text, 654, 354, 778, 377, tocolor(255, 255, 255, 255), 1, f2, "left", "top", true, true, true, true, true) end ) I expected you to fill the dxDrawText Was on mobile phone
  19. Bonus

    [HELP] dxEdit

    CodyL your code will not work pairs? local in this for block? local text = "" bindKey ( "backspace", "down", function () if text ~= "" then string.sub ( text, 1, #text - 1 ) end end ) addEventHandler ( "onClientCharacter", root, function ( key ) text = text .. key end ) addEventHandler ( "onClientRender", root, function () dxDrawText ( text, ... ) end )
  20. scrollpane is a GUI ... You can use dxDrawRectangle (2x) and onClientClick so you can click on it. Can show you an example in some minutes. local screenX, screenY = guiGetScreenSize() local sx, sy = screenX/1920, screenY/1080 local scrollplayers = 0 local maxplayerswithoutscroll = 15 dxDrawRectangle ( screenX*0.4, screenY*0.35, screenX*0.02, screenY*0.01, tocolor ( 160, 160, 160, 184 ), true ) -- Scroll rectangle to click (up) dxDrawRectangle ( screenX*0.4, screenY*0.64, screenX*0.02, screenY*0.01, tocolor ( 160, 160, 160, 184 ), true ) -- Scroll rectangle to click (down) dxDrawRectangle ( screenX*0.4, screenY*0.36, screenX*0.02, screenY*0.28, tocolor ( 50, 50, 50, 184 ), true ) -- Scroll background dxDrawLine ( screenX*0.41, screenY*0.37, screenX*0.41, screenY*0.63, tocolor ( 0, 0, 0, 184 ), 1*sx, true ) -- Scroll line for optics local amount = #playersinlobby[playerlobby] - maxplayerswithoutscroll -- amount not showing if amount > 0 then -- if you can scroll dxDrawRectangle ( screenX*0.401, screenY*0.361+scrollplayers*screenY*0.2798/(amount+1), screenX*0.018, screenY*0.2798/(amount+1), tocolor ( 10, 10, 10, 184 ), true ) else -- if you cant scroll dxDrawRectangle ( screenX*0.401, screenY*0.361, screenX*0.018, screenY*0.2798, tocolor ( 10, 10, 10, 184 ), true ) end addEventHandler ( "onClientClick", root, function ( ) if x >= screenX*0.4 and x <= screenX*0.42 and y >= screenY*0.35 and y <= screenY*0.65 then if y < screenY*0.36 then scrollplayers = scrollplayers > 0 and scrollplayers - 1 or 0 elseif y > screenY*0.64 then scrollplayers = scrollplayers+maxplayerswithoutscroll < #playersinlobby[playerlobby] and scrollplayers + 1 or scrollplayers else local amount = #playersinlobby[playerlobby] if amount > maxplayerswithoutscroll then scrollplayers = roundNumber ( ( y - screenY*0.36 ) / ( screenY*0.28 ) * ( #playersinlobby[playerlobby]-maxplayerswithoutscroll ) ) else scrollplayers = 0 end end end end ) for i=1+scrollplayers, maxplayerswithoutscroll+scrollplayers do --- end You can see it better here: http://hastebin.com/ijopayeyay.lua
  21. getPlayerTeam gives the team element, not a string. getPlayerTeam can never be "police", but it can be police
  22. pairs is the thing wrong here Use ipairs instead pairs doesn't go from 1 to n, ipairs / for i=1, length does
  23. Its my own resolution. Use your own resolution.
  24. Dunno what exactly the problem is. You didn't tell the bug. You should maybe use onClientResourceStart ... onClientPlayerJoin should be totally wrong here
  25. It has to work. onClientGUIClick gets triggered when you click on a GUI. The source is the GUI element, which got clicked. It's probably your fault, but you show too less to see anything.
×
×
  • Create New...