-
Posts
1,105 -
Joined
-
Last visited
Everything posted by Aibo
-
function getTimeLeft(timer) if isTimer(timer) then local ms = getTimerDetails(timer) local m = math.floor(ms/60000) local s = math.floor((ms-m*60000)/1000) if m < 10 then m = "0"..m end if s < 10 then s = "0"..s end return m..":"..s else return "--:--" end end also "sWidth-0" is useless, max alpha is 255 (tocolor(225,225,225,255)) and font name is "diploma", not "Diploma" (though it maybe not case-sensitive)
-
')' expected (to close'(' at line 945) near 'end' plain english tells you, that you have closing parenthesis missing, you need to add ')' somewhere there, not 'end'. where i dont know, because you didnt bother to post the code. the bottom line: you should learn Lua syntax (and overall basics of programming) before scripting anything. and before even copying anything in your case.
-
i know that, it's just i'm not confident enough
-
i don't think i'm quite "eligible" to edit the wiki
-
using the info posted by varez above i wrote a function for you: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..string.sub(col, 1, 2)), tonumber("0x"..string.sub(col, 3, 4)), tonumber("0x"..string.sub(col, 5, 6)), 255) end last = e+1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end -- example usage: testline = "testing: #ff0000red #00FF00green #0000ffblue blue #ff0000red again" addEventHandler("onClientRender", getRootElement(), function() dxDrawColorText(testline, 100, 100, 900, 900, tocolor(255,255,255,255),1.0,"bankgothic") end) example result: PS: maybe someone more experienced will optimize ('cause im not sure) this and/or add text alignment/line break support. PS: variant for RGBA color codes with alpha: function dxDrawColorAlphaText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..string.sub(col, 1, 2)), tonumber("0x"..string.sub(col, 3, 4)), tonumber("0x"..string.sub(col, 5, 6)), tonumber("0x"..string.sub(col, 7, 8))) end last = e+1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end
-
FFS, first you said you want sound PAUSED on HUNTER PICKUP, now you want it to stop on marker? wtf? sound1 = false -- sound will be in this "global" variable function startclient () outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) outputChatBox ( " " , 0 , 0 , 0 , true ) outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) outputChatBox ( " ",0,0,0,true) outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) setSkyGradient ( 50 , 255 , 0 , 65 , 100 , 0 ) setWaterColor ( 50 , 60 , 70 ) setTime ( 1 , 0 ) setWaveHeight ( 0.5 ) setBlurLevel ( 5 ) setWeather ( 99 ) Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) Marker3 = createMarker ( 4157.51855468, -2296.5871582031, 1111.4150390625, "corona", 9, 50, 50, 255, 100) addEventHandler("onClientMarkerHit", Marker1, warp) addEventHandler("onClientMarkerHit", Marker2, warp) addEventHandler("onClientMarkerHit", Marker3, warp) end function warp(player) if player == getLocalPlayer() and isPedInVehicle(player) then if source == Marker1 then -- First Marker markerHitSound() local vehicle=getPedOccupiedVehicle(player) setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) setElementRotation (vehicle , 0,0,310.5) setVehicleFrozen ( vehicle , true ) setTimer( setVehicleFrozen, 300, 1, vehicle, false ) setWeather ( 99 ) setTime ( 00 , 0 ) setBlurLevel ( 0 ) elseif source == Marker2 then -- Second Marker markerHitSound() sound1 = playSound("data/mario.mp3", true) -- creates a sound and place it in global variable sound1 local vehicle=getPedOccupiedVehicle(player) setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) setElementRotation (vehicle , 0, 0, 0 ) setVehicleFrozen ( vehicle , true ) setTimer( setVehicleFrozen, 700, 1, vehicle, false ) setTime ( 00, 0 ) setBlurLevel (20 ) setGameSpeed ( 1.3 ) setWeather ( 99 ) setTimer(lights, 850, 0) setTimer(loll, 850, 0) setTimer(randomVehColors, 850, 0) elseif source == Marker3 then --Third Marker markerHitSound() if sound1 then stopSound(sound1) end -- stops sound1 on Marker3 local vehicle=getPedOccupiedVehicle(player) setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) setElementRotation (vehicle , 0, 0, 0 ) setVehicleFrozen ( vehicle , true ) setTimer( setVehicleFrozen, 700, 1, vehicle, false ) end end end function randomVehColors() --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 color[2] = math.random(0,126) color[3] = math.random(0,126) color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle end end function loll() -- Mario World setSkyGradient(math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) end function lights() for i,v in pairs (getElementsByType ("vehicle")) do setVehicleHeadLightColor(v, math.random(0,255), math.random(0,255), math.random(0,255)) end end function markerHitSound() local sound2 = playSound("data/warp.mp3") -- Sound Is Working !!! end addEventHandler("onClientResourceStart", resourceRoot, startclient) addEvent("serverSetsSoundPaused", true) addEventHandler("serverSetsSoundPaused", getRootElement(), function(paused) setSoundPaused(sound1, paused) end)
-
don't you think that those kind of improvement suggestions should go to the resource author? that is because for someone other to do this means he needs to download the resource, understand how it works, go thru its code and all that. i doubt someone will waste time on it just because you've asked. so your best bet is to ask the creator or edit this yourself, imo.
-
you should first check if player is in a team, and if it is — get team name. local team = getPlayerTeam(playerSource) if team then team = getTeamName(team) else team = "" end
-
about line 20 i've told you already, 36 and 38 depend on what you have in «objectid» variable.
-
team = getTeamName(getPlayerTeam(playerSource)) getPlayerTeam() returns false if player is not in a team, so resulting getTeamName(false) can cause your warning destroyElement(Gate) destroyElement() can cause a warning if Gate is not an element ,use «if isElement(Gate) then destroyElement(Gate) end» object = createObject ( objectid, x + 3,y + 3,z) «objectid» can be undefined. there is a check whether it is specified, but it does nothing to prevent the rest of the code from running. if not objectid then outputChatBox("usage: /addgate objectid teamname", playerSource) return false end setElementInterior(object,interior) error here is a result of error at line 35 («object» wasnt created). PS: «null» in Lua is «nil»
-
i think it is possible with some extensive controls/sound scripting, but you'll need to turn off SFX leaving only "MTA sounds". though personally i dont see a point in this.
-
1. you dont need to place it inside a marker event. 2. i dont see where's your "sound1" is defined (it's probably a local of some function again, isnt it)
-
yeah, set up a timer which will do isPlayerInVehicle check for every player every 50ms and you're good to go. seriously, if it is for race mode then: server: addEventHandler("onPlayerPickUpRacePickup", getRootElement(), function(pID, pType, vID) if pType == "vehiclechange" and vID == 425 then triggerClientEvent(source, "serverSetsSoundPaused", getRootElement(), true) end end) client: addEvent("serverSetsSoundPaused", true) addEventHandler("serverSetsSoundPaused", getRootElement(), function(paused) setSoundPaused(someSoundThatYouHavePlaying, paused) end) if not for race, onPlayerVehicleEnter event can be used.
-
no it won't. and this WILL "Make the Script Loading Fail". seriously, you can't even fix your own scripts, can't use indentation. and now you're trying to fix something by deleting stuff without thinking.
-
https://wiki.multitheftauto.com/wiki/SetSoundPaused
-
«checkpoint (1)» is a function notation, indexed table syntax is «checkpoint[1]». but it still wont be true cause «checkpoint» is already a table, and you're trying to compare a table with it's value at index 1.
-
then it's probably the fault of that script, not this one.
-
you have thePlayer passed to spawnPlayer function instead of X and skinID instead of rotation, therefore skin id is not passed at all. spawnPlayer(source, x, y, z, 0, skinID)
-
Function:spawnAllPlayers with Exceptions - War OF Empire -
Aibo replied to laserlaser's topic in Scripting
you do realise that it is the same function with 2 loops that he exploits over and over and for any purpose (remove accounts, respawn cars, now players)? honestly, i wouldnt want to see this kind of code on the wiki. dude doesnt even know about booleans. -
you forgot to close the parentheses
-
so i have to install .NET so that your "program", using the usual compiler, could place compiled lua file into a folder? well, you could at least add a gui, not a console with a language that most people wont even understand.
-
why you always changing the names of the functions and everything, it is hard to understand as it is already. 1. j2window = guiCreateWindow(386,330,519,363,"JOB SYSTEM",false) later you have a function (?) with this name. wtf? 2. function work(source) "source" is a hidden variable passed from event, you dont need to (and better not to) assign anything to it. in this case source is GUI element (not player!), and first argument is button (not player!). use function work() and replace the rest "source"s in the function with getLocalPlayer() (clientside outputChatBox() does not even need it). 3. addEventHandler( "onMarkerHit", Job1, HitOnJob1) i didn't just placed this event handler after createMarker for no reason. now you have it again in the end of the script, while the marker is created in a function (which is NOT called before the handler = no marker element to attach to), so you need to attach the handler to a marker ELEMENT when it exists: addEventHandler("CreateJob1CP", getRootElement(), function() Job1 = createMarker( -1979.3596191406, 483.17581176758, 34.100391387939, 'cylinder',0.8, 0, 255, 0, 128) addEventHandler("onMarkerHit", Job1, HitOnJob1) end) PS: are you sure your /debugscript 3 is empty? are you even using it?
-
well you never posted the gui itself.
-
i doubt that i understand the idea (your explanation differs from your scripts somewhat, it also defies basic logic, like first 2 then 1, wtf?). and you're posting only parts of the code. like where is GoToJob() function triggered? anyway, here's what i come up with, fixing the stuff that you've posted: server: Job1 = false Job2 = createMarker(-1985.6575927734, 476.59652709961, 34.021896362305, 'cylinder', 1.5, 0, 255, 0, 128) function ShowJob2(hitElement, matchingDimension) if getElementType(hitElement) == "player" then triggerClientEvent(hitElement, "JobSend2", getRootElement()) end end addEventHandler( "onMarkerHit", Job2, ShowJob2) function ShowJob1(hitElement, matchingDimension) if getElementType(hitElement) == "player" then triggerClientEvent(hitElement, "JobSend1", getRootElement()) end end function InJob1() Job1 = createMarker(-1979.3596191406, 483.17581176758, 34.100391387939, 'cylinder', 0.8, 0, 255, 0, 128) addEventHandler("onMarkerHit", Job1, ShowJob1) end addEvent("OfJob1", true) addEventHandler("OfJob1", getRootElement(), InJob1) client: function GoToJob() if (getPlayerMoney(getLocalPlayer())<=500) then outputChatBox("You don't have a money!", 255, 0, 0) else guiSetVisible(JobsWindow,false) outputChatBox("You entered to job!") showCursor(false) triggerServerEvent("OfJob1", getLocalPlayer()) end end function ShowGui1() TurnOnWindows1() guiSetVisible(Window1, true) showCursor(true) end addEvent("JobSend1", true) addEventHandler("JobSend1", getRootElement(), ShowGui1) function ShowGui2() TurnOnWindows2() guiSetVisible(Window2, true) showCursor(true) end addEvent("JobSend2", true) addEventHandler("JobSend2", getRootElement(), ShowGui2)
