-
Posts
138 -
Joined
-
Last visited
Everything posted by Army@1
-
No, only lua is supported.
-
A: It would chuck the amount of wood a woodchuck could chuck, if woodchuck could chuck wood. Q: Why this emptiness?
-
local vehicles = { } local markers = { { 1560.77563, -1605.14966, 12.38281, "cylinder", 2, 0, 0, 255, 35 }, { 1584.11853, -1604.97534, 12.38281, "cylinder", 2, 0, 0, 255, 35 }, { 1604.44885, -1622.20142, 12.51332, "cylinder", 2, 0, 0, 255, 35 }, { 1559, -1653, 30, "cylinder", 2, 0, 0, 255, 35 }, { 1559, -1697, 30, "cylinder", 2, 0, 0, 255, 35 }, } for _,v in ipairs ( markers ) do createMarker ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [ 7 ], v [ 8 ], v [ 9 ] ) end addEvent ( "CreVehicePv", true ) addEventHandler ( "CreVehicePv", root, function ( id ) if ( isElement ( vehicles [ client ] ) ) then destroyElement ( vehicles [ client ] ) end local x, y, z = getElementPosition ( client ) vehicles [ client ] = createVehicle ( tostring ( id ) or 411, x + 2, y, z ) warpPedIntoVehicle ( client, vehicles [ client ] ) end ) addEventHandler ( "onMarkerHit", resourceRoot, function ( hitPlayer ) if ( getElementType ( hitPlayer ) == "player" ) and not ( isPedInVehicle ( hitPlayer ) ) then if ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "Policia" ) ) or ( getPlayerTeam ( hitPlayer ) == getTeamFromName ( "SWAT" ) ) then triggerClientEvent ( hitPlayer, "showGUIpv", hitPlayer ) else triggerClientEvent ( hitPlayer, "failvehcop", hitPlayer ) end end end ) addEventHandler("onVehicleExplode", root, function ( ) for k, v in pairs ( vehicles ) do if v == source then setTimer ( function ( ) destroyElement ( source ) vehicles [ k ] = nil end, 5000, 1, source ) end end end ) addEventHandler ( "onPlayerQuit", root, function ( ) if ( isElement ( vehicles [ source ] ) ) then destroyElement ( vehicles [ source ] ) vehicles [ source ] = nil end end ) Edit: Replaced 'vehicle' with 'vehicles' as reminded by Sasu.
-
No loop needed, just show my way. Ah, didn't check thoroughly. I guess source doesn't need a table unless he created one.
-
function VehicleExplode() for k, v in pairs(vehicles) do if v == source then setTimer(function() destroyElement(vehicles[source]) vehicles[source] = nil end, 5000, 1) end end end addEventHandler("onVehicleExplode", root, VehicleExplode)
-
function createRob() Marker = createMarker ( 252.3,-54.6,0.9, "cylinder", 1, 255, 255, 0, 170 ) setElementCollisionsEnabled( Marker, false ) bl = createBlipAttachedTo(Marker,49) outputChatBox( "Liquor store robbery is available. You can rob it in a wine glass blip.", root, 0, 255, 0 ) end addEventHandler("onResourceStart", resourceRoot,createRob) addEventHandler("onMarkerLeave",root, function ( player ) if ( source ~= Marker ) then return end if ( isPedInVehicle( player ) ) then return end if ( getTeamName(getPlayerTeam( player )) == "TeamName") then destroyElement( Marker ) destroyElement( bl ) randomMoney = math.random ( 5000, 20000 ) randomWanted = math.random ( 1, 6 ) givePlayerMoney(player,randomMoney) setPlayerWantedLevel ( player, randomWanted ) robPlayer = getPlayerName(player) outputChatBox("#ffffff[#00ff00ALARM!#ffffff] #c48027" .. robPlayer .. " #ff0000robbed a liquor store and got: #00ff00" .. tostring(randomMoney) .."$ #ff0000and #00ff00" .. tostring(randomWanted) .. "#ff0000 wanted stars.",root,0,255,0,true) setTimer( createRob, 600000, 1 ) end end ) Replace 'TeamName' with criminal team name, on line 17.
-
Wow, that really helped me. Thanks. Is that matrix one dimension i.e vector? If yes, why do we need matrice? we can easily work out the same problem by using vectors. And also vector3 have x, y, z then what does 3x2 or above matrices have i.e x,y,z,_,_,_?
-
Looks like there is some problem with attacker. function player_Wasted(_, attacker) outputDebugString(tostring(attacker)) if attacker then outputDebugString("true:2") if getElementType(attacker) == "player" then outputDebugString("true:3") outputChatBox(getPlayerName(attacker).. " killed " ..getPlayerName(source),getRootElement(),255,255,255) end end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) What does debugscript output?
-
Thanks, I think I got the vectors concept. If I did then setElementPosition( player, x, y, z) -- here x,y,z are vectors --so we can do x,y,z = vector3(0,0,0) setElementPosition( player, x, y, z) -- player will spawn at origin If I didn't, how can I use vectors to set element's position and velocity?
-
Maybe some custom resource is preventing it? If you have any, try stopping it.
-
Sorry for the bump
-
That's not logic. logically, It SHOULD show punch Icon but WILL show hunter Icon as I have edited it. I gave you the example to show how it is done and I expect you to edit the script as per your needs. If that is not what you asked then can you explain what you actually want?
-
Wow, really? Which functions would I have to use?
-
I believe, you just have to change the definitions file. To draw hunter icon when you killed player with your fist. In definitions.lua, under icons tables, Change this line [0] = "icons/fist.png" to [0] = "icons/hunter.png" -- actually fist And you are done. Adding a comment isn't necessary but will help you getting the originals one's(and changing them again) faster.
-
Haha, I thought you were inactive by looking at your profiles' last seen date. Naw. Just haven't been logging in as much lately due to work, however I am subscribed to the board and most of its topics, so I try my best to keep up with them. If ever in doubt, feel free to send me a PM or email. I'll always respond as soon as I'm able. That's good and yes, I will if I ever need to. Cheers.
-
Haha, I thought you were inactive by looking at your profiles' last seen date. Nice to hear it is not dead. Good luck guys
-
Looks like SugarD-x is not active currently but I would like to know if there is any updates or progress done on this. I hope it is not dead.
-
Thanks MrTasty. Oh, so the latter is useful and should be use when one may need to call the function inside the same function. Thanks. But can you please answer the following? Thanks both of you guys I am learning more and more.
-
Ah, I see. So we can pass local functions to other files by storing them in global variable. But regarding my earlier post, below is a reference. On here http://lua-users.org/wiki/ScopeTutorial It says. local function f() end -- is equivalent to local f f = function() end -- not local f = function() end
-
function helloWorld() print("Hello World") end -- is the same as helloWorld = function() print("Hello World") end -- Therefore, local function helloWorld() print("Hello World") end -- is the same as local helloWorld = function() print("Hello World") end A local function is just a function but assigned to a local variable. Thanks but my actual question was that both are similar,so when to use one or another. I already got that as I did a lot of research on it. BTW, function helloWorld() print("Hello World") end -- is the same as helloWorld = function() print("Hello World") end -- Therefore, local function helloWorld() print("Hello World") end -- is not local helloWorld = function() print("Hello World") end -- but local helloWorld helloWorld = function() print("Hello World") end If my understanding is to be believe. And @Revolt, thanks, I got that but when/where to use that in MTA scripting?
-
Thanks everyone for answering my confusions till now. Okay, the classes,objects,metatables concepts is appearing to be less confusing to me. The other thing which I find hard to understand is vectors and matrices.... What are these actually and how/when to use them? The MTA wiki seems to not help me.
-
Thanks guys for the explanations. BTW, in lua, whats the different between just 'function' and 'local function'. I know about variables but functions seems bit confusing to me as I hear we can called them outside scope too.
-
I get that but I am wondering why they overlap at around 70 (or 67 >= number) specifically. Is it related to 32 bit or 64 bit? And no, they don't overlap just in local table, I tried global too and got the same result.
-
What is it actually? is there limit to how much hma(hexademical memory address), RAM can handle? I made a simple script to find out if they can be repeated. What I did was that I made a for loop which create a table, gets its hma and then set the table to nil. The hma is stored in another table. But what I found is stange, the hma number is not repeated until it is near 70, the least I could found is 67. Is it how much my ram can handle or something like that? Here is a actual script which I made: function hmaRepChecker() print("Hexadecimal Memory Address repeatation checker has been started: ") local hma = {} local hmarep = {} local hmarepdata = {} print("(Start)Total HMA's: "..#hma) print("(Start)Total repeated HMA's: "..#hmarep) for i=1,100 do local tab = {} local tvalue = tostring(tab) local tud= tvalue:gsub("table: ", "") table.insert(hma,tud) for j=1,100 do if hma[i] == hma[j] and i ~= j then table.insert(hmarep,hma[i]) hmarepdatavalue = tostring("hma("..hma[i]..") repeated at: "..j.." and "..i) table.insert(hmarepdata,hmarepdatavalue) print(hmarepdatavalue) end end tab = nil end print("(Finish)Total HMA's: "..#hma) print("(Finish)Total repeated HMA's: "..#hmarep) end Change the for loop's i's and j's repeatation value(which is 100 currently) proportionally and see where they start repeating hma for you. Sorry, if its just simple or nonsense type of thing but I am curious.
-
hmm, that looks tough. I will look into it later. Meanwhile I am struggling with user-data. In lua, Whenever I create a table, for instance, and print it, it output something like 'table: 003DAF20'.In that, what is '003DAF20'? Is it a user-data? If not, what is it then? table-data? or something related to memory? i.e. function myTable() local atable = {} print(atable) end -- output: --table: 003DAF20 --what is '003DAF20'