Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Dzsozi (h03)

  1. Why don't you just use bone attach and attach a phone object to the player's hand?
  2. Very helpful, lots of beginner modellers will be grateful for your effort that you put into this video!
  3. ****Sighs**** Okay so you are trying to tell me to look up the wiki and community and basically the whole internet to create a new shader file, that - as I can see I must write it down again - can handle the replace of 4 textures at the same time. What kind of modeller are you if you couldn't find the default CJ textures in the game files bro? You are 100% right! But what does that have to do with my problem, nothing? It's a fact that peds vehicles and objects are being made in a modeling program bro, no sh#t! Have you ever checked this function on the wiki https://wiki.multitheftauto.com/wiki/EngineApplyShaderToWorldTexture ? I quote: so by that you probably already figured out that I am using the correct texture names, just because your HD downloaded CJ mod doesn't have its files named the same (let me guess they are called player_torso, player_legs, etc), it doesn't mean I am using the wrong textures, since MTA handles those texture names in a different way as we can see, with some quick semi enthusiastic research you could find the answer easy bro. Why are you linking me the MTA community site, I don't even know, so let's not talk about that. Well, about countless shader examples, I wouldn't say they are countless. But they are not examples for me in this case. Like you said, yes, those are shaders, and this is what I use them for in this case as well. REPLACE TEXTURES, which means I edit the default texture, for example the torso and REPLACE it with a shader. So what does modeling has to do with it, I still don't get it. I don't have to do any UV mapping nor any modeling, why would I? You yourself said that shaders are for applying a texture to an object ped or vehicle. Looks like you are not completely understanding how texture replacing works if you only edit the default texture(?) You can keep telling me to go on YouTube or MTA forum (well, in this case this is what I just did, and that's the reason for this topic being existent, so again, I don't understand you), but there's a reason I made this topic... Probably because I didn't find the proper help I need and I am hoping for someone to help me out, don't you think? I didn't create this topic because I was bored. So, from now on, please avoid telling me the same thing "over and over in different ways" bro. Because you are not helping me, you are just trying to prove me wrong, that I must go and learn from wiki and search up the whole internet for a solution to my problem. I just asked a simple question which is: HOW CAN I MAKE A SHADER THAT CAN HANDLE MULTIPLE TEXTURE REPLACES AT ONCE??? No modeling, no UV mapping, no Facebook or YouTube or Twitter search for help, just a simple question on MTA forum in a topic about shaders. You don't have to tell me that I am doing it wrong and must find a different way via modeling, (even if I already have my system ready, just willing to improve it) when you are the one who doesn't even know where to find the default game textures. And now, back to the main question again: HOW CAN I MAKE A SHADER THAT CAN HANDLE MULTIPLE TEXTURE REPLACES AT ONCE??? ???
  4. https://community.multitheftauto.com/index.php?p=resources&s=details&id=4413 https://community.multitheftauto.com/index.php?p=resources&s=details&id=6889
  5. Well, thanks for your help, that I way I could "just learn" HLSL shader programing and fix the problem on my own. Could you already please tell me what does the modeling has to do with my problem? Learn to do what in a modeling program? I don't even understand... I already made my system and it is working, I just want to improve it by minimizing the amount of shaders I use in my script and that's what I need help with, writing a new shader file that can handle multiple texture replacing.
  6. Yes, maybe it is not a big performance question at all, but it would be also easier to change the textures, I mean less lines in the script itself. For example not having to destroy all the shaders and such, just change the shader value. @Ren_712 Can you give me a helping hand regarding the question of this topic?
  7. Check if the player is in a vehicle and then set the vehicle’s position as well. local vehicle = getPedOccupiedVehicle(p) if vehicle then setElementPosition(vehicle, 0, 0, 5) end
  8. @Pirulax is right, it doesn't work, the feet texture is being put on every part of the character.
  9. I am not sure how I should use this with my code. I tried many ways of adding, substracting and calculating but it always happened that I got spawned outside the given area coordinates. This is my current script: spawnPositions = { ["Whetstone"] = {minPos = {-188.8860168457,267.83926391602}, maxPos = {-204.15943908691,251.66763305664}, z = 12.078125}, } function getRandomPositionInArea(minValue, maxValue) -- Be a number #1 local value1 = minValue local value2 = maxValue -- Be different! ;o local difference = (value1 - value2) -- Be positive! :D local positiveDifference = math.abs(difference) -- Be ra ndo m! local randomPositiveDifference = math.random(positiveDifference) local randomDifference if difference < 0 then -- Be negative :( randomDifference = -randomPositiveDifference else -- Stay positive! :DDDD randomDifference = randomPositiveDifference end -- Be famous print(value1+(randomDifference-value1)+value2) return value1+(randomDifference-value1)+value2 end function getRandomSpawnPoint(cityName) if spawnPositions[cityName] then local minX, minY = spawnPositions[cityName].minPos[1], spawnPositions[cityName].minPos[2] local maxX, maxY = spawnPositions[cityName].maxPos[1], spawnPositions[cityName].maxPos[2] local x, y = getRandomPositionInArea(minX, maxX), getRandomPositionInArea(minY, maxY) return x, y end end local cityName = "Whetstone" local x, y = getRandomSpawnPoint(cityName) setElementPosition(localPlayer, x, y, getGroundPosition(x, y, spawnPositions[cityName].z)+1)
  10. I would like to have random spawnpoints inside a given area. I have the positions for minimum and maximum positions, but for some reason I can't manage to get the script working properly. I am using math.random from min to max values, but sometimes I get spawned outside the area, it doesn't return the right values. How can I get it working properly, so I spawn only inside the given area? spawnPositions = { ["Los Santos"] = {minPos = {1127.3712158203,-1632.8560791016}, maxPos = {1139.2634277344,-1621.2121582031}, z = 18.610622406006}, ["Las Venturas"] = {minPos = {1460.0589599609,2615.3452148438}, maxPos = {1478.0885009766,2622.806640625}, z = 10.8203125}, ["San Fierro"] = {minPos = {-2253.4848632813,521.00201416016}, maxPos = {-2250.8369140625,544.48956298828}, z = 35.174301147461}, ["Tierra Robada"] = {minPos = {-2259.4995117188,2352.9875488281}, maxPos = {-2253.8283691406,2372.5617675781}, z = 4.9140625}, ["Bone County"] = {minPos = {-244.1667175293,1210.9313964844}, maxPos = {-214.33074951172,1223.3796386719}, z = 19.735198974609}, ["Red County"] = {minPos = {243.48251342773,-160.65313720703}, maxPos = {252.89712524414,-151.75907897949}, z = 1.5703220367432}, ["Flint County"] = {minPos = {19.591306686401,-2641.8295898438}, maxPos = {37.629207611084,-2632.4833984375}, z = 40.432315826416}, ["Whetstone"] = {minPos = {-2122.837890625,-2481.69921875}, maxPos = {-2118.30859375,-2466.0988769531}, z = 30.625}, } function getRandomSpawnPoint(cityName) if spawnPositions[cityName] then local realTime = getRealTime() math.randomseed(realTime.second + realTime.minute + realTime.hour) local minX, minY = spawnPositions[cityName].minPos[1], spawnPositions[cityName].minPos[2] local maxX, maxY = spawnPositions[cityName].maxPos[1], spawnPositions[cityName].maxPos[2] local x, y = math.random(minX, maxX), math.random(minY, maxY) return x, y end end I guess it is because of the negative values, how to do the calculations for math.random?
  11. That has nothing to do with my problem. My problem is that I don't know how to write the shader file properly to handle 4 textures that is being changed in the script.
  12. Link me the topic where I asked this question in a different way. If you are not trying to help then please avoid commenting.
  13. Hello! I would like to optimize my character system and create only one shader for every player, instead of creating a shader for every player and every clothing type. My current script handles shaders this way: for k, player in pairs(getElementsByType("player")) do cachedData[player] = {} cachedData[player].clothingShader = {} cachedData[player].bodyShader = {} end ... cachedData[player].clothingShader[clothingType] = dxCreateShader("files/shader.fx", 0, SHADER_MAX_VISIBLE_DISTANCE, true, "ped") Where the clothingType key is the actual clothing type from here https://wiki.multitheftauto.com/wiki/CJ_Clothes of the cloth or body texture that I would like to change. I tried changing up the things little bit and made this to my shader file (before I used the simple texture replace shader), this is my bodyShader.fx: texture cj_ped_torso; texture cj_ped_head; texture cj_ped_legs; texture cj_ped_feet; technique TexReplace { pass P0 { DepthBias = -0.0002; Texture[0] = cj_ped_torso; Texture[1] = cj_ped_head; Texture[2] = cj_ped_legs; Texture[3] = cj_ped_feet; } } I named the textures after the texture to replace, so therefore I can use a table where clothing type is the key and the texture to replace is the value, that way I can easily replace the textures. My problem now is that the same texture gets applied everywhere, how can I fix this? As I mentioned before, I would like to create only one shader for body textures and only one shader for clothing textures for every player, if that is possible. Here's my function for changing the face texture for an example of how I did things. clothingTypeToTexture = { [0] = "cj_ped_torso", [1] = "cj_ped_head", [2] = "cj_ped_legs", [3] = "cj_ped_feet", [13] = "cj_ped_necklace", [14] = "cj_ped_watch", [15] = "cj_ped_glasses", [16] = "cj_ped_hat", [17] = "cj_ped_extra1", } local function createBodyShader(player) if not isElement(cachedData[player].bodyShader) then return dxCreateShader("files/bodyShader.fx", 0, SHADER_MAX_VISIBLE_DISTANCE, false, "ped") end return nil end function changePlayerFaceTexture(player, faceID) if utility:isPlayer(player) and cachedData[player] then if availableFaceTextures[tonumber(faceID)] == "face-" .. tostring(faceID) then faceID = tonumber(faceID) local skinColor = currentSkinColor[player] or defaultSkinColor cachedData[player].bodyShader = cachedData[player].bodyShader or createBodyShader(player) engineApplyShaderToWorldTexture(cachedData[player].bodyShader, clothingTypeToTexture[1], player, false) dxSetShaderValue(cachedData[player].bodyShader, clothingTypeToTexture[1], cachedFaceTextures[skinColor][faceID]) currentFace[player] = faceID end end end What is the problem with this script? When I call the changePlayerBodyTexture function, which is almost the same structure but for the other body parts, every part gets the same texture, even the face, but it is not defined there, since it is being handled with a different function (this). EDIT: I realised that the problem is in the shader file, the texture that is used to replace the other is always the one that is defined as Texture[0] in the shader file at the pass. How can I make it functioning so I can handle all four in a different way?
  14. I don’t know what this could mean. Sometimes when you paste a code from the forum there is a character after the line, which doesn’t show up, but if you hit backspace at the end of that line, it deletes something and the code works. Try doing the same at the end of the 12th line, hit a backspace. Or try copying the code with the little icon in the top left corner, if this is not how you did it. I didn’t have any errors when I was testing so this must be the problem. I don’t know why it happens.
  15. Create a new lua file and paste this: walkStyleTable = { [118] = "Man", [119] = "Shuffle", [120] = "Old Man", [121] = "Gangster 1", [122] = "Gangster 2", [123] = "Old Fat Man", [124] = "Fat Man", [125] = "Jogger", [126] = "Drunk", [127] = "Blind", [128] = "SWAT", [129] = "Woman", [131] = "Busy Woman", [132] = "Sexy Woman", [133] = "Hooker", [134] = "Old Woman", [135] = "Fat Woman", [136] = "Jogging Woman", } In the meta.xml set the type of this lua file to "shared" Client: local screenW, screenH = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function() window = guiCreateWindow((screenW - 366) / 2, (screenH - 416) / 2, 366, 416, "Walking Styles", false) guiWindowSetSizable(window, false) gridlist = guiCreateGridList(29, 41, 308, 320, false, window) guiGridListAddColumn(gridlist, "ID", 0.3) guiGridListAddColumn(gridlist, "Name", 0.6) for id, name in pairs(walkStyleTable) do row = guiGridListAddRow(gridlist) guiGridListSetItemText(gridlist, row, 1, id, false, false) guiGridListSetItemText(gridlist, row, 2, name, false, false) end acceptbtn = guiCreateButton(39, 373, 126, 33, "Accept", false, window) closebtn = guiCreateButton(201, 373, 126, 33, "Close", false, window) guiSetVisible(window, false) addEventHandler("onClientGUIClick", closebtn, closemenu, false) addEventHandler("onClientGUIClick", acceptbtn, acceptanim, false) end ) function closemenu() guiSetVisible(window, false) showCursor(false) end function acceptanim() local selectedRow = guiGridListGetSelectedItem(gridlist) local selectedID = guiGridListGetItemText(gridlist, selectedRow, 1) triggerServerEvent("setWalkStyle",localPlayer,localPlayer,tonumber(selectedID)) closemenu() end addCommandHandler("s", function() guiSetVisible(window, true) showCursor(true) end) Server: addEvent("setWalkStyle", true) function setWalk(thePlayer, walkstyle) if not walkstyle or type(walkstyle) ~= "number" then return false end if not walkStyleTable[walkstyle] then outputChatBox("Invalid ID", thePlayer) return false else setPedWalkingStyle(thePlayer, walkstyle) outputChatBox("Your walking style was set to " .. tostring(walkstyle), thePlayer) return true end end addEventHandler("setWalkStyle", root, setWalk) I don't know why does the sorting of the table messes up, but it works.
  16. Try changing pairs to ipairs. If I am correct pairs is for table keys that is a string like [“1”] and ipairs is for undefined table keys or [1]. So if you have your helmetZombies table defined something like this helmetZombies = {44, 45, 46} --etc then you should use ipairs.
  17. Yes I already experienced that the 2 tables have a different userdata but I didn’t know why. So if I somehow try to implement your code to mine would it work? Or maybe try to send the missionData[1][“Criminal”] as a string?
  18. Sorry for not replying, I did some other things but now I returned to this resource. I don't really understand the way your script would work, I started making something else. I managed to do a kind of simple mission manager. I have a resource called sa_missionmanager where I handle mission starting and stopping etc. and a resource called sa_missions where I store the missions and data of them in seperate folders that's named after the mission ID. Here's my current sa_missionmanager server side script: addEvent("onPlayerMissionStart", true) addEvent("onPlayerMissionStop", true) function setPlayerMission(player, missionID) if exports["sa_utility"]:isPlayer(player) then if type(missionID) == "number" then local mission, id = getPlayerMission(player) if missionID ~= 0 then if id ~= missionID and not isElement(mission) then local missionElement = createElement("mission", missionID) setElementParent(player, missionElement) local team = getPlayerTeam(player) local teamName = "" if team then teamName = getTeamName(team) end triggerEvent("onPlayerMissionStart", player, missionID, teamName) return missionElement, missionID end else triggerEvent("onPlayerMissionStop", player, id) if isElement(mission) then destroyElement(mission) mission = nil end return nil, 0 end end end end -- THIS IS WHERE I HAVE MY PROBLEMS addEventHandler("onPlayerMissionStart", root, function(id, team) local currentMissionData = exports["sa_missions"]:sendMissionData(id) outputChatBox(tostring(currentMissionData[1]["Criminal"](source))) -- returns nil??? outputChatBox(tostring(currentMissionData[1]["name"])) -- returns 'Hunnid on your wrist' if currentMissionData[id] then if currentMissionData[id][team] then currentMissionData[id][team](source) -- this should start the mission depending on the player's team end end end ) -- I KNOW, THERE IS NO currentMissionData DEFINED BUT IT'S NVM RIGHT NOW addEventHandler("onPlayerMissionStop", root, function(id) if currentMissionData[id] then outputChatBox("end") end end ) function getPlayerMission(player) if exports["sa_utility"]:isPlayer(player) then for _, mission in ipairs(getElementsByType("mission")) do local children = getElementChildren(mission, "player") for _, child in pairs(children) do if child == player then return mission, getElementID(mission) end end end end return nil, 0 end function testfunction(player, command, id) if id then setPlayerMission(player, tonumber(id)) else outputChatBox("/" .. command .. " [id]", player) end end addCommandHandler("mission", testfunction) My current sa_missions server side script: function sendMissionData(id) if id and type(id) == "number" then return missionData end end My current sa_missions global/shared script: missionData = {} My current sa_missions/missions/1/data global/shared script: missionID = 1 missionData[missionID] = { ["name"] = "Hunnid on your wrist", ["maxLevel"] = 5, ["reward"] = {money = 100, xp = 50}, } My current sa_missions/missions/1 server side script: missionData[missionID]["Criminal"] = function(player) return getPlayerName(player) -- I added this because of the outputchatbox in the missionmanager end I know it is lots of code, I tried to delete the unwanted codes that work and focus on the structure mainly of the scripts. So I don't understand what is wrong with this script. Why does the function not get added to the missionData[missionID] table? Everything has the correct value when talking about outputting it in the missionmanager resource, but the function, it returns nil in the chat and nothing happens. Debugscript says: attempt to call field 'Criminal' (a nil value) What is the issue, what am I doing wrong? I would like to make my missions system based on something similar structure because I want to have lots of missions created and I would like them so it can be handled easily without writing the same lines of code in every mission script. So basically I only have to do the mission scripting itself, that's why I would like to have a mission manager. EDIT: Could the problem be that I am trying to add a value on a server side script to the table created in a global script? @IIYAMA
  19. Thank you so much for your help! Works totally perfect, it will be useful for me for so much more as well! I guess for others too, thank you again!
  20. It works perfectly, thank you! I just have one more question. Is it possible to add the color code used in the previous line to the next one?
  21. Since wordBreak is forced to false if the colorCoded parameter is set to true at dxDrawText, I would like to draw multiple texts under each other. I would like to make a mission instruction label text, just like the one you can see in the default GTA games on the bottom of the screen, where I would like to use hex colorcodes for some highlights and nicer design. How can I break a string into separate lines (put it in a table I guess, but how), so I can make a loop and draw multiple dxDrawTexts with the correct text to continue after a new line was added? Could somebody help me out with the maths and string handling? I would be really grateful!
×
×
  • Create New...