Jump to content

Vector

Members
  • Posts

    114
  • Joined

  • Last visited

Everything posted by Vector

  1. Vector

    multi ColCuboid

    wait, I´ll try the code.
  2. Vector

    multi ColCuboid

    You need to learn lua first 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), 0, 255, 0); end; end);
  3. -- this function return the x,y,z coordinates of the nearest point. function findNearestCoordinates (x, y, z) local nearestPoint = coordinatesTable [1]; local minSqrDist = (nearestPoint[1] - x)^2 + (nearestPoint[2] - y)^2 + (nearestPoint[3] - z)^2; for i=2,#coordinatesTable,1 do local j = coordinatesTable [i]; local d = (j[1] - x)^2 + (j[2]-y)^2 + (j[3]-z)^2; if d < minSqrDist then d = minSqrDist; nearestPoint = j; end; end; return unpack (nearestPoint); end; example -> local pX, pY, pZ = getElementPosition (player); local sX, sY, sZ = findNearestCoordinates (pX, pY,pZ); -- nearest point to player is sX, sY, sZ
  4. use this function to craeate a indestructible car, instead of createVehicle -> -- arguments are the same than createVehicle function createIndestructibleVehicle (...) local vehicle = createVehicle (unpack({...})); -- create vehicle if not vehicle then return false; end; setVehicleDamageProof (vehicle, true); -- enable damage proof return vehicle; end; example -> -- this creates a indestructible hunter near of the player. local pX,pY,pZ = getElementPosition (player); createIndestructibleVehicle (425, pX+2, pY+2, pZ);
  5. hello, I want to show you an easier way of calling functions exported by other resources, adding a few lines of code in your script file. suppose you have a resource called "myResource". And this resource exports a function "foo" wich you want to call by other resource. the proper way to do that, according with https://wiki.multitheftauto.com/wiki/Call is ... exports.myResource:foo (...); -- or ... call (getResourceFromName("myResource"), "foo", ...); if you add the lua code below, you´ll be able to call foo like this-> importFunctions ("myResource"); -- import the functions exported by "myResource" foo (...); -- easy way. you need to add the next script lines in your file. -> function importFunctions (resourceName) local resource = getResourceFromName (resourceName); if not resource then outputDebugString ("Couldnt import functions from \"" .. resourceName .. "\" resource because" .. "it doesnt exist!", 2); return; end; local exportedFuncNames = getResourceExportedFunctions (resource); if not exportedFuncNames then return end; for i,j in ipairs (exportedFuncNames) do _G [j] = function (...) call (resource, j, unpack ({...})); end; end; end; also, you can import functions for different resources. in fact, if two resources have a function with the same name, one function will replace the other one. here is an example -> -- 1º st resource "myResource_1" have two functions: foo, bar. -- 2º nd resource "myResource_2" have the next exported funcs: bar, foobar. importFunctions ("myResource_1"); -- import funcs. foo (...); -- calling to exports.myResource_1.foo bar (...); -- calling to exports.myResource_1.bar importFunctions ("myResource_2"); foo (...); -- calling to exports.myResource_1.foo bar (...); -- now calling to exports.myResource_2.bar foobar (...); -- calling to exports.myResource_2.foobar hope you find this useful.
  6. Vector

    Access Denied.

    It works fine, thanks. silly of me..
  7. Vector

    Access Denied.

    Can you explain a bit more?
  8. Hi, guys. I tried to use the next functions in my scripts (server-side) but they didnt work ... createResource, deleteResource, startResource, stopResource, restartResource. When running the script, the console said: WARNING: Access Denied @ 'createResource' WARNING: Access Denied @ 'deleteResource' WARNING: Access Denied @ " " It said "WARNING" but the functions are not called How can avoid this?
  9. I tried this code in the client side script and does not work. Please help. [color=#0000FF]function[/color] outputPressedCharacter(character) [color=#0000FF]if [/color]character==[color=#FF0040]" "[/color] then [color=#00FF00]--if the character is a space[/color] character = [color=#FF0040]"space"[/color][color=#00FF00] --change 'character' to 'space'[/color] [color=#0000FF]end[/color] outputChatBox([color=#FF0040]"You pressed the character "[/color]..character..[color=#FF0040]"!"[/color]) [color=#00FF00]--output the character[/color] [color=#0000FF]end[/color] addEventHandler([color=#FF0040]"onClientCharacter"[/color], getRootElement(), outputPressedCharacter)
  10. nothing happen meta file => [color=#0000FF]<meta>[/color] <[color=#0000FF]info[/color][color=#008080] author[/color]=[color=#FF0040]"__Vector__"[/color] [color=#008080]version[/color]=[color=#FF0040]"1.0"[/color] [color=#008080]description[/color]=[color=#FF0040]"My Script" [/color][color=#008080]type[/color]=[color=#FF0040]"script"[/color] /> <[color=#0000FF]script[/color] [color=#008080]src[/color]=[color=#FF0040]"client.lua"[/color] [color=#008080]type[/color]=[color=#FF0040]"client"[/color] /> <[color=#0000FF]srcipt[/color] [color=#008080]src[/color]=[color=#FF0040]"server.lua"[/color] [color=#008080]type[/color]=[color=#FF0040]"server"[/color] /> [color=#0000FF]</meta>[/color]
  11. Does not work as well. According to the mta wiki. the third argument of triggerClientEvent is "The element that is the source of the event. This could be another player, or if this isn't relevant, use the root element." irrelevant. so your code does not remove the error, just assigning to the global variable "source", the variable "thePlayer". But thanks.
  12. I have two scripts. The client side script and the server side script. The server side script is executed, but the client side script not. Seems that events and event handlers in the client side are not created, so, the function triggerClientEvent has no effect. here is my meta file -->> [color=#0000FF]<meta>[/color] <[color=#0000FF]info[/color][color=#008080] author[/color]=[color=#FF0040]"__Vector__"[/color] [color=#008080]version[/color]=[color=#FF0040]"1.0"[/color] [color=#008080]description[/color]=[color=#FF0040]"My Script" [/color][color=#008080]type[/color]=[color=#FF0040]"script"[/color] /> <[color=#0000FF]script[/color] [color=#008080]src[/color]=[color=#FF0040]"server.lua"[/color] [color=#008080]type[/color]=[color=#FF0040]"server"[/color] /> <[color=#0000FF]srcipt[/color] [color=#008080]src[/color]=[color=#FF0040]"client.lua"[/color] [color=#008080]type[/color]=[color=#FF0040]"client"[/color] /> [color=#0000FF]</meta>[/color] server file script -> server.lua [color=#0000FF]local[/color] function foo (thePlayer) triggerClientEvent (getRootElement (),[color=#FF0040]"runit"[/color], getRootElement (), thePlayer); [color=#0000FF]end;[/color] addCommandHandler ([color=#FF0040]"run"[/color], foo, [color=#0000FF]false[/color], [color=#0000FF]false[/color]); client file script -> client.lua [color=#0000FF]local[/color] function bar (thePlayer) outputChatBox (getPlayerName (getLocalPlayer ()) .. [color=#FF0040]" receives an event from player "[/color] .. getPlayerName (thePlayer), getRootElement (), [color=#008080]255[/color], [color=#008080]0[/color], [color=#008080]0[/color]); [color=#00BF00] -- this does not print nothing[/color] [color=#0000FF]end;[/color] addEvent ([color=#FF0040]"runit"[/color], [color=#0000FF]true[/color]); addEventHandler ([color=#FF0040]"runit"[/color], getRootElement (), bar);
×
×
  • Create New...