Jump to content

[help] Kind of call system


m4rsje

Recommended Posts

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,?:D

thx :D:D

Link to comment

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

well i always try to understand it :),

so i can make it later again, or for other things :P

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

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
thx guys :),

50p i was asking, are you from MTA DEV?o.O

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 :wink:

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