-
Posts
6,088 -
Joined
-
Last visited
-
Days Won
215
Everything posted by IIYAMA
-
I am not sure if you can call remote to yourself. But the error 404 means not found. So try to ping to the ip, just to check if it available. Also the port is important, just to figure out which port you should use: function playerChat ( message, type ) for port=22000, 22030 do callRemote ( "87.229.77.40:" .. port, getResourceName(getThisResource()), "outputChatBoxRemote", finishedCallback, getPlayerName(source), message, type, getServerPort() ) end end
-
dbQuery + dbPoll for sql.
-
Use the aggregate COUNT function: https://dev.mysql.com/doc/refman/5.7/en/counting-rows.html Here you have more related functions: https://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html
-
Render events enhancement Having a lot of render events in your resource? Easier attach and remove? Or do you want to pass arguments in to a function which is attached to a render event? Then this might be something for you. Syntax: addRenderEvent bool addRenderEvent(function functionVar [, string eventName, arguments ...]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Arguments you can pass to the target function. (which isn't possible with the default addEventHandler + onClientRender function) Returns: true when added, and false otherwise. Syntax: removeRenderEvent bool removeRenderEvent(function functionVar [, string eventName]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Returns: true if found + removed, and false otherwise. (Not recommended to execute this function every frame > performance) onClientPreRender + timeslice If you use "onClientPreRender", just like the default event, it will pass the timeSlice to the attached/targetted function. https://wiki.multitheftauto.com/wiki/OnClientPreRender I am not sure if attached is the right word for this example, because it isn't really attached to the event. It is saved in a table which gets looped every frame. Performance Is this code bad for performance? The answer to that is NO. I ran a test for it, and it seems that addRenderEvent used less CPU AFTER adding the events. (addRenderEvent: 31% CPU, addEventHandler 99/100% CPU) Adding the event will probably use more CPU, but that is only one execution. Feel free to re-test this example, I am interested how it would perform on your pc's. Performance test code (Not the source code ) Source code:
- 21 replies
-
- 12
-
-
-
- onclienthudrender
- onclientprerender
-
(and 1 more)
Tagged with:
-
if ( staffcar[getElementModel(source)] ) and ( not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") )) then Or even better if you do not want to be confused: if staffcar[getElementModel(source)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) then I prefer the last one. Only wrapping code between (...) when really needed.
-
Did you found another solution?
-
https://wiki.multitheftauto.com/wiki/GetScreenFromWorldPosition (Put high edgeTolerance) https://wiki.multitheftauto.com/wiki/DxDrawLine
-
I know, but you did both, so maybe that could have caused problems. I am not an expert with shaders, so everything is maybe this and maybe that.?
-
addEventHandler ( "onPlayerLogin", root, function (_, theCurrentAccount ) setPlayerName ( source, getAccountName(theCurrentAccount) ) end) https://wiki.multitheftauto.com/wiki/GetAccountName string getAccountName ( account theAccount ) https://wiki.multitheftauto.com/wiki/OnPlayerLogin Parameters thePreviousAccount: The account the player was logged into before theCurrentAccount: The account the player logged into just now Source The source of this event is the player element that just logged in.
-
@Vuzimir This is what I get for trying to help you? Really? REALLY? Don't get paranoid, I have already more than enough posts and I am replying to YOU in MY FREE TIME. You are not even editing the z offset. It is set to 0. So then why would yours look so :~ty? The only thing I can think of, is either your shader file or your GPU. But if you have edited it, then it is really stupid to post code where it is not edited. dxSetShaderTransform ( myShader4, -30, 0, -2.7, 0, 0, 0, false, 0, 0, false) bool dxSetShaderTransform ( element theShader, float rotationX, float rotationY, float rotationZ, [ float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, float rotationCenterOffsetZ = 0, bool bRotationCenterOffsetOriginIsScreen = false, float perspectiveCenterOffsetX = 0, float perspectiveCenterOffsetY = 0, bool bPerspectiveCenterOffsetOriginIsScreen = false ] )
-
The very basic shader works perfect for me: dxSetShaderTransform (mapShader, 0, -60, rotation) texture gTexture; technique IIYAMA { pass P0 { Texture[0] = gTexture; } }
-
You do not have to write the loop yourself. Add the custom function I wrote for you on top of your script. function isElementWithinMarkers (element, markers) for i=1, #markers do if isElementWithinMarker(element, markers[i]) then return true end end return false end And just apply this part: function RepairVehicle( hitPlayer, matchingDimension ) if hitPlayer == getLocalPlayer() and matchingDimension == true then local theVehicle = getPedOccupiedVehicle( getLocalPlayer() ) local VehicleHealth = getElementHealth( theVehicle ) local RepairHealth = math.floor( VehicleHealth ) function Repair() --if isElementWithinMarker( getLocalPlayer(), RepairMarker[1] ) then -- old -- >>>>>>>>>>>>>> if isElementWithinMarkers( getLocalPlayer(), RepairMarker ) then -- new -- <<<<<<<<<<<<<< if RepairHealth < 1000 then RepairHealth = RepairHealth + 1 setElementHealth( theVehicle, RepairHealth ) else fixVehicle( theVehicle ) playSFX( "script", 11, 1, false ) end else killTimer( RepairTimer ) end end if VehicleHealth < 1000 then RepairTimer = setTimer( Repair, 100, 1001 - math.floor( VehicleHealth ) ) end end end
-
function isElementWithinMarkers (element, markers) for i=1, #markers do if isElementWithinMarker(element, markers[i]) then return true end end return false end if isElementWithinMarkers( getLocalPlayer(), RepairMarker ) then Syntax: bool isElementWithinMarkers( element theElement, table markers ) By looping through all markers and check if the element is in one of the markers. If that is true, then break the loop with the return keyword and send true back. Note: (different name) isElementWithinMarker + s
-
I think that it depends on the shader. Because tocolor didn't work with the shaders I tried.
-
Afaik different shaders aren't linked. The only thing I learned from shaders is that tocolor behaves different when using shaders. Put it on 255, 255, 255 and let the shader do the rest. This might also giving some problems if the shader isn't handling it right: currentHealth = (theHealth-250)/750 >>>> 0 health > -250 > / 750 > * 180 = -60 if currentHealth < 0 then currentHealth = 0 end
-
That is a good question. But it isn't about checking if something is between to elements. It is about checking if a position(colshap) is between a line(shooting line). https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire Parameters int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement, float startX, float startY, float startZ Start line | | | ( Colshape ) | | | End line The getDistanceBetweenPointAndSegment3D function I gave you calculates the distance between a line and a point. If the distance is smaller than the colshape size, it is a hit.
-
Wiki knows: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#Edit_Fields
-
I just gave you a solution for detecting shooting in round colshaps, be happy with it...
-
If is it a round colshape:
-
Too much code, what do you expect? I am not even going read it. The scoreboard will only update when the elementdata is changed. So at every place the gui is changed you have to set the elementdata.
-
invisibleAdmins = {} iprint(invisibleAdmins) -- table (empty) Interaction with the table: invisibleAdmins[getPlayerSerial(player)] = true iprint(invisibleAdmins) -- table {["<serial>"] = true} After using this: invisibleAdmins = invisibleAdmins[getPlayerSerial(player)] iprint(invisibleAdmins) -- true You just deleted your table. (not good) Solution: local isInvisible = invisibleAdmins[getPlayerSerial(player)] iprint(invisibleAdmins) -- table {["<serial>"] = true} iprint(isInvisible) -- true
-
Check the examples of this function: https://wiki.multitheftauto.com/wiki/GetElementMatrix No complex math required. Just getting 2x the offset of the vehicle and using it as camera start and end point.
-
Better not knowing, it is a computer notation which is not very useful for us humans. And it is the raw output after all. Better save RGBA in a table as input and use that. The only reason for learning this notation is if you are working with a complexes non script language, where that knowledge is required.