-
Posts
1,491 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Walid
-
I think he is talking about the colmun width.
-
Hello guys, I am creating this thread so that members of the community can share useful tips and tricks they have learned during their time of scripting. I don't know if it's already created before or not but i think it's something useful to help beginners to learn Lua language plus i think Tutorials board is the best place. to begin with, here a few tricks I have picked up: You can do this: local variable = "no" if Condition then variable = "yes" end But it's faster if you do it like this: local variable = (Condition and "yes") or "no" Reversing bools: bool = true -- if you want to reverse it you can either do bool = false -- or bool = not bool When assigning a variable you don't want to be nil you could do this: local variable = otherVariable if variable == nil then variable = 10 end But it can be done a lot faster: local variable = otherVariable or 10 Commenting multiple lines : -- line1 -- line2 -- line3 You can just use this: --[[line1 line2 lin3]] There are a lot more cool things you can do with lua, if you have something you wish to share feel free to post below.
-
Try this : -- server side function forObjPosition ( thePlayer, command ) if thePlayer and isElement(thePlayer) then local padx,pady,padz = getElementPosition(thePlayer) outputChatBox ("{" .. padx .. "," .. pady .. "," .. padz .. "}",thePlayer,0,255,0) end end addCommandHandler("mypos",forObjPosition) if you are trying to use this code client side just remove the argument thePlayer and replace it in your code with localPlayer.
-
rotate the camera around the ped i think it's much better try it: local facing = 0 function rotateCameraAroundPed( ) if spawnPed and isElement(spawnPed) then local x, y, z = getElementPosition(spawnPed) local camX = x + math.cos( facing / math.pi * 180 ) * 5 local camY = y + math.sin( facing / math.pi * 180 ) * 5 setCameraMatrix( camX, camY, z+1, x, y, z ) facing = facing + 0.00009 end end -- start rotateCameraAroundPed() function addEventHandler( "onClientRender", getResourceRootElement( ), rotateCameraAroundPed ) -- stop rotateCameraAroundPed() function removeEventHandler( "onClientRender", getResourceRootElement( ), rotateCameraAroundPed )
-
function HudMoney() local cash = getPlayerMoney(getLocalPlayer()) dxDrawText("$"..formatNumber(cash).."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) end function formatNumber(n) if (not n) then return "Error catching data" end local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end
-
All what you need is: engineLoadTXD() engineImportTXD() engineLoadDFF() engineReplaceModel() engineLoadCOL() engineReplaceCOL() engineSetModelLODDistance()
-
use tables try sth like this, put my code after checking the object model. local id = {3113,980, --[[add more ids here]]} for i, v in pairs (id) do -- your code here -- if ID ~= v then etc.. end
-
It's very simple , open notepad++ then click CTRL+F , type the text that you want to find it and press enter.
-
Try this : local screenW2,screenH2 = guiGetScreenSize() local resW2, resH2 = 1366,768 local x, y = (screenW2/resW2), (screenH2/resH2) local counter = 0 local starttick local currenttick local currFPS = 60 addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(localPlayer,"FPS",counter) currFPS = counter counter = 0 starttick = false end local time = getRealTime() local hours = time.hour local minutes = time.minute dxDrawText("Hours: "..hours..":"..minutes.."FPS: "..currFPS.." Ping: "..getPlayerPing( localPlayer ), x*1050, y*9, x*276, y*39, tocolor(255, 255, 255, 255), 1.1, "default-bold") end)
-
already gave you the solution. Edit: didn't see Karim's post.
-
Try this local facing = 0 local selectPed = createPed(287, 2892.9643554688, 1790.7238769531, 30.284019470215,90) function rotateCameraAroundPed( ) if selectPed then local x, y, z = getElementPosition(selectPed) local cameraX = x + math.cos( facing / math.pi * 180 ) * 5 local cameraY = y + math.sin( facing / math.pi * 180 ) * 5 setCameraMatrix(cameraX,cameraY, z, x, y, z ) facing = facing + 0.00009 end end addEventHandler( "onClientRender",root,rotateCameraAroundPed)
-
function sounFunction(cmd) if cmd == "playsound" then if isElement(sound) then stopSound( sound ) end sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, false) elseif cmd == "stopsound" then if isElement(sound) then stopSound( sound ) end end end addCommandHandler ("playsound", sounFunction) addCommandHandler ("stopsound", sounFunction)
-
if your code is server side , All what you need is : function bind(player) bindKey(player, "h","down",healer) end function onPlayerJoin () bind(source) end addEventHandler("onPlayerJoin",getRootElement(), onPlayerJoin) function bindKeyForAll() for index, player in pairs(getElementsByType("player")) do bind(player) end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),bindKeyForAll)
-
you want to bind a key for all players right.
-
you don't need to destroy it because the timesToExecute it's not 0 (infinite repetitions) , it will be destroyed after 5 seconds. Anyways you can use smth like this if you use a timer > then 10 seconds. local bmx = { [510]=true } local destroy = {} function bmxS(player, seat) local model = getElementModel (source) if eventName == "onVehicleExit" then if bmx[model] then destroy[source] = setTimer(respawnVehicle, 5000, 1, source) end elseif eventName == "onVehicleEnter" then if isTimer (destroy[source]) then killTimer(destroy[source]) end end end addEventHandler("onVehicleExit", root, bmxS) addEventHandler ("onVehicleEnter", root, bmxS) Edit: :fp: @swedishboy
-
local bmx = { [510]=true } function bmxS(player, seat) local model = getElementModel (source) if bmx[model] then setTimer(respawnVehicle, 5000, 1, source) end end addEventHandler("onVehicleExit", root, bmxS)