Jump to content

createobject


[DMC]

Recommended Posts

is that the whole code?

if so you need a handler to call your functions

example:

onResourceStart, getRootElement(), 
function()
local x,y,z = getElementPosition( source )
createObject ( 2993, x, y, z, 120, 0, 0 )
outputChatBox("Party started", source, 0, 255, 0, true)
end

or another possibility could be to name the function and call it that way

example:

function makeStuff()
local x,y,z = getElementPosition( source )
createObject ( 2993, x, y, z, 120, 0, 0 )
outputChatBox("Party started", source, 0, 255, 0, true)
end
onResourceStart, getRootElement(), makeStuff

Link to comment

Uhm... you forgot the addEventHandler function, trajik :P

But I guess you want it in a command, right? Then it should look something like this:

function command_makeStuff(player)
local x, y, z = getElementPosition(player)
createObject(2993, x, y, z, 120, 0, 0)
outputChatBox("Party started", player, 0, 255, 0, true)
end
addCommandHandler("command", command_makeStuff)

Link to comment
Uhm... you forgot the addEventHandler function, trajik :P

But I guess you want it in a command, right? Then it should look something like this:

function command_makeStuff(player)
local x, y, z = getElementPosition(player)
createObject(2993, x, y, z, 120, 0, 0)
outputChatBox("Party started", player, 0, 255, 0, true)
end
addCommandHandler("command", command_makeStuff)

you are right, but there is just 1 thing i like to try to fix.

every1 should see "Party started" right?

so why are you placing player.

now it only shows for him.

it should be :

addCommandHandler("party",
function (plr)
local x, y, z = getElementPosition(source)
local locName = getZoneName( getElementPosition( plr ) )
    object1 = createObject(2993, x, y, z, 120, 0, 0)
outputChatBox("Party Team: party started at" .. locName, player)
end
)

it checks where the party is being started and said in a announce :)

Link to comment

m4rsje, if you wanted to show this message to all players why did you put player in outputChatBox? So, you fixed nothing but added a location name which will be joined with "at" in the front ("atGanton", "atLos Stantos", etc.) and will still work for the player who typed the command in or will give you a warning message because player doesn't exist in the code.

Link to comment

ahh, i think i get it now,

i got it working on my server just dont know the outputChatBox(no1 wants to test lawl :( )

addCommandHandler("party",
function (plr)
local x, y, z = getElementPosition(plr)
local locName = getZoneName( getElementPosition( plr ) )
   object1 = createObject(2993, x, y, z)
object2 = createObject(2993, x+2, y, z)
object3 = createObject(2993, x+2, y+2, z)
object4 = createObject(2993, x, y+2, z)
outputChatBox("Party Team: party started at " .. locName)
end
)
 
addCommandHandler("end",
function ()
destroyElement(object1)
destroyElement(object2)
destroyElement(object3)
destroyElement(object4)
outputChatBox("Party Team: party has ended!")
end
)

there you go, a full script that works,

it creates them with /party

and deletes them with /end

;) enjoy it.

Link to comment

Don't pass. It's the most basic thing with commands/even gui windows

local active = false
function yourFunction()
if not active then -- if it isn't active yet, only then
-- your code, which starts stuff
	active = true -- set it to active, so it couldn't get duplicated
end
end
function yourSecondFunction()
if active then -- only run, if it's active
-- your code, which ends stuff here
	active = false -- as things have been shut down, you can now set it to inactive again
end
end

And when you start something, you call yourFunction, when ending it, yourSecondFunction

Link to comment
Don't pass. It's the most basic thing with commands/even gui windows
local active = false
function yourFunction()
if not active then -- if it isn't active yet, only then
-- your code, which starts stuff
	active = true -- set it to active, so it couldn't get duplicated
end
end
function yourSecondFunction()
if active then -- only run, if it's active
-- your code, which ends stuff here
	active = false -- as things have been shut down, you can now set it to inactive again
end
end

And when you start something, you call yourFunction, when ending it, yourSecondFunction

hey thats not even hard :o

thx :)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...