DjThaKiller Posted March 2, 2011 Share Posted March 2, 2011 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 Link to comment
UAEpro Posted March 2, 2011 Share Posted March 2, 2011 (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 March 2, 2011 by Guest Link to comment
Night.Ride Posted March 2, 2011 Share Posted March 2, 2011 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) Link to comment
UAEpro Posted March 2, 2011 Share Posted March 2, 2011 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 "".. Link to comment
Night.Ride Posted March 2, 2011 Share Posted March 2, 2011 that's my way of writing it, and thats not the point anyway, does it work ? Link to comment
DjThaKiller Posted March 2, 2011 Author Share Posted March 2, 2011 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) ?? Link to comment
Castillo Posted March 2, 2011 Share Posted March 2, 2011 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) Link to comment
DjThaKiller Posted March 3, 2011 Author Share Posted March 3, 2011 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 ) Link to comment
Kenix Posted March 3, 2011 Share Posted March 3, 2011 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) Link to comment
DjThaKiller Posted March 3, 2011 Author Share Posted March 3, 2011 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' Link to comment
Kenix Posted March 3, 2011 Share Posted March 3, 2011 it didn´t work, toodebugscript 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) Link to comment
Castillo Posted March 3, 2011 Share Posted March 3, 2011 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) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now