myonlake
Members-
Posts
2,312 -
Joined
-
Days Won
40
Everything posted by myonlake
-
It doesn't make any sense, because the script never executes setElementFrozen on the player element - only on a possible vehicle element, which is very awkward. It does use isElementFrozen though, but yeah, that's not much use when it doesn't even use the native functionality.
-
Place it after the point where it creates the vehicle and use the vehicle element as the first argument to those three. Here is a cool thing to make stuff easier for you. local vehicles = { { -- Mission 1 [ 470 ] = { -- Patriot { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 } }, barracks = { { -2490.8999, 741.4, 35.6, 0, 0, 180 }, { -2486.3999, 741.4, 35.6, 0, 0, 180 }, { -2482.0001, 741.4, 35.6, 0, 0, 180 }, { -2477.8000, 741.4, 35.6, 0, 0, 180 } }, mesa = { { -2473.3005, 741.2, 35.2, 0, 0, 180 }, { -2468.8999, 741.2, 35.2, 0, 0, 180 }, { -2464.6001, 741.2, 35.2, 0, 0, 180 }, { -2460.3005, 741.2, 35.2, 0, 0, 180 } }, ambulance = { { -2429.6001, 741.2, 34.7, 0, 0, 180 }, { -2425.1999, 741.2, 34.7, 0, 0, 180 }, { -2421.0005, 741.2, 34.7, 0, 0, 180 } }, bobcat = { { -2408, 741.2, 35, 0, 0, 180 }, { -2412, 741.2, 35, 0, 0, 180 }, { -2416, 741.2, 35, 0, 0, 180 } }, vincent = { { -2405, 725, 35, 0, 0, 0 }, { -2410, 725, 35, 0, 0, 0 }, { -2415, 725, 35, 0, 0, 0 }, { -2420, 725, 35, 0, 0, 0 } } } } function loadMissionVehicles( missionID, vehicleName ) local missionID = missionID or 1 if ( not vehicles[ missionID ] ) then return end local function createMissionVehicle( vehicleID, vehicleName, vehicleData ) local vehicleName = tostring( vehicleName ) local vehicleModel = tonumber( vehicleName ) or getVehicleModelFromName( vehicleName ) if ( ( not tonumber( vehicleName ) ) and ( not vehicleModel ) ) or ( type( vehicleData ) ~= "table" ) then return end local vehicle = createVehicle( vehicleModel, unpack( vehicleData ) ) if ( vehicle ) then toggleVehicleRespawn( vehicle, true ) setVehicleRespawnDelay( vehicle, 10000 ) setVehicleIdleRespawnDelay( vehicle, 60000 ) setElementData( vehicle, "missions:vehicles.id", vehicleID, true ) setElementData( vehicle, "missions:vehicles.mission_id", missionID, true ) vehicles[ missionID ][ tonumber( vehicleName ) or vehicleName ][ vehicleID ].vehicle = vehicle return vehicle end return false end if ( not vehicleName ) then for vehicleName,theseVehicles in pairs( vehicles[ missionID ] ) do for id,vehicleData in pairs( theseVehicles ) do createMissionVehicle( id, vehicleName, vehicleData ) end end return true else if ( vehicles[ missionID ][ vehicleName ] ) then for id,vehicleData in pairs( vehicles[ missionID ][ vehicleName ] ) do createMissionVehicle( id, vehicleName, vehicleData ) end return true end end return false end if ( loadMissionVehicles( 1 ) ) then for _,models in pairs( vehicles[ 1 ] ) do for _,data in pairs( models ) do if ( isElement( data.vehicle ) ) then print( getVehicleName( data.vehicle ) ) end end end end You basically have a table which contains missions (the first level), then after that you have vehicle models, which you can name as vehicle model ID and name. It creates the vehicles inside those items. But yeah, this is some cool stuff and if you want to use this, go ahead. It is probably better to stick with your own code though, unless you know what the above script does. So, with your code I'd probably do something like the following. local vehicles = { { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- ---------------------------------------------------------------- { 433, -2490.8999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2486.3999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2482.0001, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2477.8000, 741.4, 35.6, 0, 0, 180 },---Barrack--- ---------------------------------------------------------------- { 500, -2473.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2468.8999, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2464.6001, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2460.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- ---------------------------------------------------------------- { 416, -2429.6001, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2425.1999, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2421.0005, 741.2, 34.7, 0, 0, 180 },---Ambulance--- ---------------------------------------------------------------- { 422, -2408, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2412, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2416, 741.2, 35, 0, 0, 180 },---Bobcat--- ---------------------------------------------------------------- { 540, -2405, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2410, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2415, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2420, 725, 35, 0, 0, 0 } ---Vincent--- } for i,data in pairs( vehicles ) do local vehicle = createVehicle( unpack( data ) ) if ( vehicle ) then toggleVehicleRespawn( vehicle, true ) setVehicleRespawnDelay( vehicle, 10000 ) setVehicleIdleRespawnDelay( vehicle, 60000 ) setElementData( vehicle, "missions:vehicles.id", i, true ) addEventHandler( "onVehicleEnter", vehicle, mission ) vehicles[ i ].vehicle = vehicle else outputDebugString( "Could not create vehicle ID " .. i .. ". Continuing...", 2 ) end end
-
You haven't defined the source for the timer, that is why. function mission( ) if ( not isElement( source ) ) or ( getElementType( source ) ~= "player" ) then return end setCameraMatrix( source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316 ) setTimer( function( source ) setCameraTarget( source, source ) end, 5000, 1, source ) end addEventHandler( "onPlayerLogin", root, mission ) For the second one, you have to loop through the whole table in order to do that. local vehicles = { { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- ---------------------------------------------------------------- { 433, -2490.8999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2486.3999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2482.0001, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2477.8000, 741.4, 35.6, 0, 0, 180 },---Barrack--- ---------------------------------------------------------------- { 500, -2473.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2468.8999, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2464.6001, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2460.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- ---------------------------------------------------------------- { 416, -2429.6001, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2425.1999, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2421.0005, 741.2, 34.7, 0, 0, 180 },---Ambulance--- ---------------------------------------------------------------- { 422, -2408, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2412, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2416, 741.2, 35, 0, 0, 180 },---Bobcat--- ---------------------------------------------------------------- { 540, -2405, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2410, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2415, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2420, 725, 35, 0, 0, 0 } ---Vincent--- } for i,data in pairs( vehicles ) do local vehicle = createVehicle( unpack( data ) ) vehicles[ i ].vehicle = vehicle end
-
It doesn't seem to setElementFrozen the player element. Add that in the code.
-
If that returns false, then you must make sure you use setElementFrozen when you freeze a player. It should work right now.
-
onClientKey might help you in this case.
-
Re-create the file and copy the contents from the old file. It has something to do with the file name being corrupted, has happened to me before.
-
If I understand correctly, you want to have multi-language phrases. If that's the case, I wouldn't use neither. I'd use just standard files that contain a table of phrases. This way translators are able to edit these quite easily and you can strip it all in PHP to make a web application for translators and generate a new Lua file on each save. I don't like fetching irrelevant information continuously from the database, especially stuff like translations that could be saved in files for easier accessibility. Many translation programs also allow importing of some specific type of files, including files that consist out of arrays, which contains different nodes for different sub-pages or so, and then within those they have a node for events and common phrases. And then there's XML and JSON. P.S. Doesn't matter where you trigger your MySQL queries, it's the same speed and efficiency everywhere especially if they're all located in a single box and so hosted locally. And I wouldn't use mysql_query, or that module anyway. Use the standard database functionality built within MTA:SA instead.
-
To your earlier post: yes, you got the idea. The reason for doing the square bracket thing is if you have multiple different numbers like 2, 5, 8, if you now call myTable[ 5 ], it will return nil, because there is no key for that. So you'd always have to know the key beforehand you do your stuff, that's when it's useful to assign values as keys instead of the standard opposite. If you don't assign a key for each value, the keys would be automatically assigned from 1 and upwards. So that's why it's not practical to use it to detect if a weapon ID is found in your table since it would now return invalid data each time relative to the table's default indexing from 1 and upwards.
-
The difference is that the code I gave you sets 2, 3, 4, etc. as keys. If I made it like you showed, it would not work because I am comparing keys, not values. local myTable = { [ 1 ] -- This is a key = true -- This is a value } -- Can we find an item with key 1 or not if ( myTable[ 1 ] ) then -- ... end So, to do something like that you have to use a function that instead of checking keys, it checks for values. The second example of mine above shows the function and how it works (isValueInTable). And yes, you can put it to whatever you want, however, you should not put it to false or nil. Otherwise it will return else in that if-statement, because it expects a true/accessible value. If you wanted to disable weapon slot 5, then switch [ 5 ] = true to [ 5 ] = false. Table.sort sorts the table values alphabetically by default, so if you had values: 9, 2, 5, 7, 3 - it would return them as 2, 3, 5, 7, 9. You can also do this in reverse or do more HC stuff by adding your own custom function as the third argument.
-
Aha, well, your code would not work the way you would want it to. You are sorting the table, not checking for value collision. Like I showed in my example, it would work like this: local myTable = { [ 2 ] = true -- We create an item within the table, its key is set to 2, and its value is set to true (it can be anything, a string or an integer or whatever) } local myValue = 1 -- I want to search for an item with a key defined as 1 if ( myTable[ myValue ] ) then -- Check if that key is defined in myTable print( "We found that value from the table." ) -- We found that key else print( "We could not find that value from the table." ) -- We were unable to find that key, meaning it is not defined in the table end So, in your case you would do it like this: local weapons = { [ 2 ] = true, [ 3 ] = true, [ 4 ] = true, [ 5 ] = true, [ 6 ] = true, [ 7 ] = true, [ 8 ] = true, [ 9 ] = true } function yourFunctionName( attacker, weapon, bodypart, loss ) if ( weapons[ weapon ] ) then -- We found that weapon from the table else -- We did not find that weapon from the table end end
-
The reason why I use the myValue variable is to find out if that myValue exists as a key inside myTable. The key in the tables are basically defined between the square brackets [ ], so in my example it would not find such key, because there is no [ 1 ] defined in the table. The second one is basically a loop through the table and it checks if that specified value is the same as the one currently looping through on. I edited my code with some comments, you should check them out.
-
That's not the reason why they made them pickups. You can remove markers as well, but you cannot assign object models as the marker style.
-
You should check this Lua article out: http://lua-users.org/wiki/TablesTutorial This is one approach to do what you are looking for: local myTable = { [ 2 ] = true, [ 3 ] = true, [ 4 ] = true, [ 5 ] = true, [ 6 ] = true, [ 7 ] = true, [ 8 ] = true, [ 9 ] = true } local myValue = 1 if ( myTable[ myValue ] ) then -- Check if myValue exists as a key inside the myTable table print( "We found that value from the table." ) -- Print a success message if found else print( "We could not find that value from the table." ) -- Print a fail message if not found end And another approach to that: local function isValueInTable( theTable, theValue ) -- Initialize a local function for isValueInTable, which takes in two arguments: a table and a value if ( theTable == nil ) or ( theValue == nil ) or ( type( theTable ) ~= "table" ) then return false end -- If an argument is invalid, then just return false right away for _,v in pairs( theTable ) do -- Loop through the specified table and define v as the item value (we "ignore" the key by making it an underscore, but it could be anything, simply put) if ( v == theValue ) then -- If the current table item's value is the same as the value I just passed in... return true -- ... then just return true end end return false -- If something went wrong or not found, then just return false end local myTable = { [ 2 ] = true, [ 3 ] = true, [ 4 ] = true, [ 5 ] = true, [ 6 ] = true, [ 7 ] = true, [ 8 ] = true, [ 9 ] = true } local myValue = 1 if ( isValueInTable( myTable, myValue ) ) then -- Run through the above isValueInTable function with the above myTable table and myValue value print( "We found that value from the table." ) -- Print a success message if found else print( "We could not find that value from the table." ) -- Print a fail message if not found end The first one is perhaps simpler to understand, since you are comparing your value with the table keys. If you can find an item with that corresponding key then return true, otherwise false. The second one is perhaps easier to write. That way you will only need to type in your values in the table without using keys. Then you just loop through the table and see if you can find any item with that specific value. Again the same method of returning true or false. The upside in using the first method is that you are able to assign them specific values, this way you can switch those table items on and off by simply changing true to false (which makes it automatically return false in the if-statement) - or if you want to assign it a string or an integer representing something useful that you will use later on in your code it will return true if it has anything else but null or true as a value. The second method isn't really ideal for such usage. But really it's up to your needs. If you want to keep it nice and clean and something that you are easily able to modify, then perhaps the first method. Otherwise go for the second one (especially if you have a lot of values and you don't need to modify them or so).
-
I hope you understand that there is nothing positive in using easing in a timer. It's going to be jumpy and simply won't work out as you think it would. The only proper way to use it without custom rendering is the moveObject functionality.
-
I doubt you can set the fire speed. Weapon range stands for how far the weapon is able to shoot bullets. Target range stands for how far you are able to aim an entity at.
-
If you don't want to use the rendering functions, just use createObject, attachElements and moveObject in combination.
-
Make sure your ped has that weapon stat.
-
They're just to define different levels. Pro is the highest, poor is the lowest.
-
Poor, std (standard) and pro (professional) are weapon skill levels. The property names are in pure English and there's not much someone can explain better. Accuracy stands for how well the weapon can hit the target without large spread from the muzzle position. Damage stands for how much the target receives health loss, which lowers the target's health, obviously. Move speed stands for how fast you can move with the weapon equipped on you. Target range stands for how how far you are able to aim an entity at. You can use these and many other properties by simply changing the third argument of the setWeaponProperty function to whatever property you want to change. The first argument is for the weapon ID, the second one is for which weapon skill you want to place the stat on, the fourth one is for the property value.
-
NOki: As a pro-tip of the day; use indentation when doing code. I know you know this, but your code isn't doing so. It's important, because it makes code readable.
-
Download a new version of roleplay-accounts/s_death.lua, it's a possible fix for this.
-
You can't really mask the default San Andreas HUD. You can't even get the image out of it. For radar map, there's a Lua-replacement built from ground up, though. Not sure which is the best one, but there are many when you search for "radar" in community.multitheftauto.com (maybe something is already included with default MTA package as well - don't know) He didn't want that. He wanted to make his own, and that is possible by masking.