-
Posts
636 -
Joined
-
Days Won
8
Everything posted by ds1-e
-
Are you sure that you changed hour and minute in server-side part? Works for me... -- Serverside function timeFunction() local realtime = getRealTime() local hours = realtime.hour local minutes = realtime.minute -- here if hours == 21 and minutes == 54 then triggerClientEvent(getRootElement(), "onClientPlaySound", resourceRoot) end end setTimer(timeFunction, 1000, 0) -- 60 000 = 1 minute, 0 = infinite times -- Clientside function onClientPlaySound() --[[local x, y, z = 0, 0, 0 -- change your coordinates here local sound = playSound3D("daytime.mp3", x, y, z, true) setSoundMaxDistance(sound, 1000) setSoundPanningEnabled(sound, true)]] outputDebugString("test") end addEvent("onClientPlaySound", true) addEventHandler("onClientPlaySound", resourceRoot, onClientPlaySound)
-
Try from this link: https://www.sendspace.com/file/3itdcd Scan: https://www.virustotal.com/gui/file/465cae2f1d365b4f84fb723ee569fa8937ec18ebd2c5dc416a92559905702f8d/detection
-
My bad, probably found out a issue. -- Serverside function timeFunction() local realtime = getRealTime() local hours = realtime.hour local minutes = realtime.minute -- here if hours == 7 and minutes == 0 then triggerClientEvent(getRootElement(), "onClientPlaySound", resourceRoot) end end setTimer(timeFunction, 60000, 0) -- 60 000 = 1 minute, 0 = infinite times -- Clientside function onClientPlaySound() local x, y, z = 0, 0, 0 -- change your coordinates here local sound = playSound3D("daytime.mp3", x, y, z, true) setSoundMaxDistance(sound, 1000) setSoundPanningEnabled(sound, true) end addEvent("onClientPlaySound", true) addEventHandler("onClientPlaySound", resourceRoot, onClientPlaySound)
-
Show me your code, i guess that you call them below declaring them as variables or not exactly in this function.
-
Add outputDebugString inside timeFunction, and also in condition which triggersClientEvent. https://wiki.multitheftauto.com/wiki/OutputDebugString To check, for sure.
-
Yes, something like this. I also fixed your code a bit. -- Serverside function timeFunction() local realtime = getRealTime() local hours = realtime.hour local minute = realtime.minute if hours == 7 and minutes == 0 then triggerClientEvent(getRootElement(), "onClientPlaySound", resourceRoot) end end setTimer(timeFunction, 60000, 0) -- 60 000 = 1 minute, 0 = infinite times -- Clientside function onClientPlaySound() local x, y, z = 0, 0, 0 -- change your coordinates here local sound = playSound3D("daytime.mp3", x, y, z, true) setSoundMaxDistance(sound, 1000) setSoundPanningEnabled(sound, true) end addEvent("onClientPlaySound", true) addEventHandler("onClientPlaySound", resourceRoot, onClientPlaySound)
-
Try: I've also fixed my mistake with elementData. local facVehsTable = { ["Police"] = { [1] = true, -- faction: 1, can enter [3] = true, -- faction: 3, can enter [4] = false, -- faction: 4, can't enter }, ["Medic"] = { [2] = true, -- faction: 2, can enter }, } -- function onVehicleStartEnter(player, seat, jacked, door) if seat == 0 then local vehid = getElementID(source) local faction = getElementData(player, "faction") -- mistake, fixed it if facVehsTable[vehid] then -- if vehid is equal to Police or Medic if not faction or not facVehsTable[vehid][faction] then -- if server can't get faction, or player faction isn't equal to one of in table cancelEvent() outputChatBox("#ff0000This is faction vehicle!", player, 230, 0, 0, true) end end end end addEventHandler("onVehicleStartEnter", getRootElement(), onVehicleStartEnter)
-
You can set timer to 1 minute, and every 1 minute it will call your function, also you can't play sounds server-side. You need to use triggerClientEvent to play sound from server to player/s.
-
If you want to send data to server use: https://wiki.multitheftauto.com/wiki/TriggerServerEvent
-
Are you sure that you call this function? Try to change 07 to 7 and 00 to 0 Code looks fine, use: https://wiki.multitheftauto.com/wiki/SetTimer
-
I think it's easy to do, you just need to modify table.
-
Try like that: local facVehsTable = { ["Police"] = 1, ["Medic"] = 2, } -- function onVehicleStartEnter(player, seat, jacked, door) if seat == 0 then local vehid = getElementID(source) local faction = getElementData(player) if facVehsTable[vehid] then -- if vehid is equal to Police or Medic if faction ~= facVehsTable[vehid] then -- if faction isn't equal to Police(1) or Medic(2) cancelEvent() outputChatBox("#ff0000This is faction vehicle!", player, 230, 0, 0, true) end end end end addEventHandler("onVehicleStartEnter", getRootElement(), onVehicleStartEnter)
-
This doesn't work like that. You need to change table structure or loop whole table, i suggest 1st option. Let me know if something wouldn't work. local facVehsTable = { [1] = "Police", [2] = "Medic", } -- function onVehicleStartEnter(player, seat, jacked, door) if seat == 0 then local vehid = getElementID(source) local faction = getElementData(player) if facVehsTable[vehid] then -- if vehid is equal to 1 or 2 if faction ~= facVehsTable[vehid] then -- if faction isn't equal to Police or Medic cancelEvent() outputChatBox("#ff0000This is faction vehicle!", player, 230, 0, 0, true) end end end end addEventHandler("onVehicleStartEnter", getRootElement(), onVehicleStartEnter)
-
You should include this: https://wiki.multitheftauto.com/wiki/Math.round This is not built-in, but an useful function.
-
https://wiki.multitheftauto.com/wiki/Authorized_Serial_Account_Protection Be sure that this is empty: <auth_serial_groups></auth_serial_groups> In mtaserver.conf
- 1 reply
-
- 1
-
Using ipairs is bad idea. local playerWeapons = { ["AK-47"] = 2222, -- example id, not sure if correct ["M4A1"] = 3333, -- example id, not sure if correct } local weapon = getElementData(source, "currentweapon_1") -- basing on dayz, this is element data which keeps weapon which player hold in hand local correct_weapon = playerWeapons[weapon] if correct_weapon then -- do your stuff. end Simply add: isElement(armaobject) You should start reading carefully warning/error codes. nil = empty/doesn't exist, this is also used for clearing variables, tables, etc. Expected element got non-existing thing.
-
Exports are faster? I mean that this events will be in same resource, just another file on same side, also they would be attached to resourceRoot.
-
Does triggerEvent have a big performance impact on same side? Need to ask, because i thought about separating some parts of code on certain files.
-
It worked, thanks again I need to ask about moment when server prepare string with function dbPrepareString, this is the moment when table is created/re-created. I was thinking it's possible that due of timing this will be executed at same time, so data for another player wouldn't save (script re-creates tables). Not sure if it's only my imagination.
-
What's purpose for elementdata here? Can you send full code? Maybe mistake is somewhere else.
-
It is, but i couldn't help you. I prefer simple GUI.
-
You might check that: https://springrts.com/wiki/Lua_Performance Loops, localize variables, unpack, and much more. I don't recommend to use ipairs at all. Int loop is much faster.
-
dx ~= gui This doesn't work as it is in your code, example code with toggle on/off. local screenW, screenH = guiGetScreenSize() local enabled = true function renderPanel() if enabled then dxDrawRectangle(screenW * 0.3324, screenH * 0.2799, screenW * 0.3609, screenH * 0.3581, tocolor(0, 0, 0, 205), false) dxDrawRectangle(screenW * 0.6428, screenH * 0.2513, screenW * 0.0483, screenH * 0.0208, tocolor(254, 23, 23, 205), false) dxDrawText("Close", screenW * 0.6420, screenH * 0.2513, screenW * 0.6911, screenH * 0.2721, tocolor(255, 255, 255, 205), 1.00, "default", "center", "top", false, false, false, false, false) end end addEventHandler("onClientRender", getRootElement(), renderPanel) function openPanel() enabled = not enabled end addCommandHandler("openpanel", openPanel)
-
Thanks, but what if i would need to use WHERE to check if serial is matching with a player?
-
Also, i need to ask about that, it's possible to obtain data from 2 tables in one query? In my case `Players` and `Items`?