-
Posts
39 -
Joined
-
Last visited
Everything posted by Keiichi1
-
You can't set the player's money over that value. Use ElementData. Code (server): -- When this script starts set every players' 'money' elementdata to 0, if they haven't got one already. for _, player in ipairs(getElementsByType("player")) do if not getElementData(player, "money") then setElementData(player, "money", 0) end end -- When a player joins set the 'money' elementdata to 0. addEventHandler("onPlayerJoin", getRootElement(), function() setElementData(source, "money", 0) end) addCommandHandler("givemoney", function(thePlayer, cmd, targetName, amount) if targetName and tonumber(amount) then local target = getPlayerFromName(targetName) if target then setElementData(target, "money", getElementData(target, "money") + tonumber(amount)) outputChatBox("You gave $"..amount.." to "..targetName.."!", thePlayer, 0, 200, 0) outputChatBox("You got $"..amount.."!", target, 0, 200, 0) else outputChatBox("Player not found.", thePlayer, 255, 0, 0) end else outputChatBox("Usage: /givemoney [playername] [amount]", thePlayer, 255, 255, 255) end end)
-
onClientKey setPedControlState
-
I think it's because you're using setPedControlState to set the control state to walk. I got the same issue, then i turned that resource off and it works perfectly.
-
I think it is not possible in MTA, but wait for someone elses' answer.
-
You can change some object properties using ColEditor 2. Try it.
-
Replace the default objects with custom ones. This is the only method, you can't add more objects. https://wiki.multitheftauto.com/wiki/EngineLoadDFF Example 4.
-
MTA isn't have built-in elementdata save, you have to do it manually. I recommend mysql. dbConnect dbExec dbQuery onPlayerQuit And when the player joins you have to set those element datas with the result you get with query.
-
Set the vehicle variable to the vehicles tables' i index, which should be a number. It can be done easier. for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementPosition(vehicle, 0, 0, 10) -- position setElementRotation(vehicle, 90, 180, 0, "ZYX") -- orientation/rotation end
-
You won't get help with this attitude, trust me. Start learning...
-
What's your problem? @IIYAMA wants you to learn, not to beg everytime for scripts. You need to understand first how lua works and then you can go with the MTA:SA functions, events.
-
Server for k, v in ipairs(getElementsByType("vehicle")) do setVehicleDamageProof(v, true) end addEventHandler("onVehicleExit", getRootElement(), function() setVehicleDamageProof(source, true) end) addEventHandler("onVehicleEnter", getRootElement(), function() setVehicleDamageProof(source, false) end)
-
There's no marker element in your code.
-
My code doesn't even have line 22.
-
Yeah I see, fixed it. Thanks for the reply.
-
Client: addEventHandler("onClientGUIClick", guiCreateStaticImage(100, 100, 100, 100, "skin1.png", false), function() engineImportTXD(engineLoadTXD("skin1.txd"), 411) engineReplaceModel(engineLoadDFF("skin1.dff"), 411) end) bindKey("m", "down", function() showCursor(not isCursorShowing()) end) Meta: <meta> <script src="client.lua" type="client" /> <file src="skin1.png" /> <file src="skin1.dff" /> <file src="skin1.txd" /> </meta> Works perfectly, press 'M' to show/hide cursor.
-
local policeVehicles = { [597] = true, } local vehiclePositions = { {597, -1594.15295, 674.24622, 7.18750}, } for _, v in pairs(vehiclePositions) do createVehicle(v[1], v[2], v[3], v[4]) end addEventHandler("onVehicleStartEnter", getRootElement(), function(thePlayer) if getElementData(thePlayer, "faction") ~= "Police" and policeVehicles[getElementModel(source)] then outputChatBox("#ffff00You're not in Police Department faction.", thePlayer, 255, 255, 255, true) cancelEvent() end end)
-
Yes, I can do it, but i want you to learn from my script and do it yourself!
-
Client: local sx, sy = guiGetScreenSize() function renderText() dxDrawText(timeText, sx/2, sy/2, 0, 0, tocolor(255, 255, 255), 2, "default-bold") end function updateTime() if isTimer(timer) then timeText = formatTime(getTimerDetails(timer)) end end addCommandHandler("timer", function(cmd, min) if tonumber(min) then if not isTimer(timer) then local time = tonumber(min) * 60000 timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), renderText) end, time, 1) setTimer(updateTime, 1000, 0) timeText = formatTime(getTimerDetails(timer)) addEventHandler("onClientRender", getRootElement(), renderText) end else outputChatBox("SYNTAX: /timer [minutes]") end end) function formatTime(ms) local totalseconds = math.floor(ms / 1000) local ms = ms % 1000 local seconds = totalseconds % 60 local minutes = math.floor(totalseconds / 60) % 60 return string.format("%02d:%02d", minutes, seconds) end
-
You can do it yourself. Just draw another button and text like i did.
-
setTimer(function() outputChatBox("Time's up!") end, 600000, 1)
-
Client: local sx, sy = guiGetScreenSize() local rx, ry = sx/1920, sy/1080 local selectedPlayer = false function isCursorInPosition(rectX, rectY, rectW, rectH) if isCursorShowing() then local cursorX, cursorY = getCursorPosition() local cursorX, cursorY = cursorX * sx, cursorY * sy return (cursorX >= rectX and cursorX <= rectX+rectW) and (cursorY >= rectY and cursorY <= rectY+rectH) else return false end end setTimer(function() if isElement(selectedPlayer) then local x, y, z = getElementPosition(localPlayer) local px, py, pz = getElementPosition(selectedPlayer) local dist = getDistanceBetweenPoints3D(x, y, z, px, py, pz) if dist > 5 then selectedPlayer = false end end end, 500, 0) addEventHandler("onClientRender", getRootElement(), function() if isElement(selectedPlayer) then if isCursorInPosition(cX, cY, 200*rx, 30*ry) then dxDrawRectangle(cX, cY, 200*rx, 30*ry, tocolor(66, 134, 244, 220)) else dxDrawRectangle(cX, cY, 200*rx, 30*ry, tocolor(66, 134, 244, 150)) end dxDrawText("Revive", cX + (55*rx), cY, 0, 0, tocolor(255, 255, 255), 2*rx, "default-bold") end end) addEventHandler("onClientClick", getRootElement(), function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if (state == "up") then if (button == "right") then if (clickedElement) and (getElementType(clickedElement) == "player") and clickedElement ~= localPlayer then cX, cY = absoluteX, absoluteY selectedPlayer = clickedElement else selectedPlayer = false end elseif (button == "left") then if isElement(selectedPlayer) and isCursorInPosition(cX, cY, 200*rx, 30*ry) then triggerServerEvent("serverRevivePlayer", resourceRoot, selectedPlayer) selectedPlayer = false end end end end) Server: addEvent("serverRevivePlayer", true) addEventHandler("serverRevivePlayer", resourceRoot, function(targetPlayer) if isElement(targetPlayer) then local x, y, z = getElementPosition(targetPlayer) local rx, ry, rz = getElementRotation(targetPlayer) local skin = getElementModel(targetPlayer) spawnPlayer(targetPlayer, x, y, z, rz, skin) setCameraTarget(targetPlayer, targetPlayer) outputChatBox("You got revived by: "..getPlayerName(client), targetPlayer) outputChatBox("You revived: "..getPlayerName(targetPlayer), client) end end)