m4rsje Posted July 6, 2010 Share Posted July 6, 2010 hey guys, im trying to make an command like /call a team called "nubs" have to get the input. like: /call hey all, welcome to the server! only team "nubs" have to get this message, but i dont got any idea how! :\ maybe some1 could help me with a small start,? thx Link to comment
50p Posted July 6, 2010 Share Posted July 6, 2010 I'll make the command for you because I'm in good mood and it isn't hard at all but I expect you to try and understand how it works! addCommandHandler( "call", function( plr, _, ... ) local myName = getPlayerName( plr ); -- get my nick local message = table.concat( arg, " " ); -- make a string of all the words typed after "/call " local team = getPlayerTeam( plr ); -- get my team for _, player in ipairs( getElementsByType( "player" ) ) do -- loop through players local plrTeam = getPlayerTeam( player ); -- get player's team if plrTeam == team then -- check if his team is the same as yours outputChatBox( myName .. ": " .. message, player ); -- if it is, send the message to him end end end ) Link to comment
m4rsje Posted July 6, 2010 Author Share Posted July 6, 2010 well i always try to understand it , so i can make it later again, or for other things anyway i think you didn't get me , like, im a mechanic, and i need to call a cop. so i do /911 san fiero mechanic house and only the cops, can see that message. with the player name. the cops will see this: m4rsje needs help at san fiero mechanic house! the team is called: Cops. maybe you get me now ^^ Link to comment
50p Posted July 6, 2010 Share Posted July 6, 2010 OK, then you can get player's location instead of typing it in because some people may not know the name of place where they are, like so: addCommandHandler( "call", function( plr, _, whatTeam, ... ) local myName = getPlayerName( plr ); -- get my nick local team = getTeamFromName( "Cops" ); -- get the team --local team = getTeamFromName( whatTeam ); -- get the team that you call, eg. "/call Cops" local locName = getZoneName( getElementPosition( plr ) ); -- get the name of location where the player is for _, player in ipairs( getElementsByType( "player" ) ) do -- loop through players local plrTeam = getPlayerTeam( player ); -- get player's team if plrTeam == team then -- check if he is in "Cops" team outputChatBox( myName .. " needs help! Location: " .. locName, player ); -- if he is, send the message to him --outputChatBox( myName .. " " .. table.concat( arg, " " ) .. " - Location: " .. locName, player ); -- send whatever you typed after "/call ", eg. "/call Cops I need help!" end end end ) If you want to use "/call " then you have to uncomment the 2 lines and comment the line above the commented line. Link to comment
dzek (varez) Posted July 6, 2010 Share Posted July 6, 2010 just replace line 5 in 50p's script with team you want to send message to.. Link to comment
m4rsje Posted July 6, 2010 Author Share Posted July 6, 2010 thx guys , 50p i was asking, are you from MTA DEV? you know alot and you always help people alot, Link to comment
50p Posted July 6, 2010 Share Posted July 6, 2010 thx guys ,50p i was asking, are you from MTA DEV? you know alot and you always help people alot, I'm not an MTA Dev but if you run MTA and look into "Credits", you will find me in "Patch contributors" section. I made a few patches for MTA before they moved to Git. I always help people because I was born to help as much as I can and share my knowledge with others Link to comment
m4rsje Posted July 6, 2010 Author Share Posted July 6, 2010 thats a nice life im trying to to that too, getting better, and better, and if you are good enough. help people 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