megaman54 Posted February 27, 2011 Share Posted February 27, 2011 Hello! I made a admin area and script for it. It checks if the player who enter the area is in "Admins" team. So here is the problem: it kicks the player out of the area even if the player is in the Admins team, it doesnt give any errors or anything relating to errors. Code: function detectorDetect(thePlayer) if(getPlayerTeam" class="kw2">getPlayerTeam(thePlayer) == "Admins")then outputChatBox("Welcome!", thePlayer, 0, 255, 0) else setElementPosition(thePlayer, 247, 1833, 5) setElementRotation(thePlayer, 269) outputChatBox("You are not allowed to come here!", thePlayer, 255, 0, 0) end end addEventHandler("onColShapeHit", detector, detectorDetect) I hope someone can help me. Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 Where the colshape is created ? put it here please Link to comment
megaman54 Posted February 27, 2011 Author Share Posted February 27, 2011 Ok, here is the colshape detector = createColCircle(219.2746887207, 1822.8521728516, 21) Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 And where is it in your code ? In a function or just like that ? Link to comment
megaman54 Posted February 27, 2011 Author Share Posted February 27, 2011 Its at the beginning of the LUA file. Not in a function. Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 Ok so try that and tell me if HIT appear in your chatbox when you enter in the ColShape function detectorDetect(thePlayer) outputChatBox("HIT") if ( getPlayerTeam(thePlayer) == "Admins")then outputChatBox("Welcome!", thePlayer, 0, 255, 0) else setElementPosition(thePlayer, 247, 1833, 5) setElementRotation(thePlayer, 269) outputChatBox("You are not allowed to come here!", thePlayer, 255, 0, 0) end end addEventHandler("onColShapeHit", detector, detectorDetect) EDIT: I paste the code again EDIT2: IDK why but the code in lua was bugged so I put it in text format Link to comment
megaman54 Posted February 27, 2011 Author Share Posted February 27, 2011 Ok thx i will try it now. EDIT: The HIT thing appears but i still get teleported out of the area even if i'm in the team. Strange Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 Where is your createTeam and your setPlayerTeam please ( Lol my bad, I thought that the onColshapeHit was never triggered ) Link to comment
megaman54 Posted February 27, 2011 Author Share Posted February 27, 2011 I create them in admin panel. Or should i create them in that script? Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 Yeah I think it's better put this a the top of your lua file: teamAdmin = createTeam( "Admin" ) function enterInTeam( thePlayer, commandName ) if teamAdmin then setPlayerTeam ( thePlayer, teamAdmin ) end end addComandHandler("enterteam", enterInTeam, false, false ) Then restart your server and tape /enterteam then try to enter in your colshape Link to comment
proracer Posted February 27, 2011 Share Posted February 27, 2011 It is same with admin panel or creating team ( tested only in freroam) Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 It is same with admin panel or creating team ( tested only in freroam) Maybe but here it doesn't work Link to comment
Castillo Posted February 27, 2011 Share Posted February 27, 2011 It does work, you are doing it wrong, if i'm right getPlayerTeam returns an element and to get the team name you must use getTeamName, so would be. function detectorDetect(thePlayer) outputChatBox("HIT") if ( getTeamName(getPlayerTeam(thePlayer)) == "Admins")then outputChatBox("Welcome!", thePlayer, 0, 255, 0) else setElementPosition(thePlayer, 247, 1833, 5) setElementRotation(thePlayer, 269) outputChatBox("You are not allowed to come here!", thePlayer, 255, 0, 0) end end addEventHandler("onColShapeHit", detector, detectorDetect) Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 It does work, you are doing it wrong, if i'm right getPlayerTeam returns an element and to get the team name you must use getTeamName, so would be. function detectorDetect(thePlayer) outputChatBox("HIT") if ( getTeamName(getPlayerTeam(thePlayer)) == "Admins")then outputChatBox("Welcome!", thePlayer, 0, 255, 0) else setElementPosition(thePlayer, 247, 1833, 5) setElementRotation(thePlayer, 269) outputChatBox("You are not allowed to come here!", thePlayer, 255, 0, 0) end end addEventHandler("onColShapeHit", detector, detectorDetect) you right and I miss a little s at Admin so replace that line: teamAdmin = createTeam( "Admins" ) And now it will work perfectly Link to comment
megaman54 Posted February 28, 2011 Author Share Posted February 28, 2011 It works! Thanks for this nice support and help! Link to comment
Moderators Citizen Posted February 28, 2011 Moderators Share Posted February 28, 2011 It works! Thanks for this nice support and help! Thanks No problem 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