hey so i am trying to learn .lua and i am very new a couple days old i would say and i have been trying to make a script that you could make someone explode for troll reasons
example /boom (playerid) and then they would go boom
I would need help because i have made a script and it does not work. here is the code i have used
RegisterCommand(‘boom’, function ()
PlayerPedId("") AddEventHandler(AddExplosion)
end) — /boom
i am thinking maybe its because the addexplosion needs to be something else i really dont know someone pls help me and try to explain it
fx_version 'cerulean'
game 'gta5'
server_script "server.lua"
server.lua:
RegisterCommand("boom", function(source, args)
local src = source
local target = next(args) and tonumber(args[1]) or src
target = GetPlayerName(target) and target or src
local coords = GetEntityCoords(GetPlayerPed(target))
AddExplosion(coords.x, coords.y, coords.z, 9, 1.0, 1, 0, 1065353216, 0)
end) -- /boom
I am not sure where you got that code from and how you thought that would work… Take a look at some basic scripts and see how things actually work. Throwing function names into an event won’t do anything. You need to get values with functions, pass those values as variables to other functions, etc. Take note of the difference between your attempt (which will do nothing) and mine.
Because AddExplosion is a native function that receives a number of parameters.
AddExplosion(
x --[[ number ]],
y --[[ number ]],
z --[[ number ]],
explosionType --[[ integer ]],
damageScale --[[ number ]],
isAudible --[[ boolean ]],
isInvisible --[[ boolean ]],
cameraShake --[[ number ]]
)