Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Dzsozi (h03)

  1. I know that I should remove the event handler with removeEventHandler function, I even wrote it above, the thing I don't know is how. Same with the positions. What do you mean by make them start on a random location of the left side? When they are fading in it is okay to start at pos 0 and change their X sizes randomly, and when fading away it is okay to keep the X size of the screen and change their X positions randomly, that's just what I did, since it is the simplest way to do this, and I don't think there is any probem with the base. I just don't know how to change their size without wiggling around, please just read the lines I wrote above.
  2. Hello! I started doing a custom camera fading script, which I would like to make look like this: https://youtu.be/Ejon93PmXAg?t=1m7s (the blue rectangles sliding in the background) I would like to make a new custom function for that, where I can give the following arguments: the color of the rectangles and the size of the rectangles. I have a few little problems. First of all, how can I make the length random, so one of the rectangles is longer than the other, one is shorter, etc. Right now it is wiggling, because it always generates a random number because it is inside the onClientRender event I guess, or maybe because of the loop, or both, I'm not sure. The other thing I don't know how to make is the disappearing. So for example I have the function called fadeCameraDX and it has the following arguments: state: the state whether the camera should fade in or away r,g,b: the RGB color of all the rectangles, if it is not given then the colors will be random size: the size of the rectangles I would like to prevent a "bug" when the camera is already faded in I can't start the fade in animation again, so I made a variable for that, called currentState, I am using outputchatbox to see if it is working correctly and it seems like it is fine, but for some reason the rectangles doesn't start to go away when I use the fadeCameraDX(false) function, and it should start if the currentState variable is true, and it is true, but it doesn't work. And one more thing I'm not SURE about, is if I made the rectangles correctly. I mean it is not 100% correct, because if I set the size of the rectangles to 10, the rectangles doesn't cover even the half of the screen. How can I make sure that there is always just enough rectangles to cover the screen? Not more, to avoid unnecessary drawings and fps drops and not less to cover up the whole screen. Is there any way to count it? You will see what I mean if you look at the script, here it is: local screenX, screenY = guiGetScreenSize() local dxFades = nil local timeToFade = 2000 local currentState = false function fadeCameraDX(state,r,g,b,size) if dxFades then return end dxFades = {} dxFades.timeStart = getTickCount() dxFades.timeStop = dxFades.timeStart + timeToFade dxFades.state = state if not tonumber(size) then size = 50 end dxFades.size = size if not tonumber(r) then r = math.random(100,255) end if not tonumber(g) then g = math.random(100,255) end if not tonumber(b) then b = math.random(100,255) end dxFades.color = {r,g,b} addEventHandler("onClientRender", root, renderDXCameraFading) end function renderDXCameraFading() local r,g,b = unpack(dxFades.color) local rectangleWidth = screenX local rectanglePosX = 0 local borderSize = dxFades.size/10 if dxFades.state == true then if currentState == false then local now = getTickCount() local elapsedTime = now - dxFades.timeStart local duration = dxFades.timeStop - dxFades.timeStart local progress = elapsedTime / duration rectangleWidth = interpolateBetween( 0,0,0, screenX,0,0, progress, "InOutQuad" ) if elapsedTime > duration then currentState = true end end for i=0,dxFades.size do -- what should I change dxFades.size to to have just enough rectangles that covers up the whole screen, but not more? local randomSize = math.random(0,250) exports.vice_util:dxDrawBorder(0, i*(dxFades.size+borderSize), rectangleWidth+randomSize, dxFades.size, borderSize, tocolor(0,0,0,255)) dxDrawRectangle(0, i*(dxFades.size+dxFades.size/10), rectangleWidth+randomSize, dxFades.size, tocolor(r,g,b,255)) end else if currentState == true then local now = getTickCount() local elapsedTime = now - dxFades.timeStart local duration = dxFades.timeStop - dxFades.timeStart local progress = elapsedTime / duration rectanglePosX = interpolateBetween( 0,0,0, screenX,0,0, progress, "InOutQuad" ) if elapsedTime > duration then currentState = false end end for i=0,dxFades.size do -- what should I change dxFades.size to to have just enough rectangles that covers up the whole screen, but not more? local randomSize = math.random(0,250) exports.vice_util:dxDrawBorder(rectanglePosX+randomSize, i*(dxFades.size+borderSize), screenX, dxFades.size, borderSize, tocolor(0,0,0,255)) dxDrawRectangle(rectanglePosX+randomSize, i*(dxFades.size+dxFades.size/10), screenX, dxFades.size, tocolor(r,g,b,255)) end end outputChatBox(tostring(currentState)) end fadeCameraDX(true,255,255,255,10) setTimer(function() fadeCameraDX(true,0,0,0,20) outputChatBox("1") setTimer(function() fadeCameraDX(false,255,0,0,50) outputChatBox("2") end, 5000, 1) end, 10000, 1) So my questions again: How can I make the disappearing work and if the disappearing animation is over then remove the event handler of the onclientrender event? How can I make the rectangles have different lengths without wiggling and moving around, changing sizes? If I create the randomSize variable outside of the loop it doesn't change the size for each, but all of them, so it looks like nothing has changed. How can I "optimise" or make the loop better so I can get always just enough rectangles to cover up the whole screen?
  3. Well, actually that could be the case for the bumpers and skirts, since they look so smooth and correctly fitting, but that would involve lots of modelling I guess, since you have to make and add them in, for example 3ds max as a part of the vehicle. But I think there is an easier way than this. I'm not sure.
  4. Maybe try creating the object outside of the colshape and then move it inside the colshape using moveobject and use a timer to print the text, see if it works.
  5. local col = createColCircle(170, -377, 15) local object = createObject(737, 175, -377, 6) moveObject ( object, 100, 175, -378, 6 ) setTimer(function() print(isElementWithinColShape(object, col)) end, 500, 1, object) I don't know if I did right, but try something like this, try using timers, since you have to move the element if they are at the same position when being created. So MTA can recognize when did the element hit the collision shape, so it can assign the isElementWithinColShape function to it, I guess. Try using something like I posted.
  6. The onPlayerJoin event is a default server sided event of mta, you don't need this, this is not a custom event: addEvent("onPlayerJoin",true) The source of the onPlayerJoin event is the player who joined. So it means that the player is defined as source, so instead of "thePlayer" and "player" you must use "source", so it would look like this: local accName = getAccountName ( getPlayerAccount ( source ) ) Also, what is this for? if not player then player = source end Did you define somewhere a table called g_PlayerData? For the client side, you must create a custom function there, and then trigger it to server. So for example addEvent("customClientEvent", true) addEventHandler('customClientEvent', g_ResRoot, function() setTimer(getPlayers, 1000, 1) bindKey('f1', 'down', toggleFRWindow) createWindow(wndMain) hideAllWindows() guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me)) guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me)) setJetpackMaxHeight ( 9001 ) triggerServerEvent('onLoadedAtClient', g_ResRoot) end ) And then use triggerClientEvent on server side. Also, I don't think that you have to trigger the onLoadedAtClient event from server to client, just to trigger it back to server side again. Just to make it clear, you can just call the function where you put triggerClientEvent on server side I guess. Hope you understand me. I would reccomend you to also check some of the tutorials on wiki and the forum. You can find the tutorials on the right side of the Main Page, and you can find some really helpful tutorials on the forum here.
  7. Oh sorry, I made a typo, there was an "and" before the "then". function customMeCommand(message, messageType) local playerName = getPlayerName(source) local message = string.gsub(message, "#%x%x%x%x%x%x", "") if not isPedDead(source) then if messageType == 1 then cancelEvent() outputChatBox("** " .. playerName .. " " .. message .. "", getRootElement(), 192, 162, 216, true) end end end addEventHandler("onPlayerChat", getRootElement(), customMeCommand) Try now please.
  8. You can do your own /me command. function customMeCommand(message, messageType) local playerName = getPlayerName(source) local message = string.gsub(message, "#%x%x%x%x%x%x", "") if not isPedDead(source) and then if messageType == 1 then cancelEvent() outputChatBox("** " .. playerName .. " " .. message .. "", getRootElement(), 192, 162, 216, true) end end end addEventHandler("onPlayerChat", getRootElement(), customMeCommand)
  9. You are mixing up client side and server side functions so much. #1: onClientResourceStart is obviously a client sided event but --> #2: getAccountName is a server sided function. So, you must do the whole script server side I guess, I'm not sure what do you want to do, but if you want to get the account name of the player you must do it server side. #3: Who is thePlayer? You must define it somewhere and somehow on server side, on client side you can simply just use localPlayer in some scenarios. #4: On server side you must specify the player whose camera you want to be faded. So you can't just use fadeCamera(true), instead you must use fadeCamera(thePlayer, true), in this case thePlayer is the player. #5: On server side, if you are triggering an event from client side, you must obviously use triggerClientEvent, not triggerServerEvent. #6: You can't use gui or draw functions on server side, and I assume that you did because of the createWindow() and hideAllWindows() functions, you must use triggerClientEvent for that. #7: Is g_ResRoot defined somewhere? Client Scripting Functions Client Scripting Events Server Scripting Functions Server Scripting Events
  10. Here is my weather system, I think using this method (using tables) is easier. local weatherTable={ { weatherid=0, name="very sunny" }, { weatherid=1, name="sunny" }, { weatherid=2, name="sunny but foggy" }, { weatherid=8, name="rainy" }, { weatherid=9, name="foggy" }, } local currentWeatherTable={} function setNewWeather() currentFogDistance = getFogDistance() while (#currentWeatherTable<7) do table.insert(currentWeatherTable,weatherTable[math.random(1,#weatherTable)]) end end function weatherSystemStart() setTimer(newWeather, 1000, 1) end addEventHandler("onResourceStart", resourceRoot,setNewWeather) addEventHandler("onResourceStart", resourceRoot,weatherSystemStart) function newWeather() local weather=table.remove(currentWeatherTable,1) outputChatBox("the weather is now "..weather.name) setWeatherBlended(weather.weatherid) setNewWeather() end setTimer(newWeather, 1000*(math.random(5, 10))*60, 0) You can add more weathers by just adding a new line to the table and changing the id and the name to whatever you want.
  11. So I guess I have to use tables for that with the object, and the positions of the object for the vehicle. So a lots of data should be given. What does that mean? How is this possible to do that and if I did that how should I do the scripting part?
  12. EDIT: picture one, meant to write cadrona, not primo
  13. Hello! I was browsing around and I found an MTA server called NFS:SA MTA, which is obviously a Need For Speed themed gamemode for MTA:SA. The developers of this server made a really nice job with this server and it's resources, but I'm interested in one or two things about some of their scripts, I have no idea how they could make it. So first of all, how is this possible to add tuning parts to a non-tunable vehicle? Like the bumper of a tuned elegy or sultan to a nebula or something? I know that some of the tuning parts are objects, so I can create them via createObject and attach them to the vehicle. But how can I count the position of the tuning part? Or do I have to use a table for every tuning part's position on every vehicle I would like to make tunable, and also, do I have to make a custom tuning shop to apply these tuning parts? How can I save and load a vehicle if it has tuning parts? Example picture: If I see it right, it is the primo. How is this possible to make a bumper, skirts and etc for that vehicle and attach them? If I'm not mistaken, it is possible to put every spoiler on every vehicle in MTA, how can I do that with other tuning parts as well? The second question I have: how can I make a vinyl for a vehicle and then apply it anywhere I would like to on the car? Example picture: Again, if I'm not mistaken, devGaming also made it possible, they have tons of (around 500-1000) custom vinyls as png images and it is possible to apply it anywhere on the car. Example of the devGaming tuning/vinyl system:
  14. https://wiki.multitheftauto.com/wiki/Character_Skins Notes: Last valid skin ID: 312 The following pairs of IDs produce same character (1st ID used in lists, 2nd disabled) 118:119 148:149 Non-working IDs <---- 3 4 5 6 8 42 65 74 86 119 149 208 273 289 <---- Change the non-valid numbers in the tables (3, 5, etc.) to something else and see if it works.
  15. Alright, thank you all for every help! You helped me so much with this!
  16. I have managed to fix it, tostring(vehicle) == vehicle wasn't working, but something came into my mind, here's the final result if you are interested: function getVehicleBrand(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if vehicle then if isElement(vehicle) then --case element if getElementType(vehicle) == "vehicle" then if getElementModel( vehicle ) == v[i].modelID then return k end else return false --if it's an element but it's not a veh, we can kill the function... it's not a vehicle and that's not we handle here. It's junk :D end elseif tonumber(vehicle) and not tostring(vehicle) then if v[i].modelID == tonumber(vehicle) then return k end if getVehicleNameFromModel( tonumber(vehicle) ) then return false --another general check: if the number provided is NOT an ID it is again junk end elseif tostring(vehicle) and not tonumber(vehicle) then --case string if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return k end if not getVehicleModelFromName( vehicle ) then --it's just a general check, if it's not a valid name it's junk we won't need return false end end --do not return false here, otherwise the loop will break else return false --our arg were nil or false end end end return "" end function getVehicleCustomName(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if vehicle then if isElement(vehicle) then if getElementType( vehicle ) == "vehicle" then if getElementModel( vehicle ) == v[i].modelID then return v[i].vehicleName end end elseif tonumber(vehicle) and not tostring(vehicle) then if v[i].modelID == tonumber(vehicle) then return v[i].vehicleName end if getVehicleNameFromModel( tonumber(vehicle) ) then return false --another general check: if the number provided is NOT an ID it is again junk end elseif tostring(vehicle) and not tonumber(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return v[i].vehicleName end if not getVehicleModelFromName( vehicle ) then --it's just a general check, if it's not a valid name it's junk we won't need return false end end else return false --our arg were nil or false end end end --return default name... let's do it --note: it's possible to compact this, but it will be much less readable if isElement( vehicle ) and getElementType( vehicle ) == "vehicle" then return getVehicleNameFromModel( getElementModel( vehicle ) ) --getVehicleName( vehicle ) lol elseif tonumber(vehicle) then --if it's a number here... it's a valid model so get the name return getVehicleNameFromModel( vehicle ) elseif tostring(vehicle) then --if it wasn't valid the functions already have returned false, so if it's a string in this part of code it's a valid name return vehicle else return nil --in case i forgot something, nil will be returned. remember that both nil and false are "false values", but they are different! end end local car = createVehicle(516, 210.8377532959, -1466.6046142578, 10.860450744629) outputChatBox(getVehicleBrand(420) .. " " .. getVehicleCustomName(420) .. " 1") outputChatBox(getVehicleCustomName(car) .. " 2") outputChatBox(getVehicleBrand("Cadrona") .. " " .. getVehicleCustomName("Cadrona") .. " 3")
  17. These are working if the vehicle is a string or an element, but if I put a number there I get the ' attempt to concatenate a boolean value ' error in debugscript. I have read through the script you posted, I tried to fix it but it does not work for some reason and I can't fix it. It only works with an element and a string. function getVehicleBrand(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if vehicle then if isElement(vehicle) then --case element if getElementType(vehicle) == "vehicle" then if getElementModel( vehicle ) == v[i].modelID then return k end else return false --if it's an element but it's not a veh, we can kill the function... it's not a vehicle and that's not we handle here. It's junk :D end elseif tostring(vehicle) then --case string if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return k end if not getVehicleModelFromName( vehicle ) then --it's just a general check, if it's not a valid name it's junk we won't need return false end elseif tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return k end if getVehicleNameFromModel( tonumber(vehicle) ) then return false --another general check: if the number provided is NOT an ID it is again junk end end --do not return false here, otherwise the loop will break else return false --our arg were nil or false end end end return "" end function getVehicleCustomName(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if vehicle then if isElement(vehicle) then if getElementType( vehicle ) == "vehicle" then if getElementModel( vehicle ) == v[i].modelID then return v[i].vehicleName end end elseif tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return v[i].vehicleName end if not getVehicleModelFromName( vehicle ) then --it's just a general check, if it's not a valid name it's junk we won't need return false end elseif tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return v[i].vehicleName end if getVehicleNameFromModel( tonumber(vehicle) ) then return false --another general check: if the number provided is NOT an ID it is again junk end end else return false --our arg were nil or false end end end --return default name... let's do it --note: it's possible to compact this, but it will be much less readable if isElement( vehicle ) and getElementType( vehicle ) == "vehicle" then return getVehicleNameFromModel( getElementModel( vehicle ) ) --getVehicleName( vehicle ) lol elseif tostring(vehicle) then --if it wasn't valid the functions already have returned false, so if it's a string in this part of code it's a valid name return vehicle elseif tonumber(vehicle) then --if it's a number here... it's a valid model so get the name return getVehicleNameFromModel( vehicle ) else return nil --in case i forgot something, nil will be returned. remember that both nil and false are "false values", but they are different! end end local car = createVehicle(516, 210.8377532959, -1466.6046142578, 10.860450744629) outputChatBox(getVehicleBrand(516) .. ", " .. getVehicleCustomName(516)) outputChatBox(getVehicleCustomName(car)) outputChatBox(getVehicleBrand("Cadrona") .. " " .. getVehicleCustomName("Cadrona"))
  18. I really don't understand what am I doing wrong, I tried it again, it's different, I tried doing what you wrote, but it's not working. It only outputs Enus Huntley, but it is wrong as well, because I am creating a bus in the script and it should output Brute, Bus, for the number and string arguments it doesn't even output anything, I just get this error in the debugscript: 'brandG.lua:202: attempt to concatenate a boolean value I don't understand what's wrong, I can't fix it. This is my whole current script: vehicleTable = { -- brand --> vehicle -- name, mod (if there is any), model id ["Maibatsu"] = { {vehicleName="Penumbra", fileName="mods/previon", modelID=436}, {vehicleName="Manchez", fileName="mods/sanchez", modelID=468}, }, ["Benefactor"] = { {vehicleName="Schwartzer", fileName="mods/elegant", modelID=507}, {vehicleName="Schafter", fileName="mods/admiral", modelID=445}, }, ["Pegassi"] = { {vehicleName="Infernus", fileName="mods/infernus", modelID=411}, }, ["Enus"] = { {vehicleName="Huntley", fileName="mods/huntley", modelID=579}, {vehicleName="Cognoscenti", modelID=580}, }, ["Declasse"] = { {vehicleName="Rancher", modelID=489}, {vehicleName="Rancher XL", fileName="mods/intruder", modelID=546}, {vehicleName="Tampa", fileName="mods/tampa", modelID=549}, {vehicleName="Perennial", fileName="mods/peren", modelID=404}, {vehicleName="Voodoo", fileName="mods/voodoo", modelID=412}, {vehicleName="Tornado", modelID=576}, {vehicleName="Savanna", modelID=567}, {vehicleName="Moonbeam", fileName="mods/moonbeam", modelID=418}, }, ["BF"] = { {vehicleName="Injection", modelID=424}, {vehicleName="Bandito", fileName="mods/bandito", modelID=568}, }, ["Annis"] = { {vehicleName="Stratum", modelID=561}, {vehicleName="Elegy", modelID=562}, }, ["Karin"] = { {vehicleName="Manana SS", fileName="mods/emperor", modelID=585}, {vehicleName="Manana", fileName="mods/manana", modelID=410}, {vehicleName="Sultan", fileName="mods/sultan", modelID=560}, {vehicleName="Kuruma", fileName="mods/primo", modelID=547}, }, ["Mammoth"] = { {vehicleName="Patriot", fileName="mods/patriot", modelID=470}, {vehicleName="Hydra", fileName="mods/hydra", modelID=520}, {vehicleName="Skimmer", modelID=460}, }, ["Lampadati"] = { {vehicleName="Super GT", fileName="mods/supergt", modelID=506}, }, ["Imponte"] = { {vehicleName="Dukes", fileName="mods/stallion", modelID=439}, {vehicleName="Centauro S-200", fileName="mods/phoenix", modelID=603}, }, ["Grotti"] = { {vehicleName="Turismo R", modelID=451}, }, ["Willard"] = { {vehicleName="Majestic", modelID=517}, {vehicleName="Tahoma", fileName="mods/tahoma", modelID=566}, {vehicleName="Polaris V8", fileName="mods/solair", modelID=458}, }, ["Truffade"] = { {vehicleName="Deluxo", fileName="mods/cadrona", modelID=527}, {vehicleName="Hustler", fileName="mods/hustler", modelID=545}, }, ["Vapid"] = { {vehicleName="Contender", fileName="mods/yosemite", modelID=554}, {vehicleName="Contender XL", fileName="mods/landstal", modelID=400}, {vehicleName="Hotknife", fileName="mods/hotknife", modelID=434}, }, ["Brute"] = { {vehicleName="Bus", modelID=431}, {vehicleName="Dashound", fileName="mods/coach", modelID=437}, {vehicleName="Ambulance", modelID=416}, {vehicleName="Enforcer", modelID=427}, {vehicleName="Boxville", modelID=498}, {vehicleName="Journey", modelID=508}, {vehicleName="Pony", fileName="mods/pony", modelID=413}, {vehicleName="Hot-Dog", modelID=588}, {vehicleName="Stockade", modelID=428}, {vehicleName="Barracks", modelID=433}, {vehicleName="Towtruck", modelID=525}, {vehicleName="Utility Van", modelID=552}, {vehicleName="Firetruck Ladder", modelID=544}, }, ["HVY"] = { {vehicleName="Linerunner", modelID=403}, {vehicleName="Roadtrain", modelID=515}, {vehicleName="Tanker", modelID=514}, {vehicleName="Benson", modelID=499}, {vehicleName="Dozer", modelID=486}, {vehicleName="Flatbed", modelID=455}, {vehicleName="Yankee", fileName="mods/yankee", modelID=456}, {vehicleName="Packer", modelID=443}, {vehicleName="Mule", modelID=414}, {vehicleName="Dumper", modelID=406}, {vehicleName="Firetruck", fileName="mods/firetruk", modelID=407}, {vehicleName="Trashmaster", fileName="mods/trash", modelID=408}, {vehicleName="Cement Truck", modelID=524}, {vehicleName="Combine Harvester", modelID=532}, {vehicleName="DFT-30", modelID=578}, {vehicleName="Forklift", modelID=530}, }, ["Cheval"] = { {vehicleName="Picador", fileName="mods/picador", modelID=600}, }, ["Albany"] = { {vehicleName="Buccaneer", fileName="mods/buccanee", modelID=518}, }, ["Military"] = { {vehicleName="Rhino Tank", fileName="mods/rhino", modelID=432}, {vehicleName="Hunter", modelID=425}, }, } function getVehicleBrand(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if vehicle and isElement(vehicle) then return k else return false end if tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return k end else return false end if tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return k end else return false end end end return "" end function getVehicleCustomName(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if v[i].vehicleName then if vehicle and isElement(vehicle) then return v[i].vehicleName else return false end if tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) then return v[i].vehicleName end else return false end if tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return v[i].vehicleName end else return false end else return getVehicleNameFromModel(vehicle) end end end end local car = createVehicle(431, 210.8377532959, -1466.6046142578, 10.860450744629) outputChatBox(getVehicleBrand(car) .. ", " .. getVehicleCustomName(car)) outputChatBox(getVehicleBrand(400) .. ", " .. getVehicleCustomName(400)) outputChatBox(getVehicleBrand("Cadrona") .. ", " .. getVehicleCustomName("Cadrona"))
  19. I guess you will have to wait for a reply of a more experienced person, I don't know what could be the problem, sorry.
×
×
  • Create New...