-
Posts
1,255 -
Joined
-
Last visited
Everything posted by .:HyPeX:.
-
Use some timers imo.. it isnt so hard.
-
Well guys, you're still missing a point on texts, its scale: This will not be exact, and it will be small in smaller resolutions, but it will fit. local x,y = guiGetScreenSize() ScaleFix = (1680 / x ) * (1050 / y ) dxDrawText("TexT", PosX, PosY, EndX, EndY, color, Scale / ScaleFix) This will make it fit in all the resolutions, just remember to edit the original values to the screen where you did the text. (This is in your case). In the end: local x,y = 1360,768 ScaleFix = (1680 / x ) * (1050 / y ) dxDrawText("TexT", PosX, PosY, EndX, EndY, color, 2 / ScaleFix) --ScaleFix = 1.68 --RealScale in actual resolution = 2 / 1.68 = 1.19
-
WELCOME Hey guys, HyPeX here, with a tutorial to help new scripters. First of all, this tutorial assumes you have read and understood the introduction to scripting: https://wiki.multitheftauto.com/wiki/Sc ... troduction So, with any furthermore lets go in: Note: My first point in this tutorial is to give tips and data to users and scripters wich are not implicit on the wiki, but they're in lua tutorials, and some other info that there isnt anywhere. [*]Our start point will be functions. Normally, you understand functions very well, but not how they work nor many aspects of them. I will keep editing and adding more things to this topic. Next to come is tables. PD: if someone wants to add this to the wiki, do so, i get quite some headaches editing the wiki. EDIT: After some inactivity, i wont continue this tutorial, sorry. Please head up to Made's topic here to continue your learning!
-
if you want a better explanation of what novo did, its "indexing tables", basically, any indexed table is that one that doesnt has any "name" definition or variable, its just like a table: table = {name = "jose", jose = "etc"} Thats an unindexed table becouse it has variables, and you cant get numbers straight, therefore ipairs wont work. In this case you call: table.name to get "jose". table = {"jose", "etc"} Thats an indexed table, becouse it has not variables, just values. therefore ipairs will work. In this case as you dont have variables,but you do have a key to call them: Their position. table[1] will return "jose", as you are calling position one in the table. -- Not so easy: table = { {"Jose", "Juan", "etc"}, {"Juane", "etc", "Jase"} } Now, we have a complex table (just to say its harder we call it complex). (About ordering, just remember the 2nd table inside table "table" is the last value of table "table", so it actually ends like: {"juane", "etc", "Jase"}} ) Here, it is still an indexed table, and we can still call the values by key, but how? For an unindexed table you would probably do: table.table1.name Here, keys still work: table[1][1] will return Position 1 from a "supposed" table to be in position 1 of table "table", else if positon 1 from table is not a table it will return an error trying to index '?'. (nil value) Also, we can manage to loop them! table = { {"Jose", "Juan", "etc"}, {"Juane", "etc", "Jase"} } for i=1, #table[1] do outputChatBox(table[1][i]) end This will give: "Jose", "Juan", "etc" Now what about a complex indexed/unindexed table? table = { {"Jose", "Juan", "etc"}, {name = "Juane", etc = "etc", name2 = "Jase"} } for i=1, #table[1] do outputChatBox(table[1][i]) end for i,v in pairs(table[2]) do outputChatBox(i.." "..v) end This will output first the values before: "Jose", "Juan", "etc" But we now made the second table unindexed, the first one is still indexed, so it works, but the second one it is not, so ipairs will no longer work. In this case, pairs will return the following values in a random position: name Juan etc etc name2 Jase So we can basically have huge combinations and huge tables, wich in the end, its amazing. Hope this is usefull for you. Greets HyPeX
-
Well, it also has a fail. local x, y = guiGetScreenSize() notificationX = x*0.03 -- Pretty same effect as 10px (50px here if 1680). (10px is shit at 1680, almost unnoticable.) notificationY = y/notificationHeight Anyways, 10px at 1680 would be x*0.006, but at a lower one like 800 it would be: 4.8 (not much)
-
Why a whitelist? just ask the server and client if they want to recive a file, then it can be managed by the scripters who make these work itself.
-
Then there's something wrong with your code, it should work.. tell me exactly what this says: n = 0 local radios = { {"None","None",6}, {"http://mp3uplink.duplexfx.com:8054/listen.pls","West Coast Rap",5}, {"http://somafm.com/dubstep.pls","Dubstep",4}, {"http://www.181.fm/winamp.pls?station=181-power&style=mp3&description=Power%20181%20(Top%2040)&file=181-power.pls","Power 181",3}, {"http://193.34.51.25/listen.pls","rauteMusik.",2}, {"http://212.45.104.34:8042/listen.pls","defjay",1} } title = "Radio Off" addEventHandler("onClientSoundChangedMeta", root, function(streamTitle) title = streamTitle end) addEventHandler("onClientSoundStream",root,function(suc,length,streamN) title = streamN end) function onPlayerEnterVehicle(thePlayer,seat) if seat == 0 then setRadioChannel(0) addEventHandler("onClientRender", getRootElement(), RenderClient) bindKey("mouse_wheel_up", "down", PlaySound, "up") bindKey("mouse_wheel_down", "down", PlaySound, "down") end end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), onPlayerEnterVehicle) function stopMySound(player,seat) if ( player == localPlayer ) then stopSound( sound ) removeEventHandler("onClientRender", getRootElement(), RenderClient) unbindKey("mouse_wheel_up", "down", PlaySound) unbindKey("mouse_wheel_down", "down", PlaySound) n = 0 end end addEventHandler("onClientPlayerVehicleExit",getRootElement(),stopMySound) function RenderClient() if isPedInVehicle(localPlayer) then local x,y = guiGetScreenSize() dxDrawText("Song Name: "..title, x*0.299, y*0.778, x*0.599, y*0.800, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Radio: "..tostring(radiotitle), x*0.299, y*0.757, x*0.599, y*0.778, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end end function PlaySound(state) local x,y,z = getElementPosition(getLocalPlayer()) n = tonumber(n) if sound then stopSound(sound) end if state == "up" then n = n + 1 if n == 6 then n = 1 end elseif state == "down" then n = n - 1 if n == 0 then n = 1 end end outputChatBox(type(n)) outputChatBox(n) outputChatBox(radios[1][1]) outputChatBox(radios[n][1]) sound = playSound3D(radios[n][1], x,y,z) outputChatBox("Stream: "..radios[n][1]) outputChatBox("Title: "..radios[a][2]) radiotitle = radios[n][2] end function UpdateSound() if sound then local x,y,z = getElementPosition(getLocalPlayer()) setElementPosition(sound, x,y,z) end end addEventHandler("onClientRender", getRootElement(), UpdateSound)
-
what does this output? n = 0 local radios = { {"None","None",6}, {"http://mp3uplink.duplexfx.com:8054/listen.pls","West Coast Rap",5}, {"http://somafm.com/dubstep.pls","Dubstep",4}, {"http://www.181.fm/winamp.pls?station=181-power&style=mp3&description=Power%20181%20(Top%2040)&file=181-power.pls","Power 181",3}, {"http://193.34.51.25/listen.pls","rauteMusik.",2}, {"http://212.45.104.34:8042/listen.pls","defjay",1} } title = "Radio Off" addEventHandler("onClientSoundChangedMeta", root, function(streamTitle) title = streamTitle end) addEventHandler("onClientSoundStream",root,function(suc,length,streamN) title = streamN end) function onPlayerEnterVehicle(thePlayer,seat) if seat == 0 then setRadioChannel(0) addEventHandler("onClientRender", getRootElement(), RenderClient) bindKey("mouse_wheel_up", "down", PlaySound, "up") bindKey("mouse_wheel_down", "down", PlaySound, "down") end end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), onPlayerEnterVehicle) function stopMySound(player,seat) if ( player == localPlayer ) then stopSound( sound ) removeEventHandler("onClientRender", getRootElement(), RenderClient) unbindKey("mouse_wheel_up", "down", PlaySound) unbindKey("mouse_wheel_down", "down", PlaySound) n = 0 end end addEventHandler("onClientPlayerVehicleExit",getRootElement(),stopMySound) function RenderClient() if isPedInVehicle(localPlayer) then local x,y = guiGetScreenSize() dxDrawText("Song Name: "..title, x*0.299, y*0.778, x*0.599, y*0.800, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Radio: "..tostring(radiotitle), x*0.299, y*0.757, x*0.599, y*0.778, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end end function PlaySound(state) local x,y,z = getElementPosition(getLocalPlayer()) n = tonumber(n) if sound then stopSound(sound) end if state == "up" then n = n + 1 if n == 6 then n = 1 end elseif state == "down" then n = n - 1 if n == 0 then n = 1 end end outputChatBox(type(n)) local a = tonumber(n) sound = playSound3D(radios[a][1], x,y,z) outputChatBox("Stream: "..radios[a][1]) outputChatBox("Title: "..radios[a][2]) radiotitle = radios[a][2] end function UpdateSound() if sound then local x,y,z = getElementPosition(getLocalPlayer()) setElementPosition(sound, x,y,z) end end addEventHandler("onClientRender", getRootElement(), UpdateSound)
-
But wont that make it go twice? since they will be both triggered.
-
This is basically to see your actual you while being in a garage customizing yourself (somewhere else)
-
Wont onClientKey run as the same time as onClientCharacter on some of them? @1st example
-
Hey guys, how can i have 2 screen sources, like a camera ? lets say this: Simulate a player camera somewhere, and draw it on a shader in a wall. is this possible?
-
Hey i'm unsure, in the code you pasted up there in the start post, how you defined RenderTarget?
-
No. Thats basically an error saying the number wasnt recognized, as lines before having a number were passed correctly. Try this: n = 0 local radios = { {"None","None",6}, {"http://mp3uplink.duplexfx.com:8054/listen.pls","West Coast Rap",5}, {"http://somafm.com/dubstep.pls","Dubstep",4}, {"http://www.181.fm/winamp.pls?station=181-power&style=mp3&description=Power%20181%20(Top%2040)&file=181-power.pls","Power 181",3}, {"http://193.34.51.25/listen.pls","rauteMusik.",2}, {"http://212.45.104.34:8042/listen.pls","defjay",1} } title = "Radio Off" addEventHandler("onClientSoundChangedMeta", root, function(streamTitle) title = streamTitle end) addEventHandler("onClientSoundStream",root,function(suc,length,streamN) title = streamN end) function onPlayerEnterVehicle(thePlayer,seat) if seat == 0 then setRadioChannel(0) addEventHandler("onClientRender", getRootElement(), RenderClient) bindKey("mouse_wheel_up", "down", PlaySound, "up") bindKey("mouse_wheel_down", "down", PlaySound, "down") end end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), onPlayerEnterVehicle) function stopMySound(player,seat) if ( player == localPlayer ) then stopSound( sound ) removeEventHandler("onClientRender", getRootElement(), RenderClient) unbindKey("mouse_wheel_up", "down", PlaySound) unbindKey("mouse_wheel_down", "down", PlaySound) n = 0 end end addEventHandler("onClientPlayerVehicleExit",getRootElement(),stopMySound) function RenderClient() if isPedInVehicle(localPlayer) then local x,y = guiGetScreenSize() dxDrawText("Song Name: "..title, x*0.299, y*0.778, x*0.599, y*0.800, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Radio: "..tostring(radiotitle), x*0.299, y*0.757, x*0.599, y*0.778, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end end function PlaySound(state) local x,y,z = getElementPosition(getLocalPlayer()) n = tonumber(n) if sound then stopSound(sound) end if state == "up" then n = n + 1 if n == 6 then n = 1 end elseif state == "down" then n = n - 1 if n == 0 then n = 1 end end outputChatBox(n) local a = tonumber(n) sound = playSound3D(radios[a][1], x,y,z) outputChatBox("Stream: "..radios[a][1]) outputChatBox("Title: "..radios[a][2]) radiotitle = radios[a][2] end function UpdateSound() if sound then local x,y,z = getElementPosition(getLocalPlayer()) setElementPosition(sound, x,y,z) end end addEventHandler("onClientRender", getRootElement(), UpdateSound)
-
There should be a number before them.
-
Yet, what did outputChatBox say, thats what i asked for.
-
Why you have a number at the end of each table? just tell me what it says, n should be a number and the rest work, else you're doing something wrong. (try removing the number at the end of each table, its pointless since the only ways you're using it is by directly reaching it, you know whats the value, or by table, where you also know the value.)
-
Then there's two possibilities, either your table is not indexed, or n is bad. function onPlayerEnterVehicle(thePlayer,seat) if seat == 0 then setRadioChannel(0) addEventHandler("onClientRender", getRootElement(), RenderClient) bindKey("mouse_wheel_up", "down", PlaySound, "up") bindKey("mouse_wheel_down", "down", PlaySound, "down") end end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), onPlayerEnterVehicle) function stopMySound(player,seat) if ( player == localPlayer ) then stopSound( sound ) removeEventHandler("onClientRender", getRootElement(), RenderClient) unbindKey("mouse_wheel_up", "down", PlaySound) unbindKey("mouse_wheel_down", "down", PlaySound) n = 0 end end addEventHandler("onClientPlayerVehicleExit",getRootElement(),stopMySound) function RenderClient() if isPedInVehicle(localPlayer) then dxDrawText("Song Name: "..title, x*0.299, y*0.778, x*0.599, y*0.800, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Radio: "..tostring(radiotitle), x*0.299, y*0.757, x*0.599, y*0.778, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end end function PlaySound(state) local x,y,z = getElementPosition(getLocalPlayer()) n = tonumber(n) if sound then stopSound(sound) end if state == "up" then n = n + 1 if n == 6 then n = 1 end elseif state == "down" then n = n - 1 if n == 0 then n = 1 end end local n = tonumber(n) outputChatBox(n) sound = playSound3D(radios[1][1], x,y,z) outputChatBox("Stream: "..radios[1][1]) outputChatBox("Title: "..radios[1][2]) radiotitle = radios[n][2] end function UpadteSound() if sound then local x,y,z = getElementPosition(getLocalPlayer()) setElementPosition(sound, x,y,z) end end addEventHandler("onClientRender", getRootElement(), UpdateSound) Try that
-
Deberias postear esto en la seccion español, en español, este foro es el general y únicamente en inglés. -- You should post this in spanish section, in spanish, this forum is general and only in english.
-
could you try this? tell me what outputchatbox says function onPlayerEnterVehicle(thePlayer,seat) if seat == 0 then setRadioChannel(0) addEventHandler("onClientRender", getRootElement(), RenderClient) bindKey("mouse_wheel_up", "down", PlaySound, "up") bindKey("mouse_wheel_down", "down", PlaySound, "down") end end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), onPlayerEnterVehicle) function stopMySound(player,seat) if ( player == localPlayer ) then stopSound( sound ) removeEventHandler("onClientRender", getRootElement(), RenderClient) unbindKey("mouse_wheel_up", "down", PlaySound) unbindKey("mouse_wheel_down", "down", PlaySound) n = 0 end end addEventHandler("onClientPlayerVehicleExit",getRootElement(),stopMySound) function RenderClient() if isPedInVehicle(localPlayer) then dxDrawText("Song Name: "..title, x*0.299, y*0.778, x*0.599, y*0.800, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Radio: "..tostring(radiotitle), x*0.299, y*0.757, x*0.599, y*0.778, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end end function PlaySound(state) local x,y,z = getElementPosition(getLocalPlayer()) n = tonumber(n) if sound then stopSound(sound) end if state == "up" then n = n + 1 if n == 6 then n = 1 end elseif state == "down" then n = n - 1 if n == 0 then n = 1 end end local n = tonumber(n) sound = playSound3D(radios[n][1], x,y,z) outputChatBox("Stream: "..radios[n][1]) outputChatBox("Title: "..radios[n][2]) radiotitle = radios[n][2] end function UpadteSound() if sound then local x,y,z = getElementPosition(getLocalPlayer()) setElementPosition(sound, x,y,z) end end addEventHandler("onClientRender", getRootElement(), UpdateSound)
-
nevermind, i did this when i was at a veery low point compared to now. (I could have done this shit in a sole table )
-
I did my own ones with my BF3 gamemode, i did some crazy messed up shit, as i used up 4 tables, for killer, weapon and killed and last the colour, it was pretty much crazy(But still works) colour = tocolor(0, 119, 255,255) DrawTable = {} DrawTable2 = {} DrawTable3 = {} DrawTable4 = {} local x,y = guiGetScreenSize() function KillScore2(killer, weapon, bodypart) if killer ~= false and killer ~= true then else return end if getPlayerTeam(killer) ~= getPlayerTeam(getLocalPlayer()) then colour = tocolor(248, 101, 21,255) elseif killer == getLocalPlayer() then colour = tocolor(0, 119, 255,255) elseif getPlayerTeam(killer) == getPlayerTeam(getLocalPlayer()) then colour = tocolor(0, 119, 255,255) end local colour = colour local name = getPlayerNametagText(source) local killer = getPlayerNametagText(killer) table.insert(DrawTable, 1, name) table.insert(DrawTable2, 1, weapon) table.insert(DrawTable3, 1, killer) table.insert(DrawTable4, 1, colour) if #DrawTable >= 5 then table.remove(DrawTable) table.remove(DrawTable2) table.remove(DrawTable3) table.remove(DrawTable4) end end addEventHandler("onClientPlayerWasted", getRootElement(), KillScore2) local timer = setTimer(function() table.remove(DrawTable) table.remove(DrawTable2) table.remove(DrawTable3) table.remove(DrawTable4) end, 15000, 0) function RenderingKills2() local USA = getTeamFromName("#ff0000U#ffffffS#0000ffA #ffffff - #0046C8Marines") local RUSSIA = getTeamFromName("#ffffffRU#0000ffSS#ff0000IA #ffffff- #0046C8Sovietz") if not getPlayerTeam(getLocalPlayer()) == USA or not getPlayerTeam(getLocalPlayer()) == RUSSIA then return end local x,y = guiGetScreenSize() local count = 0 for i, v in ipairs(DrawTable) do if i == 2 then y = y/1.2 elseif i == 3 then y = y/1.3 elseif i == 4 then y = y/1.45 elseif i == 1 then y = y else y = y/1.2 end local Weapon = DrawTable2 [ i ] local Killer = DrawTable3 [ i ] local colour = DrawTable4 [ i ] local v = string.gsub(v, "#%x%x%x%x%x%x", "") local Weapon = string.gsub(Weapon, "#%x%x%x%x%x%x", "") if Killer then else return end local Killer = string.gsub(Killer, "#%x%x%x%x%x%x", "") local Weapon = getWeaponNameFromID(Weapon) dxDrawText(tostring(Killer).." ["..Weapon.."] "..v, x/1.5, y/5.5, x/4, y/1, colour, 0.5 / ( ( 1360 / x ) * ( 768 / y ) ), PodiumFont, center, center, false,false,true,true) end end addEventHandler("onClientRender", getRootElement(), RenderingKills2)
