Jump to content

Vector

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by Vector

  1. Vector

    XML

    -- iterate over all the xml nodes and find those whose value and tag name matches... local children = xmlNodeGetChildren(root); for _, child in ipairs(children) do if (xmlNodeGetName(child) == tagName) and (xmlNodeGetValue(child) == someValue) then xmlDestroyNode(child); end; end;
  2. maybe the skill level of your player is not "poor". it can be "pro", "std" and "poor" local M1Garand = function() local skills = {"pro", "std", "poor"}; for _, skill in ipairs(skills) do setWeaponProperty(33, skill, "weapon_range", 180) setWeaponProperty(33, skill, "target_range", 180) setWeaponProperty(33, skill, "accuracy", 5) setWeaponProperty(33, skill, "damage", 50) setWeaponProperty(33, skill, "maximum_clip_ammo", -- s8) --> setWeaponProperty(33, skill, "move_speed", 90) setWeaponProperty(33, skill, "flags", 0x000010) setWeaponProperty(33, skill, "flags", 0x008000) end end addEventHandler("onResourceStart", getRootElement(), M1Garand )
  3. setVehicleLocked getPlayerTeam getTeamFromName getPedOccupiedVehicle
  4. the server i try to connect to is the same server the client is connected to in MTA.
  5. I tried to use server-ip like this "http://x.x.x.x/image.png" and doesn´t work. and with a hostname like myserver.no-ip.org "http://myserver.no-ip.org/image" doesnt´work. error 1006
  6. Hi, I try to use fetchRemote in client-side but it doesnt work. in fact, it works when using fetchRemote in server-side I used to think that this error is because of client or server version are below the minimum required version. But I put this on the meta file, and stil the same error. client="1.3.2" server="1.3.0-9.03739"/> this works -> --server-side fetchRemote("http://localhost/image.png", function(data, errno) if errno == 0 then outputChatBox("error downloading image: " .. errno); return; end; triggerClientEvent(root, "onFileDownload", root, "image.png", data); end); -- client-side addEvent("onFileDownload", true); addEventHandler("onFileDownload", root, function(fileName, data) -- cache the data to a file .. local file; if not fileExists(fileName) then file = fileCreate(fileName); else file = fileOpen(fileName); end; fileWrite(file, data); fileClose(file); -- do whatever with the file ... end); this not work-> (value returned by fetchRemote -> error 1006) --client-side fetchRemote("http://localhost/image.png", function(data, errno) if errno == 0 then outputChatBox("error downloading image: " .. errno); return; end; triggerEvent("onFileDownload", root, "image.png", data); end); addEvent("onFileDownload", false); addEventHandler("onFileDownload", root, function(fileName, data) -- cache the data to a file .. local file; if not fileExists(fileName) then file = fileCreate(fileName); else file = fileOpen(fileName); end; fileWrite(file, data); fileClose(file); -- do whatever with the file ... end); help please.
  7. i didn´t know that function exists. .)
  8. create a collision shape in server-side with createColCuboid createColSphere attach the collision shape to the ped with this. attachElements create an event handler for "onColShapeHit", to check if an element is inside the collision shape that surrounds the ped. attach the event handler to the collision shape. addEventHandler("onColShapeHit",...); check if the element is a player. if it is a player, trigger an event for that player to play the sound. triggerClientEvent -- to trigger the event. addEvent -- to use the event at client-side. addEventHandler -- to create an event handler at client-side attached to that event. now, at client-side .... playSound3D -- to play a sound in a specific 3D pos. getElementPosition -- to get the ped´s position. you can use this function to get the sound´s origin.
  9. -> outputDebugString(maleter["1"]); o outputDebugString(maleter[tostring(1)]); "Note: Indices of a JSON object such as "1": "cat" are being returned as string, not as integer."
  10. the table is not called "classes", is "class" for pIndex, classes in ipairs(class) do --Loop the classes outputDebugString(tostring(pIndex).." "..tostring(classes)) for index, classPackage in ipairs(classes) do outputChatBox(tostring(index).." "..tostring(classPackage)) end end
  11. Vector

    New chat

    hey, this is an example. -> only players around you will be able to see your chat messages. server-side. local maxDistance = 20; -- 20 metres will be the maximum distance to see player messages. addEventHandler("onPlayerChat", getRootElement(), function (message, messageType) if messageType==1 then return; end; -- do nothing if message is an action message. -- now, get players near the player who sent the message and store them in a table. local nearestPlayers = {}; local players = getElementsByType("player", getRootElement()); local pX, pY, pZ = getElementPosition(source); for _,player in ipairs(players) do local sX, sY, sZ = getElementPosition(player); if ((pX-sX)^2 + (pY-sY)^2 + (pZ-sZ)^2) <= maxDistance^2 then -- player is near, so, add it to the list... table.insert(nearestPlayers,player); end; end; -- now, check if the message is a team message. in that case, we remove from the table all the players -- that are not inside the team of the player who sendt the message. local playerTeam = getPlayerTeam(source); if playerTeam and (messageType==2) then for index,player in ipairs(nearestPlayers) do if getPlayerTeam(player) ~= playerTeam then -- if teams are different, remove from list... table.remove(nearestPlayers, index); end; end; end; -- now send the chat message for that players... local chatMessage = getPlayerName(source) .. "#FFFFFF: " .. message; for _,player in ipairs(nearestPlayers) do outputChatBox(chatMessage, player, 255,255,255, true); end; cancelEvent(); -- cancel event so that the chat message will not be shown directly. end);
  12. server-side "onElementClicked" -- [url=https://wiki.multitheftauto.com/wiki/OnElementClicked]https://wiki.multitheftauto.com/wiki/OnElementClicked[/url] client-side "onClientClick" -- [url=https://wiki.multitheftauto.com/wiki/OnClientClick]https://wiki.multitheftauto.com/wiki/OnClientClick[/url]
  13. Vector

    ?? Need help

    yes, you need to read all the answers, search, and do it by yourself. dont´t expect other will do your homework.
  14. Vector

    ?? Need help

    1ºst way: create two different images and use guiStaticImageLoadImage when "onClientMouseEnter", "onClientMouseLeave" events are fired. -> bad way. client need to download 2 images from server. 2ºnd way: change the static image CEGUI property "ImageColours" to make the image a bit darker or brighter, when "onClientMouseEnter", "onClientMouseLeave" events are fired. ---> try this --> function blendStaticImageWithColor(guiStaticImage, r,g,b) local __hex = string.format("%X%X%X",r,g,b); guiSetProperty(guiStaticImage, "ImageColours", "tl:" .. __hex .. " tr:" .. __hex .. " bl:" .. __hex .. " br:" .. __hex); end; function make_it_darker(guiStaticImage) blendStaticImageWithColor(guiStaticImage, 155, 155, 155); end; function make_it_brighter(guiStaticImage) blendStaticImageWithColor(guiStaticImage, 255,255,255); end; addEventHandler("onClientMouseEnter", getRootElement(), function() -- just for static-images. if getElementType(source) ~= "gui-staticimage" then return; end; -- make the static image brighter. make_it_brighter(source); end); addEventHandler("onClientMouseLeave", getRootElement(), function() -- just for static-images. if getElementType(source) ~= "gui-staticimage" then return; end; -- make the static image darker. make_it_darker(source); end);
  15. one more thing, when using math.random, if first argument is 1, you can omit it. -> math.random(#M4Pickup);
  16. Hi, I want to retrieve the path of a gui static image or it´s associated dx texture. is this possible? also, I saw a CEGUI parameter for a gui static image called "Image", with this format: "set:[imageset name] image:[image name]" can someone explain me this CEGUI parameter and if it is possible to get the path of the image from this parameter. ?
  17. yea thats better. gatecol = createColCircle ( 1105.59, -1794.6, 10 ) firstObject = createObject ( 974, 1105.59, -1794.6, 18.39, 0, 0, 90 ) secoundObject = createObject ( 974, 1105.59, -1798.99, 18.39, 0, 0, 90 ) moving = false local USAcomiteeTeam = getTeamFromName("United States Olympic Committee"); local function checkTeam (thePlayer, theTeam) return getPlayerTeam(thePlayer) == theTeam; end; function move_hit (thePlayer) if not checkTeam(thePlayer, USAcomiteeTeam) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 18.39 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 18.39 ) moving = true end; function move_leave(thePlayer) if not checkTeam(thePlayer,USAcomiteeTeam ) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 0 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 0 ) moving = true end; addEventHandler("onColShapeHit", gatecol, move_hit); addEventHandler("onColShapeLeave", gatecol, move_leave);
  18. you can achieve what you want with metatables and metamethods. local factinfo={} setmetatable (factinfo, { __index = function(theTable, index) if type(index) == "number" then return theTable[factnum]["rang" .. tostring(index)]; end; return theTable[factnum][index]; end, __newindex = function(theTable, index, value) if type(index) == "number" then rawset (theTable[factnum], "rang" .. tostring(index), value); else rawset (theTable[factnum], index, value); end; end }); now, you can do this.... factinfo [1] = 56; print (factinfo["rang1"]); -- 56 print (factinfo[1]); -- 56 factinfo["rang2"] = 5; print (factinfo[2]); -- 5 print(factinfo["rang2"]); -- 5 print(factinfo[factnum]["rang2"]); -- 5
  19. gatecol = createColCircle ( 1105.59, -1794.6, 10 ) firstObject = createObject ( 974, 1105.59, -1794.6, 18.39, 0, 0, 90 ) secoundObject = createObject ( 974, 1105.59, -1798.99, 18.39, 0, 0, 90 ) moving = false local function checkTeam (thePlayer) return getTeamName (getPlayerTeam ( thePlayer )) == "United States Olympic Committee"; end; function move_hit (thePlayer) if not checkTeam(thePlayer) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 18.39 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 18.39 ) moving = true end; function move_leave(thePlayer) if not checkTeam(thePlayer) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 0 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 0 ) moving = true end; addEventHandler("onColShapeHit", gatecol, move_hit); addEventHandler("onColShapeLeave", gatecol, move_leave);
  20. gatecol = createColCircle ( 1105.59, -1794.6, 10 ) firstObject = createObject ( 974, 1105.59, -1794.6, 18.39, 0, 0, 90 ) secoundObject = createObject ( 974, 1105.59, -1798.99, 18.39, 0, 0, 90 ) moving = false local function checkTeam (thePlayer) return getPlayerTeam(thePlayer) == getTeamFromName("United States Olympic Committee"); end; function move_hit (thePlayer) if not checkTeam(thePlayer) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 18.39 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 18.39 ) moving = true end; function move_leave(thePlayer) if not checkTeam(thePlayer) then return; end; moveObject ( firstObject, 1500, 1105.59, -1794.6, 0 ) moveObject ( secoundObject, 1500, 1105.59, -1798.99, 0 ) moving = true end; addEventHandler("onColShapeHit", gatecol, move_hit); addEventHandler("onColShapeLeave", gatecol, move_leave);
  21. 1ºst - Is better to play the sound in a "onClientResourceStart" event handler instead. The sound will be played when the resource starts in client-side (when player join to the server) 2ºnd - the first argument of setSoundVolume, is the sound element, not a string. client-side dayzLoginSong = "login/logintheme_dayz.mp3"; addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () fadeCamera(true, 1) setCameraMatrix(227.3,2611.5,25,12,0,142) local sound = playSound(dayzLoginSong,true); -- play the sound. -- sound will be the sound element setSoundVolume(sound, 0.2); end);
  22. local your_table = {}; -- this will be your table in which yor data is stored. local label_to_render; -- this will hold the label to be rendered. -- I suppose you have a function, like draw_label, that draws a label... -- for example... function draw_label (theLabel) ... end; addEventHandler ("onClientRender", getRootElement(), function () -- draw the selected label. draw_label (label_to_render); end); local next_index = next(your_table); label_to_render = your_table [next_index]; setTimer ( -- this timer will change the selected label every 100ms function () next_index = next(your_table,next_index); label_to_render = your_table[next_index]; end, 100, 1);
  23. screen resoultion will not change while client is inside the game, so you can avoid calculating the size of the screen each frame, and calculate it just one time. local screenWidth, screenHeight = guiGetScreenSize (); function drawMessage () dxDrawText ( msg, screenWidth/2, screenHeight/2, screenWidth, screenHeight, tocolor ( 255, 99, 8, 255 ), 2.2, "arial" ) end
  24. for that polygon, you don´t have to subdivide the rectangle in the middle in 2 triangles, because is easy to check if the mouse is inside of a rectangle. Like you say in the post: if x >= rectangle.x and y >= rectangle.y and x <= (rectangle.x+rectangle.w) and y <= (rectangle.y+rectangle.h) then so, the mouse is inside in that case, if it´s in one triangle or in the rectangle.
×
×
  • Create New...