-
Posts
230 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ShayF2
-
I feel that you should research a bit about shading vs textures. Maybe that will help you more.
-
local sounds = { --Format: {sound/url,volume(0-100)}, {'The_Incredible_Coneman_Death.wav',100}, {'sound2.wav',100}, {'sound3.wav',100}, {'sound4.wav',100}, {'sound5.wav',100}-- always leave the last one without a comma } -- this is our function to get random sound, and avoid getting the same on as the previous.. local previous function getRandom(t) local r = math.random(1,#t) if r ~= previous then previous = random return random else getRandom(t) end end function wasted() local randomSound = getRandom(sounds)-- we use the function we just created and input the sounds table. -- it will return a table with 2 variables, 1st the sound url and 2nd the volume.. local sound = playSound(randomSound[1],false)-- so we use the first variable, the sound url to create the sound. setSoundVolume(sound,randomSound[2]/100)-- and the second variable to set the volume. -- divide the volume by 100 so that mta reads it as the regular decimal value end addEventHandler('onClientPlayerWasted',localPlayer,wasted) Try this instead..
-
local sounds = { --Format: {sound/url,volume(0-100)}, {'The_Incredible_Coneman_Death.wav',100}, {'sound2.wav',100}, {'sound3.wav',100}, {'sound4.wav',100}, {'sound5.wav',100}-- always leave the last one without a comma } -- this is our function to get random sound, and avoid getting the same on as the previous.. local previous function getRandom(t) local random = math.random(1,#t) if not random == previous then previous = random return random else getRandom(t) end end function wasted() local randomSound = getRandom(sounds)-- we use the function we just created and input the sounds table. -- it will return a table with 2 variables, 1st the sound url and 2nd the volume.. local sound = playSound(randomSound[1],false)-- so we use the first variable, the sound url to create the sound. setSoundVolume(sound,randomSound[2]/100)-- and the second variable to set the volume. -- divide the volume by 100 so that mta reads it as the regular decimal value end addEventHandler('onClientPlayerWasted',localPlayer,wasted) I hope this helped you. Later I will explain how to do specific sounds for specific skins. I'm a bit busy at the moment.
-
Whatever shader you want to use. You could even make your own to fit what you need. Like I said all you're seeing here is less light..
-
local sx,sy = guiGetScreenSize() local px,py = 800,600 local x,y = (sx/px),(sy/py) win = false function createBrowser() if (window) then if (guiGetVisible(window)) then showCursor(false) toggleAllControls(true) guiSetVisible(window,false) else guiSetInputEnabled(false) showCursor(true) toggleAllControls(false) guiSetVisible(window,true) end else toggleAllControls(false) window = guiCreateWindow(x+50,y+50,sx-100,sy-100,'Please wait while your page loads',false) edit_site = guiCreateEdit(0,y+25,sx,25,'',false,window) webBrowser = guiCreateBrowser(0,55,sx,sy-100,false,false,false,window) theBrowser = guiGetBrowser(webBrowser) bindKey('enter','down',nextPage) addEventHandler('onClientBrowserCreated',theBrowser,loadBrowser) end end bindKey('F3','down',createBrowser) function SetURL(url) guiSetText(window,url) end function loadBrowser() loadBrowserURL(source,'http://www.youtube.com') showCursor(true) win = true addEventHandler('onClientBrowserDocumentReady',root,SetURL) end function nextPage() if (guiGetVisible(window)) then --[[local webBrowser = guiCreateBrowser(0,55,sx,sy-100,false,false,false,window) addEventHandler('onClientBrowserCreated',webBrowser,function()]] site = guiGetText(edit_site) loadBrowserURL(source,site) --end) end end
-
I'll make some code and test it before posting, give me a few hours.
-
Post your current code, I will try to help you to the best of my ability.
-
It's not changing color. It's changing shading and or lighting, that's simply how the game works. I'm sure you could rig up some shaders to disable it from shading. This is much like what you see with vehicles and objects. All you're really seeing here is less light.
-
Debugging the cpu and ram usage of my server while it contains many mods and many scripts, certainly not as big as CodyL's server, however it is probably the size of a normal MTA Freeroam server. The ram usage always stays below 1GB, and cpu usage always stays under 10%. I have 4GB's of ram and dual core 3.7GHz cpu dedicated to the server. I have plenty left over to run whatever else I need on the vps, such as a website, database, mail server, what have you. Possibly even another MTA server.
-
local onDuty = {} addCommandHandler('duty',function(player,cmd) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup('user.'..accName,aclGetGroup('Admin')) then if not onDuty[player] or onDuty[player] == false then onDuty[player] = true outputChatBox(getPlayerName(player)..' is now on duty!',root) local timer1 = setTimer(function() setElementData(player,'brokenbone',false) setElementData(player,'bleeding',false) setElementData(player,'pain',false) setElementData(player,'cold',false) setElementData(player,'temperature',36.5) setElementData(player,'blood',12000) setElementData(player,'food',100) setElementData(player,'thirst',75) end,50,0) else onDuty[player] = false outputChatBox(getPlayerName(player)..' is now off duty!',root) if isTimer(timer1) then killTimer(timer1) end end end end)
-
try using this Wiki Code: createBrowser My code:
-
self is just a table that stores all the data for the browser. self.url is a variable within that table called 'url' so if u were to make a browser like so local newbrowser = dxDrawWebBrowser(0,0,sx,sy,'http://www.google.com/') To change it's url you simply change the value of the variable within its own data table. This makes things a lot easier to work with Here's how you change the url.. newbrowser.url = 'http://www.youtube.com/' I gave you the code to work with, all you need to do is set values like shown above, and use the dxDrawWebBrowser to create the browser. Things should be much simpler for you, I hoped this helped. This is advanced code, type of format and style that professionals will use. You will not find any better, any smoother, or any simpler code. Even though the main functions are complicated and hard to understand, it makes getting what you want done a whole lot simpler.
-
songs = { 'sounds/1.mp3', 'sounds/2.mp3', 'sounds/3.mp3', 'sounds/4.mp3', 'sounds/5.mp3', 'sounds/6.mp3', 'sounds/7.mp3', 'sounds/8.mp3' } local previous function randomIndex() local number = math.random(1,#songs) if not previous == number then previous = number return number end end function nextSong() if isSoundFinished(sound) then playSong() else setTimer(nextSong,2000,1) end end local sound function playSong() local i = randomIndex() sound = playSound(songs[i],true) if isElement(sound) then setSoundVolume(sound,0.8) local length = getSoundLength(sound) if length > 1 then length = length+2000 end setTimer(nextSong,length,1) end end addEventHandler('onClientResourceStart',resourceRoot,playSong) function stopLoginSound() if isElement(sound) then destroyElement(sound) end end addEvent('stoploginsound',true) addEventHandler('stoploginsound',root,stopLoginSound) This is simply proper code formatting, I've got no idea if it works. If it does then it does. It's suppose to lol. Good luck. Just remember getSoundLength returns in milliseconds and a timer also uses milliseconds... 1000 milliseconds = 1 second.
-
local ATM_Locations = { {1505.16626, -1750.68909, 13.54688},--1 {1690.0927734375, -2334.8369140625, 13.546875},--2 {1951.19543, -2175.53784, 13.55421},--3 {2041.50390625, -1430.728515625, 17.1640625},--4 {1878.06372, 2073.94067, 11.06250},--5 {2280.76465, 2431.10596, 10.82031},--6 {2020.86316, 1016.50653, 10.82031},--7 {-1210.31104, 1834.64917, 41.92969},--8 {174.82074, 1175.05469, 14.75781},--9 {1380.58093, 260.50055, 19.56693},--10 {1238.48145, 327.90039, 19.75551},--11 {1626.68469, 1815.06384, 10.82031}--12 } blips = {} local Blips = {} function blips() for i=1,#ATM_Locations do local x,y,z = ATM_Locations[i][1],ATM_Locations[i][2],ATM_Locations[i][3] Blips[i] = createBlip (x,y,z,3,2) blips[player] = true setTimer(function() if blips[player] then if blips[player] == true then for i,v in pairs(Blips) do destroyElement(v) end blips[player] = false end end end,10000,1) end end addCommandHandler('ATM',blips,false)
-
Either create an event, or run this through in your group creation function https://wiki.multitheftauto.com/wiki/CreateTeam https://wiki.multitheftauto.com/wiki/SetPlayerTeam Good luck.
-
Mate, you gotta provide screenshots, snippets of code, something we can work with to help you lol.
-
-- This is an example off of the wiki. I know browsers are a bit complicated. -- https://wiki.multitheftauto.com/wiki/CreateBrowser --In order to render the browser on the full screen, we need to know the dimensions. local sx,sy = guiGetScreenSize() --Let's create a new browser in local mode. We will not be able to load an external URL. local webBrowser = createBrowser(sx,sy,true,false) --This is the function to render the browser. function webBrowserRender() --Render the browser on the full size of the screen. dxDrawImage(0,0,sx,sy,webBrowser,0,0,0,tocolor(255,255,255,255),true) end --The event onClientBrowserCreated will be triggered, after the browser has been initialized. --After this event has been triggered, we will be able to load our URL and start drawing. addEventHandler('onClientBrowserCreated',webBrowser,function() --After the browser has been initialized, we can load our file. loadBrowserURL(webBrowser,'http://mta/local/html/site.html') --Now we can start to render the browser. addEventHandler('onClientRender',root,webBrowserRender) end) And here is a more advanced version (that I created on a dime) -- Create a table of browsers browsers = {} -- Then create a function to create the browser function dxDrawWebBrowser(x,y,w,h,url) -- creating a table for its data local self = {} self.x = x self.y = y self.w = w self.h = h self.url = url -- using a toggle for visibility self.visible = true -- creating the browser self.browser = createBrowser(self.x,self.y) -- creating a draw function for dx self.draw = function() dxDrawImage(self.x,self.y,self.x+self.w,self.y+self.h,self.browser,0,0,0,tocolor(255,255,255,255),true) end -- inserting it all to a table so we can grab data table.insert(browsers,self) end -- single global event so that we don't keep creating events addEventHandler('onClientBrowserCreated',resourceRoot,function() for i,v in pairs(browsers) do if source == v.browser then -- loading its url after grabbing its data loadBrowserURL(source,v.url) end end end) -- and this is just to put it on the screen.. addEventHandler('onClientRender',resourceRoot,function() for i,v in pairs(browsers) do if v.visible == true then v.draw() end end end) -- so after all that code we can finally create a browser.. local sx,sy = guiGetScreenSize() -- using 0.5 to take literally half the screen.. local newbrowser = dxDrawWebBrowser(sx*0.5,sy*0.5,sx*0.5,sy*0.5,'http://www.google.com/') -- there you go. -- and to change its visibility now just simply do this newbrowser.visible = false -- I hope this helped you.
-
I have a script that runs a dx ui when a player enters a marker. I want to know how to disable every control other than the ones I allow. I can do most of which with toggleControl functions but what about mta keys? such as chat box keys and and hot keys ?
-
I've been scripting for nearly 4 years but only in server side. I just recently got into client side and had a few professional scripters teach me what it's all about. I'll be showcasing my current works as of now with my own uncompleted dx library.
-
the default mta resource known as admin has a function to get the players country from their ip address, I suggest you look into that.
-
I may be able to help with this. -- You may use either one of these, or both if u choose. I suggest though to use only one, preferably acl. -- Using Tables to define who should get godmode. local godmodeTeams = {'Staff Team','Godmode Team'} -- Using tables gives you the benefit of adding infinite teams. function setTeamGodmode() for i,v in pairs(godmodeTeams) do for l,p in pairs(getElementsByType('player')) do local team = getPlayerTeam(p) if team then local teamName = getTeamName(team) if getTeamFromName(v) then if v == teamName then setElementData(p,'invincible',true) else setElementData(p,'invincible',false) end end end end end end -- Doing the same thing only with ACL instead of teams.. local godmodeACL = {'Admin','Super Moderator'} -- this function is for ACL function setACLGodmode() for o,u in pairs(godmodeTeams) do for k,e in pairs(getElementsByType('player')) do local acc = getPlayerAccount(e) if acc then local accName = getAccountName(acc) if aclGetGroup(u) then if isObjectInACLGroup('user.'..accName,aclGetGroup(u)) then setElementData(e,'invincible',true) else setElementData(e,'invicible',false) end end end end end end -- to trigger these is simple, either put the function in a function as setACLGodmode() or in a timer as setACLGodmode, etc. setTimer(setACLGodmode,1000,0) -- these timers are not needed, unless u want them, they will check every second to see if all the players get godmode. setTimer(setTeamGodmode,1000,0)
-
I hope this code helps, the first example is using it to destroy all cars that are empty and the second example is destroying all cars that are empty with only specific data, in case you don't want certain vehicles destroyed. You may find unnecessary things within this code, such as so many if statements, but I like to run these 'checks' to get rid of any possible errors or warnings within the script, it makes everything run smoothly.
-
instead of this - local marker = createMarker ( ax, ay, 0, "checkpoint", aradius, r or 255, g or 255, b or 255, 0 ) setElementAlpha(marker, 0) try this - local marker = createMarker ( ax, ay, 0, "checkpoint", aradius, tocolor( r or 255, g or 255, b or 255, a or 0 ) )
-
I've not worked on this in a long while, I may start on it again, possibly even rescript it to be a lot better. I plan for the following. Easy Navigation Both Online and Offline Search Support Syntax Highlighting in the Text Editor (multiple languages) Better, nicer, cleaner, more techy appearance.