Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. local myFiles = { ["Destruction Zones"] = "destruction.xml", ["Environment"] = "env.xml", ["Ferris Wheel"] = "ferris.xml", ["HeadQuarters"] = "hq.xml", ["Horseshoe Mission"] = "horseshoe.xml", ["Shops"] = "shops.xml", ["Skins"] = "skins.xml", ["UFO"] = "ufo.xml", ["Vehicles"] = "veh.xml", ["Weapons"] = "weap.xml", ["Weed Mission"] = "weed.xml", } function myHelpList(key, keyState) helpWindow = guiCreateWindow(0.1768,0.2188,0.6475,0.6641,"Help Window",true) guiSetAlpha(helpWindow,1) guiWindowSetSizable(helpWindow,false) closeButton = guiCreateButton(0.3725,0.8922,0.2398,0.0784,"Close",true,helpWindow) guiSetFont(closeButton,"default-bold-small") helpEdit = guiCreateEdit(0.2247,0.1471,0.7225,0.7137,"",true,helpWindow) guiEditSetReadOnly( helpEdit, true ) helpGrid = guiCreateGridList(0.0136,0.1451,0.1961,0.7157,true,helpWindow) guiGridListSetSelectionMode(helpGrid,2) guiGridListAddColumn(helpGrid,"Freeroam",0.2) for name, file in pairs(myFiles) do local row = guiGridListAddRow(helpGrid) guiGridListSetItemText(helpGrid,row,1,tostring(name),false,false) end end addCommandHandler("help", myHelpList) bindKey("F9", "down", myHelpList) addEventHandler("onClientGUIClick",root, function () if (source == helpGrid) then local row,col = guiGridListGetSelectedItem(source) if (row and col and row ~= -1 and col ~= -1) then local name = guiGridListGetItemText(source,row,1) if fileExists(myFiles[name]) then local file = xmlLoadFile(myFiles[name]) local text = xmlNodeGetValue(file) guiSetText(helpEdit, tostring(text)) xmlUnloadFile(file) end end end end )
  2. HospitalSF = createColSphere(-2654, 639, 15, 1) HospitalLV = createColSphere(1608, 1817, 11, 1) HospitalFC = createColSphere(-320, 1051, 21, 1) HospitalM = createColSphere(1243, 329, 20, 1) HospitalLS1 = createColSphere(2035, -1404, 18, 1) HospitalLS2 = createColSphere(1174, -1323, 16, 1) function Exit() destroyElement(HospitalW) setTimer(fadeCamera,1000,1,true,1) showCursor(false) end addEventHandler("onClientColShapeHit",root, function(theElement) if (source == HospitalSF or source == HospitalLV or source == HospitalFC or source == HospitalM or source == HospitalLS1 or source == HospitalLS2) then if theElement == localPlayer then setTimer(fadeCamera,50,1,false,1,0,0,0) showCursor(true) Name = getPlayerName(localPlayer) Money = getPlayerMoney(localPlayer) Skin = getElementModel(localPlayer) HospitalW = guiCreateWindow(291,266,551,269,"Hospital",false) Name = guiCreateLabel(24,28,128,18,"Name: "..Name.."",false,HospitalW) Currency = guiCreateLabel(24,52,121,18,"Currency: "..Money.."",false,HospitalW) Skin = guiCreateLabel(24,75,113,18,"Skin(ID): "..Skin.."",false,HospitalW) Bar = guiCreateScrollBar(74,146,361,22,true,false,HospitalW) FeeL = guiCreateLabel(91,123,85,18,"Fee: "..tostring( fee ) .."",false,HospitalW) HPL = guiCreateLabel(371,123,85,18,"HP: "..tostring( getElementHealth( localPlayer ) ) .."",false,HospitalW) ExitB = guiCreateButton(237,219,81,35,"Exit",false,HospitalW) HealB = guiCreateButton(441,144,101,26,"Heal",false,HospitalW) Img = guiCreateStaticImage(148,33,251,93,"Hospilogo.png",false,HospitalW) addEventHandler("onClientGUIClick",HealB,Heal,false) addEventHandler("onClientGUIClick",ExitB,Exit,false) end end end ) function getBarPos() if Bar and isElement( FeeL ) then local fee = guiScrollBarGetScrollPosition(Bar) guiSetText( FeeL,"Fee: ".. tostring( fee ) ) end end addEventHandler( "onClientRender",root,getBarPos ) function Heal() local fee = guiScrollBarGetScrollPosition(Bar) local money = getPlayerMoney(localPlayer) if (money < fee) then outputChatBox("You aint got the greens") else triggerServerEvent("takeMoney",getRootElement(),fee) setElementHealth(localPlayer, getElementHealth(localPlayer) + fee) outputChatBox("Recovered ".. fee .."% of HP!") end end
  3. https://wiki.multitheftauto.com/wiki/Res ... le_storage
  4. Castillo

    Consulta

    La unica manera es aprendiendo a programar en Lua. https://wiki.multitheftauto.com/wiki/ES/ ... %B3n_a_Lua https://wiki.multitheftauto.com/wiki/ES/ ... B3n_de_GUI
  5. Castillo

    Consulta

    Si queres un sistema de misiones lo tenes que crear, no podes usar "dyom" en MTA.
  6. Did it work? if so, you're welcome.
  7. HospitalSF = createColSphere(-2654, 639, 15, 1) HospitalLV = createColSphere(1608, 1817, 11, 1) HospitalFC = createColSphere(-320, 1051, 21, 1) HospitalM = createColSphere(1243, 329, 20, 1) HospitalLS1 = createColSphere(2035, -1404, 18, 1) HospitalLS2 = createColSphere(1174, -1323, 16, 1) function Heal() if (Money < fee) then outputChatBox("You aint got the greens") else local fee = guiScrollBarGetScrollPosition(Bar) triggerServerEvent("takeMoney",getRootElement(),fee) setElementHealth(localPlayer, getElementHealth(localPlayer) + fee) outputChatBox("Recovered ".. fee .."% of HP!") end end function Exit() destroyElement(HospitalW) setTimer(fadeCamera,1000,1,false,1,0,0,0) end addEventHandler("onClientColShapeHit",getRootElement(), function() if (source == HospitalSF or HospitalLV or HospitalFC or HospitalM or HospitalLS1 or HospitalLS2) then setTimer(fadeCamera,1000,1,true,1) Name = getPlayerName(localPlayer) Money = getPlayerMoney(localPlayer) Skin = getElementModel(localPlayer) HospitalW = guiCreateWindow(291,266,551,269,"Hospital",false) Name = guiCreateLabel(24,28,128,18,"Name: "..Name.."",false,HospitalW) Currency = guiCreateLabel(24,52,121,18,"Currency: "..Money.."",false,HospitalW) Skin = guiCreateLabel(24,75,113,18,"Skin(ID): "..Skin.."",false,HospitalW) Bar = guiCreateScrollBar(74,146,361,22,true,false,HospitalW) HPL = guiCreateLabel(91,123,85,18,"HP: "..fee.."",false,HospitalW) ExitB = guiCreateButton(237,219,81,35,"Exit",false,HospitalW) HealB = guiCreateButton(441,144,101,26,"Heal",false,HospitalW) Img = guiCreateStaticImage(148,33,251,93,"Hospilogo.png",false,HospitalW) addEventHandler("onClientGUIClick",HealB,Heal,false) addEventHandler("onClientGUIClick",ExitB,Exit,false) end end ) function getBarPos() if Bar then local fee = guiScrollBarGetScrollPosition(Bar) guiSetText(HPL,"Fee: ".. tostring(fee)) end end addEventHandler("onClientRender",getRootElement(),getBarPos)
  8. You mean non-peds or non-players? you want to check if the element that hit the colshape is a ped (a NPC) or a player?
  9. Eso es porque cambiaste el nombre de la funcion pero no en el event handler. function manejadorDeInicio() local x = 1959.55 local y = -1714.46 local z = 10 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Bienvenido a Mi Servidor", source) end addEventHandler("onPlayerJoin", getRootElement(), manejadorDeInicio) -- Aca.
  10. You can use the Client animation library by arc_ to do that. --[[ Client animation library by arc_ Version 1.0.0 Licence ---------------- You are free to modify this file and redistribute it with your changes. However, always mention that you changed it (and eventually what changes you made) and keep the original author, version number and licence intact. Selling this script or a derivative of it is not allowed. Documentation ---------------- Terminology - Animation: a sequence of phases that act on one or more elements and follow each other sequentially in time. Multiple animations can be running at the same time. All defined animations run in parallel. An animation is in fact one phase with several subphases (see below), with animation specific functions available. - Phase: a part of an animation sequence. A phase consists of a paramater that linearly goes from a given starting value to a given ending value, over the specified amount of time, and is applied to one certain element. While a phase is running, its callback function will be called onClientRender with the following arguments: phase.fn(element elem, float param, table phase) Specifying time and callback function is optional. If no time is specified but a function is, phase.fn(elem) will be called once. If no function is specified but a time is, the phase consists of simply waiting during that time, doing nothing. A phase can be run once, repeated multiple times or loop infinitely. Phases can also contain phases. In that case the parent phase consists of completing all child phases, in order. This allows you to f.e. make an element move left and right continuously: define a phase for moving it to the left, followed by a phase for moving it back to the right, and encapsulate these two phases in a parent phase that loops forever. Phases can be nested to arbitrary depth. The element a subphase works on is inherited from its parent phase (or, if the parent phase doesn't specify an element, from the grandparent, etc). Definition of a phase A phase is simply a table containing properties and (optionally) subphases. Available phase properties are: (the values for the properties are examples, not default values) phase = { from = 0, -- the starting value of the parameter to = 1, -- the ending value of the parameter [time = 1000,] -- the time (in ms) in which to go from start to end [fn = callback,] -- the function to call on each frame update [repeats = 5,] -- how many times to run this phase before going on to -- the next. defaults to 1 [subphase1,] -- optional subphases. if one or more of these are included, [subphase2,] -- only the "repeats" property is valid for this parent phase ... } Available functions anim = Animation.create(elem, phase1, phase2, ...) Creates and returns a new animation. This means nothing more than creating a new phase, putting the specified phases in it as subphases, and making the functions of the Animation class available to it. Once an animation is created, it is not yet running. anim = Animation.createAndPlay(elem, phase1, phase2, ...) Creates a new animation and immediately starts playing it. anim = Animation.createNamed(name, elem, ...) If an animation with the specified name exists, returns that animation. Otherwise creates a new named animation. You can look the animation up again later with Animation.getNamed(name). anim = Animation.createNamedAndPlay(name, elem, ...) Self explanatory. anim = Animation.getNamed(name) Returns the animation with the specified name if it exists, false otherwise. anim:play() Start playing a newly created animation or resume a paused animation. anim:pause() Pauses the animation. Resume it later with anim:play() or delete it with anim:remove(). anim:remove() Deletes the animation completely. It can not be resumed anymore. anim:isPlaying() Returns true if the animation is currently playing, false if not. Animation.playingAnimationsExist() Returns true if there is any animation that is currently playing. anim:addPhase(phase3), phase2:addPhase(phase3) Appends a new subphase to the animation or phase. Can be done while the animation is playing. Note that to be able to use phase2:addPhase(), phase2 first has to be processed (default values filled in, made part of the Phase class) by being passed as an argument to Animation.create[AndPlay] or addPhase. Examples Fade in a picture: local pict = guiCreateStaticImage(...) Animation.createAndPlay(pict, { from = 0, to = 1, time = 2000, fn = guiSetAlpha }) Fade in a picture using a preset (for more presets, see the end of this file): local pict = guiCreateStaticImage(...) Animation.createAndPlay(pict, Animation.presets.guiFadeIn(2000)) Move a label to the right while fading it in: local label = guiCreateLabel(10, 100, 150, 20, 'Test', false) Animation.createAndPlay(label, Animation.presets.guiMove(200, 100, 2000)) Animation.createAndPlay(label, Animation.presets.guiFadeIn(2000)) Move a label left and right forever, without presets: function guiSetX(elem, x) local curX, curY = guiGetPosition(elem, false) guiSetPosition(elem, x, curY, false) end local label = guiCreateLabel(10, 100, 150, 20, 'Test', false) Animation.createAndPlay( label, { repeats = 0, { from = 10, to = 200, time = 2000, fn = guiSetX }, { from = 200, to = 10, time = 2000, fn = guiSetX } } ) ]]-- Phase = {} Phase.__index = Phase Animation = setmetatable({}, { __index = Phase }) Animation.__index = Animation Animation.collection = {} function Animation.create(elem, ...) local anim = setmetatable({ elem = elem, ... }, Animation) anim:_setup() return anim end function Animation.createAndPlay(elem, ...) local anim = Animation.create(elem, ...) anim:play() return anim end function Animation.createNamed(name, elem, ...) local anim = Animation.getNamed(name) or Animation.create(elem, ...) anim.name = name return anim end function Animation.createNamedAndPlay(name, elem, ...) local anim = Animation.createNamed(name, elem, ...) anim:play() return anim end function Animation.getNamed(name) local i, anim = table.find(Animation.collection, 'name', name) return i and anim end function Animation:isPlaying() return self.playing or false end function Animation.playingAnimationsExist() return table.find(Animation.collection, 'playing', true) and true end function Animation:play() if self.playing then return end if not table.find(Animation.collection, self) then table.insert(Animation.collection, self) end if not Animation.playingAnimationsExist() then addEventHandler('onClientRender', getRootElement(), updateAnim) end self.playing = true end function Animation:pause() self.playing = false if not Animation.playingAnimationsExist() then removeEventHandler('onClientRender', getRootElement(), updateAnim) end end function Animation:remove() table.removevalue(Animation.collection, self) if not Animation.playingAnimationsExist() then removeEventHandler('onClientRender', getRootElement(), updateAnim) end self.playing = false end function Phase:_setup(parent) self.parent = parent if self[1] then for i,phase in ipairs(self) do if type(phase) == 'function' then phase = { fn = phase } self[i] = phase end setmetatable(phase, Phase) phase:_setup(self) end self.curphase = 1 elseif self.time then self.from = self.from or 0 self.to = self.to or 1 self.speed = (self.to - self.from) / self.time end self.repeats = self.repeats
  11. playerTeam = getPlayerTeam(source) if (not playerTeam) then return end local team = getTeamName(playerTeam) if (team == "1") then name = getPlayerName(source) else health = getElementHealth(source) end P.S: You're using this with a function, right?
  12. Castillo

    Question

    In the wiki page you'll find a example of how it works. Wiki example: function makeLineAppear() testVehicle = createVehicle ( 411, 0, 0, 5 ) -- Create our test vehicle. addEventHandler("onClientRender", getRootElement(), createLine) -- onClientRender keeps the 3D Line visible. end function createLine ( ) x1, y1, z1 = getElementPosition ( testVehicle ) -- Get test vehicles position. x2, y2, z2 = getElementPosition ( getLocalPlayer ()) -- Get local players position. dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between test vehicle and local player. end addCommandHandler("test", makeLineAppear)
  13. local cones = {} function spawnCones (thePlayer) if (not cones[thePlayer]) then cones[thePlayer] = {} end local x,y,z = getElementPosition ( thePlayer ) local index = #cones[thePlayer] +1 cones[thePlayer][index] = createObject (1238, x, y, z-0.6) outputChatBox("Created cone, ID: ".. index .."!",thePlayer,0,255,0) end addCommandHandler ( "cone", spawnCones) function destroyCones(thePlayer) if (not cones[thePlayer]) then cones[thePlayer] = {} end for index, cone in pairs(cones[thePlayer]) do if isElement(cone) then destroyElement(cone) end end outputChatBox("Removed cones!",thePlayer,0,255,0) end addCommandHandler ( "deletecone", destroyCones) That'll remove all player cones.
  14. In the top of the map file you'll find: "editor_main">
  15. Si, podes usar colshapes o markers. createMarker [url=https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions#Collision_shape_functions]https://wiki.multitheftauto.com/wiki/Ser ... _functions[/url]
  16. local cones = {} function spawnCones (thePlayer) if (not cones[thePlayer]) then cones[thePlayer] = {} end local x,y,z = getElementPosition ( thePlayer ) local index = #cones[thePlayer] +1 cones[thePlayer][index] = createObject (1238, x, y, z-0.6) outputChatBox("Created cone, ID: ".. index .."!",thePlayer,0,255,0) end addCommandHandler ( "cone", spawnCones) function destroyCones(thePlayer, cmd, id) if (not cones[thePlayer]) then cones[thePlayer] = {} end local id = tonumber(id) if isElement(cones[thePlayer][id]) then destroyElement(cones[thePlayer][id]) outputChatBox("Removed cone, ID: ".. id .."!",thePlayer,0,255,0) end end addCommandHandler ( "deletecone", destroyCones)
  17. Castillo

    Radio chat

    function radioChat(thePlayer, cmd, ...) local msg = table.concat({...}, " ") if (msg and msg ~= "") then outputChatBox("(Radio)".. getPlayerName(thePlayer) ..": ".. msg ..", over.",root,255,50,0,true) end end addCommandHandler("Radio",radioChat) addEventHandler("onPlayerJoin",root, function () bindKey(source,"R","down","chatbox","Radio") end ) addEventHandler("onResourceStart",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do bindKey(player,"R","down","chatbox","Radio") end end )
  18. Necesitas las funciones siguientes: createObject -- O un objeto en un mapa. moveObject -- Para mover el objeto. addCommandHandler -- Para poner los comandos. isObjectInACLGroup -- Para checkear si el jugador es admin.
  19. Again uploaded "Vigilante 8": https://community.multitheftauto.com/index.php?p= ... ls&id=3832 Edit: Skin mods: https://community.multitheftauto.com/index.php?p= ... ls&id=3843 https://community.multitheftauto.com/index.php?p= ... ls&id=3842 Vehicle mods: https://community.multitheftauto.com/index.php?p= ... ls&id=3841
  20. local timers = {} function aFunction(sourcePlayer) timers[getPlayerName ( sourcePlayer ).."Timer"] = setTimer ( anotherFunction, 120000, 1, sourcePlayer ) end function anotherAnotherFunction ( sourcePlayer ) if isTimer(timers[getPlayerName ( sourcePlayer ).."Timer"]) then killTimer(timers[getPlayerName ( sourcePlayer ).."Timer"]) end end
  21. This gamemode: https://community.multitheftauto.com/index.php?p= ... ls&id=3831 is not created by him, it's Interstate69 made by Lucif3r. Original: https://community.multitheftauto.com/index.php?p= ... ails&id=32
  22. Why do you say: "Free Web-Template for SA-MP Communities" and post it on MTA forums?
  23. Castillo

    Question!

    What? that question just makes no sense. This is the MTA forums, not the SA-MP forums. MTA and SA-MP has nothing in common.
×
×
  • Create New...