Jump to content

t3wz

Members
  • Posts

    149
  • Joined

  • Last visited

Everything posted by t3wz

  1. I'm sorry for going out of the topic, But why you don't indent your codes @manawydan? Really, they look terrible that way.
  2. You can imagine a render target as a "new screen", When you do this: drawArea = dxCreateRenderTarget(800,700) You are creating a "new screen" with 800px as width and 700 as height, As you may know, When you draw elements outside the player's resolution ( < -0 or > your width ) the "dx" will cut and won't render completely (the parts outside the resolution will not be visible), This will occur in render targets also: text = "Sample Text"; render = dxCreateRenderTarget ( 200, 50, true ); x = 200 + 5; addEventHandler ( "onClientRender", root, function ( ) local minWidth = ( -dxGetTextWidth ( text, 1, "pricedown" ) - 5 ); x = ( x == minWidth ) and ( 200 + 5 ) or ( x - 0.5 ); dxSetRenderTarget ( render, true ); dxDrawRectangle ( 0, 0, 200, 50, 0xAA000000 ); dxDrawText ( text, x, 0, 200, 50, 0xFFFFFFFF, 1, "pricedown", "left", "center" ); dxSetRenderTarget (); dxDrawImage ( 200, 200, 200, 50, render ) end ) As you can see it's pretty simple, we have to use dxSetRenderTarget to tell MTA that we wish to render the text under the render target and not in the "normal screen", After going back to the "render-on-the-normal screen" mode (using dxSetRenderTarget without parameters) we have to draw the render target itself (using dxDrawImage) . The other things in the script are just maths to move the text (i don't think that i need to explain it btw). I hope that you have understood, Apologizes for my English, Also i have not tested the code (but it seems to work).
  3. @Tails That's really easy to make, if you want i can help you via PM
  4. @Tails Horizontal scroll isn't implemented, What you can do to "fix" this: Increase the gridlist's width. Put a character limit to the video name. About the centered text, it is made to work like this, if you want to, here's the line responsible for processing the text of the row, you can edit this as you wish. @Tomas Good idea, i'll take a look into this later.
  5. Ha, i thought that you were talking about HEX colors, btw i've added support to RGB colors, feel free to look at the repo if you want
  6. No, it uses the clip/wordBreak arguments so color-coded texts aren't possible.
  7. Just change the outputChatBox ... is it that hard? outputChatBox ( "/spam /caps ...", player );
  8. infohelpToggled = {} addCommandHandler ( "infohelp", function ( player ) infohelpToggled[player] = not infohelpToggled[player]; outputChatBox ( "infohelp turned " .. ( infohelpToggled[player] and "on" or "off" ), player ); end ) addCommandHandler ( "spam", function ( player ) if ( infohelpToggled[player] ) then outputChatBox ( "/spam message", root ); else outputChatBox ( "use /infohelp first", player ); end end )
  9. From what i understood you want to stop the animation after a while, if i'm correct you can use a timer: setTimer ( function () setPedAnimation ( localPlayer, false ) end , 3 * 1000, 1 ) -- 3 = seconds to stop the animation Btw this is the English section, you should go to the Portuguese section to write in Portuguese.
  10. function a () end function b () end addCommandHandler ( "bomb", a ); addCommandHandler ( "bomb", b ); btw you won't need 2 functions for this, read about tables and you can create it easily.
  11. t3wz

    Private skin

    addEventHandler ( "onElementModelChange", root, function ( oldModel ) if getElementType ( source ) == "player" then if not isObjectInACLGroup( "user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Owner" ) ) then if getElementModel ( source ) == SKIN_ID_HERE then outputChatBox ( "Only the server owners can use this skin", source, 255, 0, 0 ); -- for some reason using setElementModel without a timer doesn't set the skin setTimer ( function(p) setElementModel ( p, oldModel ); end , 100, 1, source ); end end end end ); don't forget to change SKIN_ID_HERE.
  12. Just check if weapon is equal to 24.
  13. t3wz

    [HELP]Input Memo

    I made an example using edits (which is the gui element made for this): guiCreateLabel ( 500, 80, 100, 50, "input the skin ID:", false ) -- create the label, nothing special here editbox = guiCreateEdit ( 500, 100, 100, 50, "", false ) -- create the edit box in the editbox variable setbutton = guiCreateButton ( 500, 160, 100, 50, "Set", false ) -- create a button in the setbutton variable showCursor ( true ) -- show the cursor, now the player is able to write in the edit box function changeskin ( ) local skinid = guiGetText ( editbox ) -- get the text written in the edit box and 'save' it in the skinid variable local number = tonumber ( skinid ) -- convert the skinid variable to a number setElementModel ( localPlayer, number ) -- set the player skin end addEventHandler ( "onClientGUIClick", setbutton, changeskin ) -- add the onClientGUIClick event (which is triggered when the player click on the set button) Hope you understand, ofc if you're going to use this you need to check if the skin is valid etc, this is just an example.
  14. x, y, z and vehicle weren't defined in your code (they were parameters from the onClientGUIClick event), but I think that you trigger the "playTheSoundEvent" event in the server side, so i didn't remove the old 'variables'. commandGUI = "speaker" screenW,screenH = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow((screenW - 384) / 2, (screenH - 102) / 2, 384, 102, "Speakers", false) guiWindowSetSizable(Window, false) bCreate = guiCreateButton(83, 64, 72, 27, "Create", false, Window) bRemove = guiCreateButton(160, 64, 72, 27, "Remove", false, Window) bClose = guiCreateButton(237, 64, 72, 27, "Close", false, Window) addEventHandler("onClientGUIClick",bCreate, playTheSound) addEventHandler("onClientGUIClick",bRemove, stopTheSound) link = guiCreateEdit(43, 31, 331, 26, "", false, Window) guiCreateLabel(10, 36, 26, 16, "Link:", false, Window) guiSetVisible (Window, false) end ) function openGUI() guiSetVisible (Window, true) showCursor (true) end function closeGUI() guiSetVisible (Window, false) showCursor (false) end function playTheSound(x, y, z, vehicle) local url = guiGetText( link ) local pos = type(x) ~= "string" and { x, y, z } or { getElementPosition ( localPlayer ) } local vehicle = isElement(vehicle) and vehicle or ( isPedInVehicle( localPlayer ) and getPedOccupiedVehicle ( localPlayer ) or false ) sound = playSound3D(url, unpack ( pos ) ) if (isElement(vehicle)) then attachElements(sound, vehicle) end end addEvent("playTheSound", true) addEventHandler("playTheSound", root, playTheSound) function stopTheSound(x, y, z) if sound and isElement(sound) then stopSound(sound) end end addEvent("stopTheSound", true) addEventHandler("stopTheSound", root, stopTheSound) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == bClose) then closeGUI() end end ) addCommandHandler(commandGUI,openGUI)
  15. isElement will always return true (because the image is an element, even when invisible), Use isElementWithinColShape, also using root in the second parameter of addEventHandler (line 10) will execute the main function when ANY resource starts, you must use resourceRoot. col = createColCuboid ( -2424.2, -610, 132.5, 5, 5, 5 ) function main() icon = guiCreateStaticImage(0.6, 0.3, 0.1, 0.08, "files/mg42.jpg", true) -- I assume that timer is just for testing, otherwise there's no need of this. setTimer ( function() guiSetVisible(icon, false) end, 50, 1 ) bindKey ( "e", "down", onEnter ) end addEventHandler( "onClientResourceStart", resourceRoot, main ) function onHit() guiSetVisible(icon, true) end addEventHandler( "onClientColShapeHit", col, onHit ) function onLeave() guiSetVisible(icon, false) end addEventHandler( "onClientColShapeLeave", col, onLeave ) function onEnter(posX, posY, posZ) if isElementWithinColShape ( localPlayer, col ) then local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, -2422.1469, -607.8954, 132.56) end end @EDIT Al3grab's solution will work also, but if you REALLY want to check if the player is in the colshape isElementWithinColShape is the function for this.
  16. t3wz

    [HELP] Mission

    Both createMarker and createBlip have an argument that specifies which elements can see the marker/blip (if you don't knew see the syntax at the wiki). To destroy the elements later you have to save them at a table (or with element datas), if you don't do it, other markers will overwrite the marker1 variable for example. to do this we'll create a table at the top of the code. myTable = {} Then, when the player type /job, we've to define his table: myTable[source] = {} -- create a new table for the player myTable[source]["marker"] = createMarker ( ......... ) -- define the marker index at the player's table as the marker element. myTable[source]["blip"] = createBlip ( ......... ) -- define the blip index at the player's table as the blip element. Now we're going to have the elements stored in the player table, so they're 'safe'. When the player hit any marker we check if the marker is the same that is in the player's table, if it is we give the money to him. function onHitAnyMarker ( thePlayer ) -- Check if the player have a table (and is doing a job). if myTable[thePlayer] then -- Check if the hited marker is the that is in his table if source == myTable[thePlayer]["marker"] then givePlayerMoney( thePlayer, math.random( 5000, 15000 ) ) destroyElement(marker1) destroyElement(blip1) outputChatBox("#00FF00Mission complete. You get "..convertNumber(money).."$!", thePlayer, 255, 255, 255, true) end end end addEventHandler("onMarkerHit", root, onHitAnyMarker) Hope you've understood my explanation .
  17. t3wz

    getPlayerAccount

    getPlayerAccount will return an account even if player isn't logged (he will have a guest account), You have to use isGuestAccount. if not isGuestAccount ( account ) then -- registered account else -- guest account end
  18. Yeah, you'll need two rectangles, About the borders you can use the function made by Dealman (here is the topic about it).
  19. t3wz

    browser

    Use the Browser functions, if you do this correctly, all players can see the 'movie'.
  20. the play gamemode doesn't uses createSpawnpoint, it just spawn the player using spawnPlayerAtSpawnpoint and then set him skin to a random one. To edit this just open play/broph.lua and find line 19: repeat until setElementModel(player,math.random(312)) change to: setElementModel( player, 0 )
  21. Sorry about this it's fixed now, download the latest version.
  22. This section is for help about the server itself, not the scripts, go to the scripting section next time. About your problem, getAccountData(account, "bank.balance") is returning a boolean and not a number make sure that source is defined in the line above.
  23. Your script works fine here, Use /debugscript 3 to see if the problem isn't on another part of the code. Also you don't need to use getResourceRootElement(getThisResource()), resourceRoot does the job. the lookAt* parameters are optional, he doesn't need to pass it.
×
×
  • Create New...