Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make my function now run when it is an argument?

Asked by
tjtorin 172
6 years ago
01admins = {
02    ["tjtorin"] = true
03}
04prefix = ":"
05 
06function newCmd(plr,msg,name,code)
07    if admins[plr.Name] then
08        if msg == prefix..name then
09            spawn(code())
10        end
11    end
12end
13 
14--   FUNCTIONS
15------------------------
View all 25 lines...

1 answer

Log in to vote
0
Answered by 6 years ago

Simple. All you have to do is switch the parameters. There is no way to avoid running the kill function if you're going to include the function as an argument. Instead, do this:

01admins = {
02    ["tjtorin"] = true
03}
04prefix = ":"
05 
06function newCmd(player,msg,name,code)
07    if admins[player.Name] then
08        if msg == prefix..name then
09            spawn(code(player)) -- place arguments inside here, AFTER the checks are made.
10        end
11    end
12end
13 
14--   FUNCTIONS
15------------------------
View all 27 lines...
0
you need some return User#19524 175 — 6y
0
@laughablehaha But if I do that then I can't do functions that require different params tjtorin 172 — 6y
Ad

Answer this question