Jump to content

Patrick

Moderators
  • Posts

    1,143
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by Patrick

  1. https://wiki.multitheftauto.com/wiki/OnMarkerHit https://wiki.multitheftauto.com/wiki/GetPedOccupiedVehicle https://wiki.multitheftauto.com/wiki/SetElementPosition https://wiki.multitheftauto.com/wiki/SetElementDimension https://wiki.multitheftauto.com/wiki/SetElementInterior
  2. So, you want to load a xml file with xmlLoadFile from other resource? Enter the full path, from the root resource folder. ( start path with : ) xmlLoadFile(":OTHER_RESOURCE_NAME/SUBFOLDER/file.xml")
  3. I think you can't do that, but you can export functions. Wiki: https://wiki.multitheftauto.com/wiki/Call Example: -- CLIENT function print_msg(msg) outputChatBox(msg) end <meta> <script src="client.Lua" type="client"/> <export function="print_msg" type="client"/> </meta> After it you can call this 'print_msg' function from other resources: -- CLIENT exports.FIRST_RESOURCE_NAME:print_msg("called from other resource")
  4. In line 4 don't use local, because you want to change the global g variable's value. Now, you change g only inside giveGold function's scope, what has no effect on the global g variable in the first line.
  5. local obj addCommandHandler("test", function(plr, cmd) if not isElement(obj) then local x, y, z = getElementPosition(plr) obj = createObject(1234, x, y, z) else outputChatBox("'obj' already created, destroy it first.", root) end end) addEvent("trigger", true) addEventHandler("trigger", root, function() if isElement(obj) then destroyElement(obj) else outputChatBox("'obj' not found, create it first.", root) end end)
  6. player variable not defined. When you trigger it from client side, pass the player element in first argument. triggerServerEvent("givemins", localPlayer, PLAYER_ELEMENT)
  7. test = { [1] = 1, [2] = 2, [3] = 3, } local ot = test[math.random(1, #test)] outputChatBox(ot)
  8. The marker maybe too small or too low in the ground.
  9. -- SERVER addEventHandler("onPlayerCommand", root, function(cmd) if cmd == "nick" then cancelEvent() end end)
  10. https://wiki.multitheftauto.com/wiki/GetPlayerMoney local marker = createMarker(2167.1208496094,-1672.4111328125,13.075506210327,"cylinder", 1.5, 139, 0, 285,77) local Blip = createBlipAttachedTo(marker,31) function myCommandHandler(thePlayer) if isElementWithinMarker(thePlayer, marker) then if getPlayerMoney(thePlayer) >= 35000 then takePlayerMoney( thePlayer, 35000 ) outputChatBox('Gratulálok az új lakásához! A Lakás kulcsai mostantól az Öné! (IK: /086372)',thePlayer,60,238,7) else outputChatBox("Nincs elég pénzed!", thePlayer, 255, 0, 0) end end end addCommandHandler('lakasvetel1',myCommandHandler) And one more thing, read this before your next post in this topic
  11. I think because the animation ends after 1 minute but freezeLastFrame is enabled. So, the animation is no longer running, it just seems.
  12. https://wiki.multitheftauto.com/wiki/SetPlayerHudComponentVisible -- CLIENT setPlayerHudComponentVisible("area_name", false)
  13. -- loop trough the 'result' table for i, v in ipairs(result) do outputChatBox(v) end
  14. Looks like something like this local respawnPoints = { {0, 0, 3}, } local function findNearestRespawnPoint(x, y, z) local nearestPoint = { distance = 99999, index = 1 } for i, v in ipairs(respawnPoints) do local distance = getDistanceBetweenPoints3D(x, y, z, v[1], v[2], v[3]) if distance < nearestPoint.distance then nearestPoint = { distance = distance, index = i } end end return respawnPoints[nearestPoint.index] end local function respawnPlayer(player) local x, y, z = getElementPosition(player) local point = findNearestRespawnPoint(x, y, z) spawnPlayer(player, point[1], point[2], point[3]) end addEventHandler("onPlayerWasted", root, function() setTimer(respawnPlayer, 1000, 1, source) end)
  15. Patrick

    Random?

    You're in bad luck dude It has to work.
  16. onPlayerWasted event => call the respawn function => find the cloesest point from the array with for loop => spawnPlayer
  17. https://wiki.multitheftauto.com/wiki/IsPlayerInACL This example open window with command. First, check acl rights on server side, after it trigger client. -- SERVER function isPlayerInACL(player, acl) if isElement(player) and getElementType(player) == "player" and aclGetGroup(acl or "") and not isGuestAccount(getPlayerAccount(player)) then local account = getPlayerAccount(player) return isObjectInACLGroup( "user.".. getAccountName(account), aclGetGroup(acl) ) end return false end addCommandHandler("open", function(player) if isPlayerInACL(player, "groupWhoCanOpenPanel") then -- is player added to acl group? triggerClientEvent(player, "openPanel", player) -- if yes trigger the panel open else outputChatBox("You have no right to it :(", player) -- :( end end) -- CLIENT addEvent("openWindow", true) addEventHandler("openWindow", root, function() guiSetVisible(window, true) guiBringToFront(window) end)
  18. You don't have to check it. If it is, it will flash.
  19. https://wiki.multitheftauto.com/wiki/SetWindowFlashing
  20. addEventHandler("onPlayerJoin", root, function() local server_table = { 'function() return true end', 'function() outputChatBox("ANOTHER FUNCTION") return false end', } for k, v in pairs(server_table) do triggerClientEvent("r", source, k, v) end end) addEvent("r", true) addEventHandler("r", root, function(i, v) outputChatBox("RECEIVED > " .. i .. " > " .. v) -- load local func, err = loadstring("return "..v) local results = {pcall(func)} -- call local func_results = {results[2]()} outputChatBox(inspect(func_results)) end)
×
×
  • Create New...