Jump to content

Vector

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by Vector

  1. Also, you can use guiSetInputMode https://wiki.multitheftauto.com/wiki/GuiSetInputMode guiSetInputMode ("no_binds_when_editing"); -- binds are disabled when editing a memo or editbox. guiSetInputMode ("allow_binds"); -- binds are enabled again.
  2. function maskAnimation ( thePed ) setPedAnimation ( thePed, "goggles", "goggles_put_on", 1000, false, false, false ) setTimer (setPedAnimation, 1000, 1, thePed); -- ped will stop the animation after 1 second. end
  3. server-side addEventHandler ("onElementModelChange", getRootElement (), function (oldModel, newModel) local function isPlayerAdmin (thePlayer) local aclAdminGroup = aclGetGroup ("Admin"); local playerAccount = getPlayerAccount (thePlayer); local playerAccountName = getAccountName (playerAccount); return isObjectInACLGroup ("user." .. playerAccountName, aclAdminGroup); end; if getElementType (source) ~= "player" then return; end; if (newModel == 217) and (not isPlayerAdmin (source)) then outputChatBox (getPlayerName (source) .. ", skin 217 is just for admins!", source, 255, 0, 0); -- restore old skin. if oldModel == 217 then return; end; -- avoid stack overflow. -- small delay to restore again the model. setTimer (setElementModel, 50, 1, source, oldModel); end; end);
  4. table.remove (tab, 5); -- will do all the job. -- the first argument is the table and the second, the index of the element.
  5. local root = getRootElement (); local resourceRoot = getResourceRootElement (getThisResource ()); local screenWidth, screenHeight = guiGetScreenSize (); local screenSource, windowCapture; local yourWindow = guiCreateWindow (...); -- this will be your window. ok? addEventHandler ("onClientResourceStart", resourceRoot, function () screenSource = dxCreateScreenSource (screenWidth, screenHeight); assert (screenSource, "Fail to create screen source"); end); -- F7 will capture your window. bindKey ("F7", "down", function () -- we don´t capture the window if it´s not visible ... if not guiGetVisible (yourWindow) then return; end; -- get a capture of the screen. dxUpdateScreenSource (screenSource); local posX, posY = guiGetPosition (yourWindow, false); local sizeX, sizeY = guiGetSize (yourWindow, false); windowCapture = dxCreateRenderTarget (sizeX, sizeY, true); assert (windowCapture, "Fail to create render target"); dxSetRenderTarget (windowCapture, true); dxDrawImageSection (0, 0, sizeX, sizeY, posX, posY, sizeX, sizeY, screenSource); dxSetRenderTarget (); -- now windowCapture is the capture of your window. -- do whatever you want with it .... end);
  6. https://wiki.multitheftauto.com/wiki/Vehicle_IDs
  7. Vector

    /me problem

    Ok. I believed "action message" means any command (not only the \me command) sorry
  8. Vector

    /me problem

    that will not work. with onPlayerChat event, you cannot know what is the command name. That will call his function everytime the player enter a command.
  9. oh, sorry... textureID, modelID = getTypeIndexFromClothes ("hockey", "hockeymask"); txd = engineLoadTXD ("hockey.txd"); engineImportTXD (txd, textureID); dff = engineLoadDFF ("hockeymask.dff", modelID); engineReplaceModel (dff, modelID);
  10. to replace models/textures, you need to specify the ID number, not it´s name. the texture name of the hockey mask is "capgangover" the model name of the hockey mask is "capovereye" you can get texture ID, model ID with this function getTypeIndexFromClothes -> textureID, modelID = getTypeIndexFromClothes ("capgangover", "capovereye"); txd = engineLoadTXD ("hockey.txd"); engineImportTXD (txd, textureID); dff = engineLoadDFF ("hockeymask.dff", modelID); engineReplaceModel (dff, modelID);
  11. Vector

    /me problem

    SERVER-SIDE. function meChat(player,_,...) if(...==nil) then outputChatBox("Használat: /me szöveg",player,255,90,90) end if(...~=nil) then getCSD() local px,py,pz=getElementPosition(player) local msg = table.concat({...}, " ") for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,shoutRadius) then outputChatBox(csd[getElementData(player,"player_ID")].name.. "#cf4ca1 *"..msg.."*", v,255,150,150,true ) end end end end addEventHandler ("onPlayerCommand", getRootElement (), function (commandName) if string.lower (commandName) == "me" then cancelEvent (); end; end); addEvent ("onPlayerMeCommand", true); addEventHandler ("onPlayerMeCommand", getRootElement (), function (_, ...) meChat (source, "me", ...); end); CLIENT - SIDE addEventHandler("onClientConsole",getLocalPlayer(), function (text) -- get command name. local tokens = {}; for token in string.gmatch (text, "[^%s]+") do table.insert (tokens, token); end; if string.lower (tokens [1]) == "me" then triggerServerEvent ("onPlayerMeCommand", getLocalPlayer (), unpack (tokens)); end; end);
  12. SERVER-SIDE addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , function ( hitElement, matchingDimension ) -- check first if it´s a player ... if getElementType (hitElement) ~= "player" then return; end; if ( getElementType ( hitElement ) == "vehicle" ) then setElementFrozen ( hitElement, true ) -- we tell player that he is frozen ... triggerClientEvent (hitElement, "onPlayerFrozen", getRootElement ()); setTimer ( function (thePlayer) -- we tell player that will be unfrozen .. triggerClientEvent (thePlayer, "onPlayerUnfrozen", getRootElement ()); -- unfroze the player. setElementFrozen (thePlayer, false); end, 5000, 1, hitElement); end end ); -- now in client-side .... -- this function will draw a message in the middle of the screen saying that he is frozen. -- local function drawMessage () local screenWidth, screenHeight = guiGetScreenSize (); dxDrawText ("YOU ARE NOW FROZEN", screenWidth - 50, screenHeight); end; -- we need to handle events. addEvent ("onPlayerFrozen", true); addEvent ("onPlayerUnfrozen", true); addEventHandler ("onPlayerFrozen", getRootElement (), function () addEventHandler ("onClientRender", getRootElement (), drawMessage); end); addEventHandler ("onPlayerUnfrozen", getRootElement (), function () -- we don´t want the message appears. we remove the event handler .. removeEventHandler ("onClientRender", getRootElement (), drawMessage); end);
  13. I uploaded recently this resource -> https://community.multitheftauto.com/in ... ls&id=7562 but it doesn´t appear in my profile.
  14. Hi,I want to know if there is another way to transfer files from server to client and from client to server rather than adding a "file" node in meta.xml file. () for example. I have a lot of model/texture files and I don´t want users download all files at once. Only download the files that client need in that moment. I guess, I can use triggerClientEvent and triggerServerEvent, and send all the data of a file through this functions as a big string, and then, create the file in client-side like this: server-side local file = fileOpen (file_that_request_the_client); triggerClientEvent (client_that_request_the_file, "onFileDownload", getRootElement (), file_name, fileRead (file, fileSize (file))); fileClose (file); client-side addEvent ("onFileDownload", true); addEventHandler ("onFileDownload", getRootElement (), function (fileName, fileData) local file = fileCreate (fileName); fileWrite (file, fileData); fileClose (file); end); Is this the best way to achieve what I want, or there is another way?
  15. Hi, I want to show you how to change for example, the color of the text of an edit box or a memo, or how to set the color for the text in the title of a window e.t.c (looks cool ) I created the next resource: https://community.multitheftauto.com/index.php?p=resources&s=details&id=7491 You can use the exported functions to achieve this. I´ll explain how to use the functions: -> guiSetColor () <- 1ºst parameter is the gui element you want to change the text/background color. - if it is a window, the color of the text inside the title bar will be changed. - if it is a button, checkbox, editbox, radiobutton, memo, combobox or text label the normal color of the object´s text will be changed. - if it is a static image, the image itself will be mixed (blended) with that color. - the rest of the gui objects does not support this function. Before the first parameter, you can specify the R-G-B components to set the color, or you can specify one single parameter (a string), representing the color you want to set. example. local _window = guiCreateWindow (0.3, 0.3, 0.35, 0.25, "guicols example", true); -- this creates the window. exports.guicols:guiSetColor (_window, 0, 255, 0); -- this changes title bar text color to green. -- or this ... exports.guicols:guiSetColor (_window, "green"); see the images below to know what is the result. the next predefined colors are provided: "white", "silver", "gray", "black", "red", "maroon", "yellow", "olive", "lime", "green", "aqua", "teal", "blue", "navy", "fuchsia", "purple", "orange", "pink", "brown", "aero", "amber", "aquamarine", "blond", "bronze", "burlywood", "celeste" another example. -- this will create a memo in the center of the screen. local memo = guiCreateMemo (300, 300, 150, 70, "This is a multiline edit box. you can change the color of this text", false); -- this will set the color of it´s text to orange. exports.guicols:guiSetColor (memo, "orange"); -- see the images below other example ... local img = guiCreateStaticImage (300, 300, 128, 128, "img.png", false); local img2 = guiCreateStaticImage (500, 300, 128, 128, "img.png", false); local img3 = guiCreateStaticImage (700, 300, 128, 128, "img.png", false); exports.guicols:guiSetColor (img2, "pink"); -- blend first image with pink color. exports.guicols:guiSetColor (img3, "aquamarine"); -- blend second image with aquamarine color. -- see the images below. -> guiSetSelectedTextColor () <- this function has the same parameters as guiSetColor () this function can only be used on memos and edit boxes. this just change the color of the selected text in the edit box or the memo. example. local memo = guiCreateMemo (400, 300, 150, 70, "This is just another memo", false); exports.guicols:guiSetColor (memo, "blue"); -- this will set to blue the text that is not selected. exports.guicols:guiSetSelectedTextColor (memo, "red"); -- this will set to red the text that is selected. the last function .. -> guiSetDisabledColor () <- this function has the same parameters than guiSetSelectedTextColor () and guiSetColor () this function is only supported for the next gui objects: check boxes and radio buttons. this function set the color of the text of this objects when they are disabled via guiSetEnabled here is an example. -- this creates a radio button. local radio_button = guiCreateRadioButton (300, 400, 150, 20, "This is a radio button!", false); -- this will be the color of the text of the radio button when it´s enabled. exports.guicols:guiSetColor (radio_button, "navy"); -- and this set the color of the text of the radio button when it´s disabled. exports.guiCols:guiSetDisabledColor (radio_button, "celeste"); hope you like it.
  16. https://community.multitheftauto.com/in ... ils&id=672
  17. give more information about the problem and your resource.
  18. local __max_count = 5; local __count = {}; addEventHandler ("onPlayerSpawn", root, function () setElementData(source,"SL",false); outputChatBox("*[POSITION] The current position saved were removed.",source,255,0,0); -- reset the count. __count [source] = 0; end); addEventHandler("onPlayerJoin",root, function () setElementData(source,"SL",false); bindKey(source,LoadKey,"down", function (thePlayer) -- player press "load" key more than 5 times ? if __count [thePlayer] < __max_count then -- no, so ... LoadPlayer (thePlayer); -- increment count. __count [thePlayer] = __count[thePlayer] + 1; else -- "load" pressed 5 times. -- do whatever, output an error or something ... end; end); bindKey(source,SaveKey,"down",SavePlayer) end);
  19. oh. forgot it. or setElementData (thePlayer, "count", ...) getElementData (thePlayer, "count"); I guess.
  20. well, thats a big proyect, you need more than 1 scripter.
  21. https://forum.multitheftauto.com/viewtopic.php?f=148&t=61058&sid=b58333014f5ecf31ee4f74d9af856049
  22. local __count = 0; -- this hold number of times the user press the "load" key local __max_count = 5; -- this hold maximum number of times that user can press "load" key. addEventHandler ("onPlayerSpawn", root, function () setElementData(source,"SL",false); outputChatBox("*[POSITION] The current position saved were removed.",source,255,0,0); -- reset the count. __count = 0; end); addEventHandler("onPlayerJoin",root, function () setElementData(source,"SL",false); bindKey(source,LoadKey,"down", function (thePlayer) -- player press "load" key more than 5 times ? if __count < __max_count then -- no, so ... LoadPlayer (thePlayer); -- increment count. __count = __count + 1; else -- "load" pressed 5 times. -- do whatever, output an error or something ... end; end); bindKey(source,SaveKey,"down",SavePlayer) end);
  23. https://wiki.multitheftauto.com/wiki/Scripting_Introduction https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI
  24. Vector

    multi ColCuboid

    it works fine for me. there is a little error when calling outputChatBox. outputChatBox ("Welcome " .. getPlayerName (hitElement), getRootElement (), 0, 255, 0); -> this works. local Colshape = { } local ColShapes = { { -435.35120, 1127.09399, 64.77347, 89.786315917969, 138.08850097656, 31.516172409058 }, { -539.83765, 1099.35901, -0.24455, 63.918670654297, 108.96557617188, 26.398180007935 }, { -478.33630, 1126.67896, 1.00000, 89.334411621094, 38.739135742188, 79.651779174805}, {-354.53192, 1107.53027, 69.47218, 48.932952880859, 113.24426269531, 23.160528182983}, {-305.90366, 929.78162, 66.37509, 44.974731445313, 177.42919921875, 29.443685531616}, {-305.33679, 1107.58313, 65.53906, 16.306518554688, 114.54858398438, 27.093648910522}, {-316.93121, 1054.64819, 65.19218, 55.719940185547, 52.712158203125, 8.1574993133545} -- The example } -- this could work. local dummy_element = createElement ("areas"); for i,v in ipairs ( ColShapes ) do Colshape [ i ] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [7] ) setElementParent (Colshape [i], dummy_element); end addEventHandler ("onColShapeHit", dummy_element, function (hitElement) if getElementType (hitElement) == "player" then outputChatBox ("Welcome " .. getPlayerName (hitElement), getRootElement (), 0, 255, 0); end; end);
×
×
  • Create New...