Jump to content

Gamemode Script - Beginner


Guest Flibber100

Recommended Posts

Hey there, i need some help.

I got this script:

function Script_onMapLoad () 
  
barrier = createObject (968, 1544.714966, -1630.837036, 13.317049, 1.574999, 1.604999, 0.000000) 
end 
  
  
addEventHandler ( "onResourceStart", getRootElement(), Script_onMapLoad ) 
  
  
function consoleOpen () 
    local hello = getClientName ( source ) 
    outputChatBox ( "Barrier up!", hello) 
        moveObject ( barrier, 2000, 1544.714966, -1630.837036, 13.317049, 1.574999 -0.014999 0.000000 ) 
end 
  
  
addCommandHandler ( "open", consoleOpen  ) 

but it doesn't work :/

The barrier don't even appear, i want the barrier to be created, wenn the gamemode has started (on gamemode start).

What's wrong with the script?

Sorry if this is simple, I've just began to script in LUA, PAWN is something different^^

Thx for help

Flibber100

Link to comment

Like 7: try changing getRootElement() to getResourceRootElement(getThisResource())

And function consoleOpen must have first two parameters as a player who wrote command and command name. For example, changing consoleOpen() to consoleOpen(source,cmdname) would make it good.

Link to comment

function Script_onMapLoad () 
  
barrier = createObject (968, 1544.714966, -1630.837036, 13.317049, 1.574999, 1.604999, 0.000000) 
end 
  
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), Script_onMapLoad ) 
  
  
function consoleOpen (source, cmdname) 
    local hello = getClientName ( source ) 
    outputChatBox ( "Barrier up!", hello) 
        moveObject ( barrier, 2000, 1544.714966, -1630.837036, 13.317049, 1.574999 -0.014999 0.000000 ) 
end 
  
  
addCommandHandler ( "open", consoleOpen  ) 

The barrier still doesn't appear :(

Link to comment
function Script_onMapLoad () 
  
barrier = createObject (968, 1544.714966, -1630.837036, 13.317049, 1.574999, 1.604999, 0.000000) 
end 
  
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), Script_onMapLoad ) 
  
  
function consoleOpen (source, cmdname) 
    local hello = getClientName ( source ) 
    outputChatBox ( "Barrier up!", hello) 
        moveObject ( barrier, 2000, 1544.714966, -1630.837036, 13.317049, 1.574999 -0.014999 0.000000 ) 
end 
  
  
addCommandHandler ( "open", consoleOpen  ) 

The barrier still doesn't appear :(

You sure you got the right coordinates and are looking at the right spot? Also, type DEBUGSCRIPT 3 into the console before you start the gamemode next time. If something's wrong, you can see it there.

Link to comment
  
function Script_onMapLoad () 
    barrier = createObject (968, 1544.714966, -1630.837036, 13.317049, 0,90,90) 
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), Script_onMapLoad ) 
  
addCommandHandler ( "open",  
    function(player,cmd,...) 
        outputChatBox ( "Barrier up!", player) 
        moveObject ( barrier, 2000, 1544.714966, -1630.837036, 13.317049, 0,-90,0 ) 
    end 
) 
  

What was wrong:

+ You missed commas out on the moveObject() call

+ You angle parameters to createObject() and moveObject() where in radians not degrees

+ The incorrect use of outputChatBox() (as mentioned before)

Link to comment

Yeah! thx man, it works now!

I get it now, hot to make a function with a console command.

But how can i make the object (door) open itself, when e.g. a cop comes around it?

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...