Jump to content

Script Question


Recommended Posts

Posted

Hi everybody...

I made a little script for a Armybase... But i have a problem, i want that the Chatbox write who opened the base...

  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate ( ) 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(getPlayerName(source)"opened the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack () 
    moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
end 
addCommandHandler("armyc", movingMyGateBack)  

But in the Chatbox nothing happened when anybody opened the Base.... please help me

Posted (edited)
  
  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate ( ) 
local Name = getPlayerName(source) 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(Name .."opened the Armybase",getRootElement (), 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack () 
    moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
end 
  

i think this will work ^.^

Edited by Guest

تيم سبيك بروجيمر

ts3server://ts.pg.sa

Posted

if you want to get the player who triggered the command, you should use something like :

function openMyGate (player, command ) 
     moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
     outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
 end 
 addCommandHandler("armyo",openMyGate) 

Posted
if you want to get the player who triggered the command, you should use something like :
function openMyGate (player, command ) 
     moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
     outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
 end 
 addCommandHandler("armyo",openMyGate) 

you can just write

  
     outputChatBox(getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
  

without the 1st ""..

تيم سبيك بروجيمر

ts3server://ts.pg.sa

Posted

So now its work.

  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack () 
    moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyc", movingMyGateBack) 
  

And when only the "Army" teammembers conn open the Base then its so=

  
  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
        if (getPlayerTeam" class="kw2">getPlayerTeam(thePlayer) == "Army") then 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack () 
        if (getPlayerTeam" class="kw2">getPlayerTeam(thePlayer) == "Army") then 
        moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyc", movingMyGateBack)  

??

Posted
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
        if (getTeamName(getPlayerTeam(thePlayer)) == "Army") then 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack () 
        if (getTeamName(getPlayerTeam(thePlayer)) == "Army") then 
        moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyc", movingMyGateBack)  

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

it doesnt work

function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
   function openMyGate (player, command ) 
    (getTeamName(getPlayerTeam" class="kw2">getPlayerTeam(thePlayer)) == "Army") 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyo",openMyGate) 
   
function movingMyGateBack () 
    (getTeamName(getPlayerTeam" class="kw2">getPlayerTeam(thePlayer)) == "Army") 
    moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
end 
addCommandHandler("armyc", movingMyGateBack) function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  

Posted

try this

  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
        if (getTeamName(getPlayerTeam(player)) == "Army") then 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
    end 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack (player, command) 
        if (getTeamName(getPlayerTeam(player)) == "Army") then 
        moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
    end 
end 
addCommandHandler("armyc", movingMyGateBack) 
  

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

it didn´t work, too

debugscript show me: Error: Army Base/ gates.lua:8: Bad Argument @ 'getPlayerTeam'

Error: Army Base/ gates.lua:8: Bad Argument @ 'getTeamName'

Posted
it didn´t work, too

debugscript show me: Error: Army Base/ gates.lua:8: Bad Argument @ 'getPlayerTeam'

Error: Army Base/ gates.lua:8: Bad Argument @ 'getTeamName'

  
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
        if (getTeamName(getPlayerTeam(source)) == "Army") then 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
    end 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack (player, command) 
        if (getTeamName(getPlayerTeam(source)) == "Army") then 
        moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
    end 
end 
addCommandHandler("armyc", movingMyGateBack) 
  

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted
function createTheGate () 
    myGate = createObject( 988, 96.722534179688, 1920.3703613281, 18.158107757568, 0, 0, 270 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate (player, command ) 
team = getPlayerTeam(player) 
if team then 
        if (getTeamName() == "Army") then 
    moveObject( myGate, 5000, 96.722534179688, 1915.8951416016, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." opened the Armybase", 255, 255, 0, true) 
      end 
   end 
end 
addCommandHandler("armyo",openMyGate) 
  
function movingMyGateBack (player, command) 
team = getPlayerTeam(player) 
if team then 
        if (getTeamName() == "Army") then 
        moveObject( myGate, 5000, 96.722534179688, 1920.3703613281, 18.158107757568 ) 
    outputChatBox(""..getPlayerName(player).." closed the Armybase", 255, 255, 0, true) 
      end 
   end 
end 
addCommandHandler("armyc", movingMyGateBack)  

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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