This is a simple math command that I made simply because it seemed quite handy.
It lets you do a few basic things any calculator would let you do but the main benefit of this was for the people who have super low-end computers, a couple people on my server lagged like crazy and often crashed their entire system when alt-tabbing out so I made this command so they didn’t have to
Im not that great at coding lua so if you could improve it do post a reply
Install:
- paste it into any client script and restart that resource
how to use:
- /sum type value1 value2 (e.g /sum add 10 10 - you will get 20 obviously)
- /sum random
-- Simple Math command | made by Envious
RegisterCommand('sum', function(source, args)
if args[3] then -- I dont think im doing this bit right but it works for now
if args[1] == "add" then
num = args[2] + args[3]
TriggerEvent('chatMessage', "The value is", {128, 1280, 128}, num)
elseif args[1] == "div" then
num = args[2] / args[3]
TriggerEvent('chatMessage', "The value is", {128, 1280, 128}, num)
elseif args[1] == "mult" then
num = args[2] * args[3]
TriggerEvent('chatMessage', "The value is", {128, 1280, 128}, num)
elseif args[1] == "perc" then
num = args[2] / 100 * args[3]
TriggerEvent('chatMessage', "The value is", {128, 1280, 128}, num)
elseif args[1] == "sub" then
num = args[2] - args[3]
TriggerEvent('chatMessage', "The value is", {128, 1280, 128}, num)
end
elseif args[1] then
if args[1] == "random" then
math.randomseed(GetGameTimer())
math.random(); math.random(); math.random();
num = math.random(1000000,9000000) -- got to make it authentic-ish
TriggerEvent('chatMessage', "The random number ", {128, 1280, 128}, "SA" ..num.. "2018") --we use this for Gun serial numbers on our server
else
TriggerEvent('chatMessage', "^8[System]^0: ^3do /sum div/mult/add/random or perc and then your first and second argument")
end
else
TriggerEvent('chatMessage', "^8[System]^0: ^3do /sum div/mult/add/random or perc and then your first and second argument")
end
end)