-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
Nice done mate. Now get serious please. https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions https://wiki.multitheftauto.com/wiki/Client_Scripting_Events https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions https://wiki.multitheftauto.com/wiki/Server_Scripting_Events
-
After you did some serious research and collecting the parts you need. I am not creating medium examples, if I am not sure if you will learn something of it. That are my rules.
-
You can't give weapons reload animations with setWeaponProperty because they simply do not exist(for some weapons) in GTA by default. An overwrite is required. (with setPedAnimation etc.)
-
local hover = false; showCursor(true); function dxDraw() dxDrawRectangle(567, 263, 229, 236, tocolor(0, 0, 0, 206), false); local move -- keep move local if isMouseInPosition(567, 263, 229, 236) then if not hover then start = getTickCount() iprint("state has been changed! (1)") hover = true end move = interpolateBetween(0, 0, 0, 236, 0, 0, ((getTickCount()-start)/500), "Linear"); else if hover then start = getTickCount() iprint("state has been changed! (2)") hover = false end move = interpolateBetween(0, 0, 236, 0, 0, 0, ((getTickCount()-start)/500), "Linear"); end dxDrawRectangle(567, 263, 229, move, tocolor(189, 131, 131, 206), false); end addEventHandler("onClientRender", getRootElement(), dxDraw) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end That's because you only need to update the start tickCount when you change state. And not when you your state is true or false. Please check the debug console.
-
local begin = ( ( getTickCount() - start ) % 500 / 500 ); This will repeat the animation. It is not what you want.(so don't apply it in your end code) But it might tell you what you are doing wrong with the timing. What you need to do is using a boolean to set a status. This status indicates when you switch between hovering and not hovering. local hovering = false if not hovering then start = getTickCount() hovering = true end if hovering then start = getTickCount() hovering = false end The code will rest the timing, when you switch states. I leave the applying of the code to you.
-
By defining the resourceRoot as source element and attach it at the other side with the resourceRoot as well. Client triggerServerEvent("event", resourceRoot) theElement: The element that is the source of the event. Server addEvent("event", true) addEventHandler("event", resourceRoot, attachedTo: The element you wish to attach the handler to. The handler will only be called when the event it is attached to is triggered for this element, or one of its children. Often, this can be the root element (meaning the handler will be called when the event is triggered for any element). https://wiki.multitheftauto.com/wiki/AddEventHandler The source element is LINKED to the attachedTo element. The attachedTo element will only accept the same element or the children of that same element. The triggerEventSystem is a global system and the events will always be global accessible. You have to do this for every resource that uses the same event name. The root element will accepts everything, included resourceRoot's.
- 3 replies
-
- 2
-
- triggerserverevent
- triggerclientevent
-
(and 1 more)
Tagged with:
-
addEventHandler("onClientGUIClick",weather_button,setCustomWeather) function setCustomWeather(button,state) --Function to change weather You can't use the same name for the function `setWeather`, because it will actually overwrite it. Which means that if you call setWeather on line 42, it will re-call the function setWeather of line 38 (and not the mta function).
-
Attach the addCommandHandler to a function. Not the GUI element `aWarpForm`. I will take a closer look at it, once you debug your code.
-
Use the camera object. https://wiki.multitheftauto.com/wiki/GetCamera local camera = getCamera() bindKey( "w", "down", function () if getKeyState( "lshift" ) == true then -- position is already included in the matrix local x,y,z = getPositionFromElementOffset(camera, 0, 3, 0) setElementPosition(localPlayer, x, y, z) end end )
-
Blow-up and down scaling is not working?
-
I do not recommend to use renderTargets for text. Because rendertargets do not include anti-aliasing. There reason behind that is for me unknown. Maybe it can work with blendmode as idarrr said.
-
You could try to scale up and scale down. Also texture images have better quality than images rendered directly from file.
-
I get the feeling that you are not taking me seriously. (I am out of here,)
-
bla bla bla bla I REALLY don't care!!! DEBUG! DEBUG! DEBUG!!! I do care! iprint("script has been executed") function blablabla (source, command) iprint("function blablabla has been executed") local players = getPlayerTeam(source) local team = getTeamName(players) iprint("player teamName", team) if team == "team" then iprint("team name is correct") setPedStat(source, 69, 999) setPedStat(source, 70, 999) setPedStat(source, 71, 999) setPedStat(source, 72, 999) setPedStat(source, 73, 999) setPedStat(source, 74, 999) setPedStat(source, 75, 999) setPedStat(source, 76, 999) setPedStat(source, 77, 999) setPedStat(source, 78, 999) setPedStat(source, 79, 999) outputChatBox("Done.", source) local boss = getElementData(source,'boss') iprint("boss value", boss) if boss == true then outputChatBox("You can not use this now while boss is activated.", source) end end end addCommandHandler("team", blablabla)
-
Try to test it with a different command, if you want to test if the command is blocked. I never said that there are debug problems. I said that you have to add debuglines and test your code.
-
It should be indeed not a problem. But keep in mind that once the function with a callback has been executed, it leaves the lua environment. If MTA doesn't tell lua to keep that function then the garbage collector loves to clean it. If you want to know this for sure, you can manually collect it and see if an error appears. It is probably old information if you ask me.
-
There is no 'event' in this code. Please add more debuglines, because I am very sure this is a human error.
-
One of the possibility is that it takes longer to load the model, when there are a lot of objects around. Which means it takes more time to create and stream it in. So try to give it some time.
-
I am well aware that attaching custom weapons are a bit buggy outside of the gta boundary. You have to drive/move the vehicle in order to attach them correctly. A small velocity push to the vehicle might do the trick. About that code. You are creating and destroy the weapons at the same time. Shouldn't you wait for the next frame? Also you might want to create the weapon near the player. With an offset of ~0, 0, 40.
-
This code: if (getTeamName(getPlayerTeam(player)) ~= "robber" then return false end Shouldn't be able to executed because of: if player and getElementType(player) == "player" then So I am not sure if I am looking at the right code. Do no attach functions which are inside of other functions directly in an addEventHandler! They are not destroy able without accessing the globals: _G The function will be created infinity times! I recommend you to create a function outside of the block. addCommandHandler("putaspiketotheground", -- function(player, source) if (player) then local px, py, pz = getElementPosition ( player ) local rz = getPedRotation ( player ) local distance = 5 local x = distance*math.cos((rz+90)*math.pi/180) local y = distance*math.sin((rz+90)*math.pi/180) local b2 = 15 / math.cos(math.pi/180) local nx = px + x local ny = py + y local nz = pz - 0.8 local provz = rz + 90 local spike = createObject ( 2892, nx, ny, nz, 0.0, 0.0, provz) local x, y, z = getElementPosition(player) local x2, y2, z2 = getElementPosition(spike) local blow = createColSphere(x2, y2, z2, 3) addEventHandler("onColShapeHit",blow,function (player) if player and getElementType(player) == "player" then local pveh = getPedOccupiedVehicle(player) if isPedInVehicle(player) then if (getTeamName(getPlayerTeam(player)) ~= "robber" then return false end setVehicleWheelStates(pveh,1,1,1,1) setVehicleColor( pveh, 247, 39, 157 ) end end end) end end)
-
Not sure, maybe you can disable the streamer for it. https://wiki.multitheftauto.com/wiki/SetElementStreamable Check the output of the function to validate if it is actually doing something.
-
If you every player to see the same objects, then serverside is the right thing to do. If you do not know how to work with tables then you can also work with elementdata, but it is a little bit dirtier. And can actually make it very dirty if it isn't removed. Use a flowchart to make the decision how you want to build it. Ask yourself this question: Which parts do I want to do serverside and which ones clientside?
-
Create and destroy it clientside. I recommend you to create a flowchart if you have no idea how to build it. Which is actually very close to the code you are going to build, but at a more understand able level. You can later use that to inform yourself or your helper to build the components of the code.