Dope88
-
Posts
30 -
Joined
-
Last visited
Posts posted by Dope88
-
-
Hello, I want to remodel my vehicles when the Players join on my server. Code works with the command but the game crashes with the onPlayerJoin Event. Thanks for Help
server.lua:
--[[resourceRoot = getResourceRootElement(getThisResource()) function fahrzeugErstellen(id) local fahrzeug = createVehicle(544, -1993.19, 209.32, 27.39 ) setElementModel(fahrzeug, id) --triggerClientEvent(resourceRoot, "fahrzeugAnfrage", resourceRoot, fahrzeug) end addEvent('fahrzeugErstellen', true) addEventHandler('fahrzeugErstellen', resourceRoot, fahrzeugErstellen) --fahrzeugErstellen()]] resourceRoot = getResourceRootElement(getThisResource()) fahrzeug = createVehicle(544, -1993.19, 209.32, 27.39) function fahrzeugErstellen(playerSource) triggerClientEvent('fahrzeugModellieren', resourceRoot, fahrzeug) end addCommandHandler('fahrzeugErstellen', fahrzeugErstellen) function onPlayerJoin(playerSource, commandName) setTimer ( function() executeCommandHandler ( "fahrzeugErstellen", playerSource ) end, 60000, 1 ) end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin)
client.lua:
resourceRoot = getResourceRootElement(getThisResource()) function fahrzeugModellieren(fahrzeug) --if ( fileExists ( "pdBus.txd" ) then --if ( fileExists ( "pdBus.dff" ) then local txd = engineLoadTXD('pdBus.txd') local dff = engineLoadDFF('pdBus.dff') local id = engineRequestModel('vehicle', 544) engineImportTXD(txd, id) engineReplaceModel(dff, id) setElementModel(fahrzeug, id) --end --end end addEvent('fahrzeugModellieren', true) addEventHandler('fahrzeugModellieren', resourceRoot, fahrzeugModellieren)
-
14 hours ago, thisdp said:
The "relative" is calculated according to "parent". For example
local labelA = guiCreateLabel(100,100,400,200,"",false) local labelB = guiCreateLabel(0.1,0.2,0.5,0.5,"",true,labelB)
for labelB, it's
x = 0.1 * 400
y = 0.2 * 200
width = 0.5 * 400
height = 0.5 * 200In this way, we can know that:
x = relativeX * parentWidth
y = relativeY * parentHeight
width = relativeWidth * parentWidth
height = relativeHeight * parentHeightIf there's no parent, parentWidth and parentHeight will be screenWidth and screenHeight.
Thank you that helped a lot
Is there any function like guiGetSize() to get the Width and Height of an gui Element?
-
Hello, yes I know but i want to convert them in this script to absolute values
-
Hello I'am working on a gui system with absolute values:
customKnopfErstellen = function(x, y, breite, laenge, ueberschrift, relative, parent) local knopfUntergrundOben = guiCreateStaticImage(x, y, breite, 1, "images/pixel_weiss.png", relative, parent) local knopfUntergrundRechts = guiCreateStaticImage(x+breite-1, y, 1, laenge, "images/pixel_weiss.png", relative, parent) local knopfUntergrundUnten = guiCreateStaticImage(x, y+laenge-1, breite, 1, "images/pixel_weiss.png", relative, parent) local knopfUntergrundLinks = guiCreateStaticImage(x, y, 1, laenge, "images/pixel_weiss.png", relative, parent) local knopfObergrund = guiCreateStaticImage(x+1, y+1, breite-2, laenge-2, "images/pixel_weiss.png", relative, parent) local label = guiCreateLabel(0, 0, breite-2, laenge-2, ueberschrift, relative, knopfObergrund) guiSetFont(label, "default-bold-small") guiLabelSetHorizontalAlign(label, "center", false) guiLabelSetVerticalAlign(label, "center", false) guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfObergrund, "ImageColours", "tl:"..knopfFarbe.." tr:"..knopfFarbe.." bl:"..knopfFarbe.." br:"..knopfFarbe) addEventHandler("onClientMouseEnter", label, function(mx, my) guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfSchrift.." tr:"..knopfSchrift.." bl:"..knopfSchrift.." br:"..knopfSchrift) guiLabelSetColor(label, 135, 135, 135) end, false) addEventHandler("onClientMouseLeave", label, function() guiSetProperty(knopfUntergrundOben, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundRechts, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundUnten, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiSetProperty(knopfUntergrundLinks, "ImageColours", "tl:"..knopfRandFarbe.." tr:"..knopfRandFarbe.." bl:"..knopfRandFarbe.." br:"..knopfRandFarbe) guiLabelSetColor(label, 255, 255, 255) end, false) return label end standartKnopfErstellen = guiCreateButton guiCreateButton = customKnopfErstellen
But how to make it when the values from guiCreateButton are relative values? How to convert them to absolute values that this script works? thank you
-
13 minutes ago, The_GTA said:
I have received your resource files for full evaluation and have detected an alpha-based image configuration combined with append-layer based shader attachment. Based on the provided files, here is my defect report:
- By creating and attaching multiple shaders onto the same "head_diff_000_a_whi" texture of the player model you are inducing depth-fighting between the bart and the face textures. It looks like a coding error in your script due to COPY & PASTE. In order to focus your eyes for critical reading, take a look at line 348 of example.lua:
engineApplyShaderToWorldTexture(shader,clothes_ID[7]["face"][1],thePlayer, true)
In this line you are using the "face" texture. Are you meaning to use the "beard" texture instead? If you are, then you can fix easily fix this issue by chaging the string and making sure that each shader points to only one texture. In case you are not, there is a fundamental flaw in your design that is caused by misunderstanding how the GPU works and how MTA is utilizing it. By using append-layers and enabling depth-testing, the GPU is attempting to redraw the beard onto the original model BUT this is not stable because of mathematical inprecision. Your textures will start to flicker or one will hide another.
So how to fix this defect? Instead of creating two shaders that draw onto one texture, I recommend you to off-screen combine the textures and then apply them to a shader. You can use the dxCreateRenderTarget, dxSetRenderTarget, dxCreateTexture and dxDrawImage functions to create a drawing surface (render target), layer the face + beard onto each other and then use the resulting render-target as texture in your shader. Do not forget to enable alpha for the render-target!
Here is how a combine-stage of two textures might look like:local function renderCombinedTexture(tex1, tex2) local tex1w, tex1h = dxGetMaterialSize(tex1) local tex2w, tex2h = dxGetMaterialSize(tex2) local cw, ch = math.max(tex1w, tex2w), math.max(tex1h, tex2h) local rt = dxCreateRenderTarget(cw, ch, true) dxSetRenderTarget(rt) dxDrawImage(0, 0, tex1w, tex1h, tex1) dxDrawImage(0, 0, tex2w, tex2h, tex2) dxSetRenderTarget() return rt end
You should use renderCombinedTexture in the onClientRender event handler to adhere to MTA's recommendations.
- You seem to use weird global variables across your script. Take a look at the following line which repeats itself but seems to imply a contradiction:
hat[thePlayer] = shader
The global table is called "hat" but the function it is used in is called addFace or addBart. Could this be a variable misuse?
I am looking forward to hearing back from you!
Wow! Thank you very much for taking the Time to help me with my Problem. I will take a look at it and try toedit it the next days. I will tell you when im done! Thank you!
-
I bought the Script from the Internet I‘ll look what I can do and could I message you in private please?
-
I made a Mistake with "bart" and "Bart" had the B big and b small but now I changed it and the face texture disappears when I activate the beard and the beard disappears when I activate the face texture..
-
3 hours ago, The_GTA said:
- Please take a look at the engineApplyShaderToWorldTexture wiki documentation. Are you properly setting the appendLayers parameter to true or leaving it out?
- It might help to support you if we had insight into your shaders themselves. They could be designed in a way that does not allow layering. Could you share them with us?
Thanks for the Answer! I just set appendLayers to true but now nothing seems to happen.
Client Side:
local shaderData = [[ texture tex; technique replace { pass P0 { Texture[0] = tex; } } ]] face = {} bart = {} function addFace(thePlayer, ID, color) if (face[thePlayer]) then -- to remove any existing hair before applying new one. for i, v in ipairs(clothes_ID[7]["face"]) do engineRemoveShaderFromWorldTexture ( face[thePlayer], v, thePlayer) end local shader = dxCreateShader(shaderData, {}, 0, 0, false, "ped") local texture = dxCreateTexture("clothes/7/face/1/"..color..".png") dxSetShaderValue(shader, "tex", texture) engineApplyShaderToWorldTexture(shader,clothes_ID[7]["face"][tonumber(ID)],thePlayer, true) hat[thePlayer] = shader else local shader = dxCreateShader(shaderData, {}, 0, 0, false, "ped") local texture = dxCreateTexture("clothes/7/face/"..ID.."/"..color..".png") dxSetShaderValue(shader, "tex", texture) engineApplyShaderToWorldTexture(shader,clothes_ID[7]["face"][1],thePlayer, true) hat[thePlayer] = shader end end addEvent("client:sync:face", true) addEventHandler("client:sync:face", root, addFace) function addBart(thePlayer, ID, color) if (face[thePlayer]) then for i, v in ipairs(clothes_ID[7]["face"]) do engineRemoveShaderFromWorldTexture ( face[thePlayer], v, thePlayer) end local shader = dxCreateShader(shaderData, {}, 0, 0, false, "ped") local texture = dxCreateTexture("clothes/7/bart/1/"..color..".png") dxSetShaderValue(shader, "tex", texture) engineApplyShaderToWorldTexture(shader,clothes_ID[7]["face"][tonumber(ID)],thePlayer, true) hat[thePlayer] = shader else local shader = dxCreateShader(shaderData, {}, 0, 0, false, "ped") local texture = dxCreateTexture("clothes/7/bart/"..ID.."/"..color..".png") dxSetShaderValue(shader, "tex", texture) engineApplyShaderToWorldTexture(shader,clothes_ID[7]["face"][1],thePlayer, true) hat[thePlayer] = shader end end addEvent("client:sync:Bart", true) addEventHandler("client:sync:Bart", root, addBart)
Server Side:
function testface(thePlayer, _, ID, color) triggerClientEvent(root, "client:sync:face", thePlayer, thePlayer, ID, color) end addCommandHandler("testface", testface, false, false) function testbart(thePlayer, _, ID, color) triggerClientEvent(root, "client:sync:bart", thePlayer, thePlayer, ID, color) end addCommandHandler("testbart", testbart, false, false)
Shared:
clothes_ID = { [7] = { ["face"] = {"head_diff_000_a_whi"}, ["bart"] = {"head_diff_000_a_whi"}, }, }
-
Hello im searching a Model creator to edit my skin for a customization system I just need to cooy and paste the face region to put eyes eyebrows and beard. These textures fit perfectly with the normal face region but deletes the face when I activate a beard shader image for example. Thats why it must be duplicadet. I pay for the service
-
Hello I want to put multiple textures to one texture Name with "engineApplyShaderToWorldTexture", but when I apply one shader the other one disappears. What could I do now?
Thanks for the help!
-
Give the Resource u running Admin rights in your acl
-
Hey Iam looking for a Model creator. Iam interested in MLO Maps like in FiveM. I want to have enterable buildings in San Fierro for example burger shots... I pay for your work. Thank you
-
On 25/03/2021 at 16:16, thisdp said:
Use Cos and Sin to calculate the position
Or better question.. Which function creates the menu?
-
On 25/03/2021 at 16:16, thisdp said:
Use Cos and Sin to calculate the position
Thank you for the Answer! What is Cos and Sin?
-
2 hours ago, ege said:
I'm new to this business, I just do the basics, I was wondering if you can help me
Try this resource https://community.multitheftauto.com/index.php?p=resources&s=details&id=14560
-
On 30/05/2017 at 14:53, thisdp said:
This is my server. The gui is made by dgs. ( I am bad in design sry)
How to create a radial menu like in the second picture?
-
Hey im looking for a Clothing System. I will pay for it. PM me Thank you!
-
On 09/01/2020 at 03:52, XaskeL said:
Completely finished code, as well as an example of use inside. Also, a resource is ready to download protected files (loader).
Link:
https://www.dropbox.com/s/0cpkkuwjdqa6nvt/protection dff %26 txd files example.rar?dl=0Works perfect Thank you
-
Do you know why?
-
10 minutes ago, XaskeL said:
It is worth testing. And the key is what you encrypt your file and decrypt, it is advisable to come up with it yourself. After that, you need to encrypt the models and in the client-side decrypt in RAW and load.
Thank you I made all in Client File but now I get Errors in line 49: Corrupt DFF File data or file path too long
-
1 hour ago, XaskeL said:
Example:
function string_padding_dword(s) local l = 4 - string.len(s) % 4 return s .. string.rep(string.char(l), l) end function string_unpadding_dword(s) return string.sub(s, 0, string.len(s) - string.byte(s, string.len(s))) end function FileProtection(path, key) local file = fileOpen(path) local size = fileGetSize(file) local FirstPart = fileRead(file, 65536) fileSetPos(file, 65536) local SecondPart = fileRead(file, size - 65536) fileClose(file) file = fileCreate(path..'rw') fileWrite(file, encodeString('tea', string_padding_dword(FirstPart), { key = key })..SecondPart) fileClose(file) return true end function FileUnProtection(path, key) local file = fileOpen(path) local size = fileGetSize(file) local FirstPart = fileRead(file, 65536 + 4) fileSetPos(file, 65536 + 4) local SecondPart = fileRead(file, size - (65536 + 4)) fileClose(file) -- file = fileCreate(path..'rw') -- fileWrite(file, string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart) -- fileClose(file) return string_padding_dword( decodeString('tea', FirstPart, { key = key }) )..SecondPart end -- example FileProtection('infernus.dff', 'GT4BAE') -- FileUnProtection(path, key) local txd = engineLoadTXD('infernus.txd') engineImportTXD(txd, 401) local dff = engineLoadDFF( FileUnProtection('infernus.dff', 'GT4BAE') ) engineReplaceModel(dff, 401)
Thank you very much Do I just have to change infernus.dff and infernus.txd to my files? and what do I have to do with the key? (GT4BAE)
-
Hello im searching for a good compiler Script. I would also pay for it
-
Hello im searching for a good compiler Script. I would also pay for it
-
Download link doesnt work
- 2
[HELP] onPlayerJoin
in Scripting
Posted
Works, thank you!