Jump to content

# novo

Members

325

## About novo

• Birthday 02/05/1998

## Details

• Location
United States

## Recent Profile Visitors

911 profile views

0

1. ## How to sort a table by value

local players = getElementsByType('player') table.sort( players, function(a, b) return getPlayerMoney(a) > getPlayerMoney(b) end )
2. ## Hunter Camera Problem

ShowPlayerHudComponent
3. ## getCursorMoveOn

First error is caused by the function getCursorMoveOn, as it does not return any value in case isCursorShowing() returns false at line 2. Second error is because outputChatBox only accepts a player as second argument server-side (visibleTo), whilst client does not and thus expects a number (r).
4. ## [Solved] Table inside of a table

You get that error because number is an undefined variable, and thus equals to nil. Now, you can do table.test with alphabetical keys only - you have to do table[123] for numbers. local table = { test = 'a', ['something'] = 'b', [1] = 'c', ['test2'] = 'd', } print(table.test) -- a print(table.something) -- b print(table[1]) -- c print(table['test2']) -- d ---------------------------- local players = {} local player = getRandomPlayer() players[player] = { name = getPlayerName(player), } print(players[player].name)
5. ## Short lua question

Only predefined variables are these, and thus what you are trying to achieve is not possible.
6. ## Help with Collision calculator

It indeed does not check if given projectile has a target, but still does work with static elements. Now, you might instead do a per-frame check and find out whether an element interferes with the projectile, or through loop as in your code. I would do some sort of sight check around the projectile and check if there is any nearby approaching element that might end up colliding given its velocity within a certain distance. Also, I had a few issues calculating what the final position is going to be and dividing by 10 worked just fine there for testing, though you might want to replace this with proper calculations.
7. ## setElementVelocity backwards

local vx, vy, vz = getElementVelocity(veh) setElementVelocity( veh, -vx, -vy, vz )
8. ## Help with Collision calculator

function collision (projectile) local time = projectile.counter / 10 local velocity = projectile.velocity velocity = velocity * time -- local position = projectile.position + velocity local sight, x, y, z = processLineOfSight( projectile.position, position, true, true, true, true, true, true, true, false, nil, true ) position = (sight and Vector3(x, y, z)) or position -- Marker( position, 'corona', 3 ) end addEventHandler( 'onClientProjectileCreation', root, function() collision(source) end )
9. ## table.sort problem

toptimes = { {32423,"nickname"}, {12313,"nickname"}, }; table.sort(toptimes, function(a, b) return a[1] < b[1] end ) table.sort basically needs minimum two values inside the input table, toptimes in this case, and then does compare these values and thus determines their order. We have got two sub-tables inside toptimes, and those tables are the ones being compared through table.sort. This is why [1] is used, we retrieve those table's index 1 value and then check which one is smaller/bigger. However, here is a similar thing I found you may have a look at.
10. ## Anti teamkill

addEventHandler("onClientVehicleDamage", root, function(attacker) if getElementModel(source) ~= 432 then return end -- avoid this function from executing in case the vehicle that is being damaged is not a tank(?) if getElementModel(getPedOccupiedVehicle(attacker)) == 432 then -- in case attacker's model is equal to 432 if attacker == localPlayer then -- in case the attacker tank's driver is the localPlayer outputChatBox("Don't attack friendly tanks!", 255, 0, 0) -- a warning message is output end cancelEvent() end end ) What about this? You could've either way tried to modify the code on your own, lol.
11. ## unloading code which was loaded with loadstring

I do not know, you probably ran those resources before. Err.. either way I did not check it out for a long while, they probably implemented it - quite a big security hole though.
12. ## unloading code which was loaded with loadstring

That is what I meant, you can not manipulate files outside a resource itself.
13. ## unloading code which was loaded with loadstring

Are those files even being written/created? I am not sure it is possible to actually write into a different resource location from where you are running the functions.
14. ## Anti teamkill

It is not working because you are using onClientVehicleDamage's arguments in a wrong way. Either way, you are using attacter at isPedInVehicle - a non-defined variable. addEventHandler("onClientVehicleDamage", root, function(attacker) if getElementModel(source) ~= 432 then return end -- avoid this function from executing in case the vehicle that is being damaged is not a tank(?) if getElementModel(attacker) == 432 then -- in case attacker's model is equal to 432 if getVehicleController(attacker) == localPlayer then -- in case the attacker tank's driver is the localPlayer outputChatBox("Don't attack friendly tanks!", 255, 0, 0) -- a warning message is output end cancelEvent() end end )
15. ## unloading code which was loaded with loadstring

Well, you can this way avoid loaded scripts from executing your actual wrappered functions. Which means that if you have set a wrapper to _triggerServerEvent and not using an environment, it can be called from inside the loaded script. And you are avoiding this by using an own environment.
×

• #### Social Media

×
• Create New...