-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
function renderMyText ( ) dxDrawText ( arguments ) end addCommandHandler ( "render", function ( ) addEventHandler ( "onClientRender", root, renderMyText ) -- Begin rendering our text end ) addCommandHandler ( "stoprender", function ( ) removeEventHandler ( "onClientRender", root, renderMyText ) -- Stop rendering our text end ) That's an example.
-
Well, I thought that was obvious.
-
If you add the event only when you need to, then no.
-
You add the event handler to render it.
-
You can't use dxDrawText without onClientRender/onClientPreRender/onClientHUDRender.
-
function buyVeh ( source ) local money = getPlayerMoney ( source ) if ( money < 10000 ) then outputChatBox ( "You do not have enough money to purchase this car", source, 255, 0, 0 ) -- You forgot about 'outputChatBox' else newveh = createVehicle ( 589, 558.748046875, -1265.380859375, 17.2421875 ) warpPedIntoVehicle ( source, newveh ) takePlayerMoney ( source, 10000 ) outputChatBox ( "You have successfully bought a club!", 0, 255, 0 ) end end addCommandHandler ( "buyvehclub", buyVeh ) -- addCommandHandler doesn't have attachedTo argument.
-
local timers = { } -- Inserting a new timer to our table local timer = setTimer ( arguments ) table.insert ( timers, timer ) -- Killing all the timers: for index, timer in ipairs ( timers ) do if isTimer ( timer ) then killTimer ( timer ) end timers [ index ] = nil end
-
setElementData ( veh, "vehiclePrice", 50000 )
-
Is a table where the markers are stored.
-
-----CREATE THE VEHICLES----- vehcreates = { [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863 ), [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) } -----CREATING THE MARKERS------ vehmarkers = { [1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96), [2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96), [3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96), [4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96), [5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96), [6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96), [7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96), [8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96), [9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), [10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96), [11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), [12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), [13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), [14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), [15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) } local link = { } -----SETTING PARENT TO THE MARKERS----- ele = createElement ( "markers" ) for i, v in ipairs ( vehmarkers ) do setElementParent ( v, ele ) setElementAlpha ( v, 50 ) link [ v ] = vehcreates [ i ] end addEventHandler ( "onClientMarkerHit", root, ---THIS HERE!!!! function ( hitElement ) if ( hitElement == localPlayer ) then local vehicle = link [ source ] if ( vehicle ) then outputChatBox ( "This vehicle is a ".. getVehicleName ( vehicle ) .."!" ) end end end ) Some of the vehicles from the table don't match the index of the marker.
-
Read what CrystalMV said.
-
That's what I noticed after fixing his error.
-
-----CREATE THE VEHICLES----- vehcreates = { [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863 ), [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) } -----CREATING THE MARKERS------ vehmarkers = { [1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96), [2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96), [3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96), [4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96), [5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96), [6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96), [7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96), [8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96), [9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), [10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96), [11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), [12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), [13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), [14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), [15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) } -----SETTING PARENT TO THE MARKERS----- ele = createElement ( "markers" ) setElementParent(vehmarkers[1], vehcreates[1] ) addEventHandler("onClientMarkerHit", vehmarkers[1], ---THIS HERE!!!! function ( ) local vehicle = getElementParent ( source ) if ( vehicle ) then outputChatBox ( "This vehicle is a ".. getVehicleName ( vehicle ) .."!" ) end end ) for i, v in ipairs ( vehmarkers ) do setElementParent ( v, ele ) setElementAlpha(v, 50) end
-
local guiAnimations = { } function guiFade ( gui, state ) if ( not guiAnimations [ gui ] ) then guiAnimations [ gui ] = { } end if isTimer ( guiAnimations [ gui ].fadeIn ) then killTimer ( guiAnimations [ gui ].fadeIn ) guiAnimations [ gui ].fadeIn = nil end if isTimer ( guiAnimations [ gui ].fadeOut ) then killTimer ( guiAnimations [ gui ].fadeOut ) guiAnimations [ gui ].fadeOut = nil end if ( state == "out" ) then guiAnimations [ gui ].fadeIn = setTimer ( guiFade, 50, 1, gui, state ) local alpha = guiGetAlpha ( gui ) guiSetAlpha ( gui, ( alpha - 0.1 ) ) if ( alpha == 0 ) then guiSetVisible ( gui, false ) killTimer ( guiAnimations [ gui ].fadeIn ) guiAnimations [ gui ] = nil end elseif ( state == "in" ) then guiSetVisible ( gui, true ) guiAnimations [ gui ].fadeOut = setTimer ( guiFade, 50, 1, gui, state ) local alpha = guiGetAlpha ( gui ) guiSetAlpha ( gui, ( alpha + 0.1 ) ) if ( alpha == 1 ) then killTimer ( guiAnimations [ gui ].fadeOut ) guiAnimations [ gui ] = nil end end end Use that function for fading in and out GUI elements. Example: local window = guiCreateWindow ( arguments ) guiFade ( window, "out" )
-
[IMPORTANTE]Usuario en MTA
Castillo replied to Tomas's topic in Ayuda relacionada al cliente/servidor
Lo que queres es cambiar el nombre de una cuenta en tu servidor? que sistema de cuentas usas? el original del MTA? -
[IMPORTANTE]Usuario en MTA
Castillo replied to Tomas's topic in Ayuda relacionada al cliente/servidor
Decis la cuenta en el servidor? si de eso hablas te digo que eso depende de cada servidor. -
I edited the code to add comments so you may understand it better.
-
My mistake, I didn't notice that error.
-
local markers = { } -- Define a table. local vehicle = createVehicle ( ) -- Create a vehicle. local marker = createMarker ( ) -- Create a marker. markers [ marker ] = vehicle -- Add marker to the table with the value of the vehicle element. addEventHandler ( "onMarkerHit", root, function ( ) local vehicle = markers [ source ] -- Get the vehicle element using the marker as index for the table. if ( vehicle ) then -- If there is a vehicle... -- Do your thing here end end ) Is that what you meant?
-
The problem is that "bindTheKeys" function is never executed. Also, bindKey client side has no player argument. addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) setTimer ( function ( ) sound = playSound ( "winsound.mp3" ) bindKey ( "space", "down", stopMusic ) end ,2000, 1 ) end ) function stopMusic ( key, keyState ) if ( keyState == "down" ) then stopSound ( sound ) end end
-
if not isPlayerInTeam( Player, 'Civil' ) then Your argument name is "player" not "Player".
-
https://bugs.multitheftauto.com/view.php?id=5015