GamerDeMTA Posted April 15, 2013 Posted April 15, 2013 What's wrong with these lines? outputChatBox("You're in "..getTeamName( source ).. " team "..getPlayerName( source ).. "",root,255,255,255,true) Also I want to do a table with outputchatboxs with TRUE AND ALSO 255, 255, 255 THOSE THINGS. I can without it, but with it it gives error. setTimer ( function ( ) outputChatBox ( tabl[math.random(#tabll)] ) end, 10000, 0 ) What I should do?
Castillo Posted April 15, 2013 Posted April 15, 2013 Well, in your first code, you are trying to get the team name from the player element, not from a team element, you must use getTeamName with getPlayerTeam. And in your second code, how is "tabl" table constructed?
GamerDeMTA Posted April 15, 2013 Author Posted April 15, 2013 Hm I don't understand how to do it with getPlayerTeam and getTeamName both. And tabl is this: tablelol = { 'lol', 'xd', 'wtf' }
xXMADEXx Posted April 15, 2013 Posted April 15, 2013 Try: outputChatBox("You're in "..getTeamName( getPlayerTeam ( source ) ).. " team "..getTeamName( getPlayerTeam ( source ) ),root,255,255,255,true)
Castillo Posted April 15, 2013 Posted April 15, 2013 setTimer ( function ( ) outputChatBox ( tabl [ math.random ( #tabll ) ], 255, 255, 255, true ) end ,10000, 0 )
Sasu Posted April 15, 2013 Posted April 15, 2013 Try: outputChatBox("You're in "..getTeamName( getPlayerTeam ( source ) ).. " team "..getTeamName( getPlayerTeam ( source ) ),root,255,255,255,true) He put the name of the player in the end. outputChatBox("You're in "..getTeamName( getPlayerTeam ( source ) ).. " team "..getPlayerName( source ),root,255,255,255,true)
GamerDeMTA Posted April 15, 2013 Author Posted April 15, 2013 setTimer ( function ( ) outputChatBox ( tabl [ math.random ( #tabll ) ], 255, 255, 255, true ) end ,10000, 0 ) It doesn't work Also when I type the command for my other commands like this: addEventHandler ( "onPlayerChat", root, function ( message ) if ( message == "players" ) then outputChatBox("we are "..getPlayerCount( source ).. " players",root,255,255,0,true) cancelEvent ( ) end end ) It shows the message before I say that ((( I mean this happened, I say players[/ban] and... Me: players we are 1 players It happened... That PLease Help
Castillo Posted April 15, 2013 Posted April 15, 2013 That code is client side, if you want to do it server side, you must fill the visibleTo argument. setTimer ( function ( ) outputChatBox ( tabl [ math.random ( #tabl ) ], root, 255, 255, 255, true ) end ,10000, 0 )
Sasu Posted April 15, 2013 Posted April 15, 2013 setTimer ( function ( ) outputChatBox ( tabl [ math.random ( #tabll ) ], 255, 255, 255, true ) end ,10000, 0 ) It doesn't work Also when I type the command for my other commands like this: addEventHandler ( "onPlayerChat", root, function ( message ) if ( message == "players" ) then outputChatBox("we are "..getPlayerCount( source ).. " players",root,255,255,0,true) cancelEvent ( ) end end ) It shows the message before I say that ((( I mean this happened, I say players[/ban] and... Me: players we are 1 players It happened... That PLease Help getPlayerCount haven't arguments so delete "source".
Renkon Posted April 15, 2013 Posted April 15, 2013 ( tabl [ math.random ( #tabll )) -- there's a typo
GamerDeMTA Posted April 16, 2013 Author Posted April 16, 2013 Ok but help me with this! When I type "ping" it shows the outputChatBox two times! addEventHandler ( "onPlayerChat", root, function ( message ) if ( message == "ping" ) then outputChatBox("your ping: "..getPlayerPing( source ).. " \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />",root,255,255,0,true) cancelEvent ( ) end end ) Why???
Max+ Posted April 16, 2013 Posted April 16, 2013 Make Sure Freeroam is Off and Try This , addEventHandler('onPlayerCommand', root, function ( cmd ) if ( cmd ) == 'ping' then cancelEvent ( ) outputChatBox('Your Ping'.. getPlayerName(source), root, 255, 255, 0 , true) end end )
GamerDeMTA Posted April 16, 2013 Author Posted April 16, 2013 Make Sure Freeroam is Off and Try This , addEventHandler('onPlayerCommand', root, function ( cmd ) if ( cmd ) == 'ping' then cancelEvent ( ) outputChatBox('Your Ping'.. getPlayerName(source), root, 255, 255, 0 , true) end end ) Freeroam isn't running But I want to do it if player says "ping" not with a command. Please help
Mega9 Posted April 16, 2013 Posted April 16, 2013 addEventHandler('onPlayerChat', root, -- When player sends the message in chatbox function ( msg ) if ( msg ) == 'ping' then -- if message was "ping" then cancelEvent ( ) -- don't show the message outputChatBox(getPlayerName(source) .. "'s ping is: " .. getPlayerPing (source), root, 255, 255, 0 , true) -- Output player's name and ping end end )
GamerDeMTA Posted April 16, 2013 Author Posted April 16, 2013 It doesn't work yet!!!!!! Two times it shows the output instead one ((((
Sasu Posted April 16, 2013 Posted April 16, 2013 Try this: addEventHandler('onPlayerChat', root, -- When player sends the message in chatbox function ( msg, msgT ) if msg == 'ping' and msgT == 1 then -- if message was "ping" then cancelEvent ( ) -- don't show the message outputChatBox(getPlayerName(source) .. "'s ping is: " .. getPlayerPing (source), root, 255, 255, 0 , true) -- Output player's name and ping end end )
xXMADEXx Posted April 16, 2013 Posted April 16, 2013 Try: outputChatBox("You're in "..getTeamName( getPlayerTeam ( source ) ).. " team "..getTeamName( getPlayerTeam ( source ) ),root,255,255,255,true) He put the name of the player in the end. outputChatBox("You're in "..getTeamName( getPlayerTeam ( source ) ).. " team "..getPlayerName( source ),root,255,255,255,true) oh, didn't see that. Sorry. Thanks for fixing it.
GamerDeMTA Posted April 16, 2013 Author Posted April 16, 2013 Try this: addEventHandler('onPlayerChat', root, -- When player sends the message in chatbox function ( msg, msgT ) if msg == 'ping' and msgT == 1 then -- if message was "ping" then cancelEvent ( ) -- don't show the message outputChatBox(getPlayerName(source) .. "'s ping is: " .. getPlayerPing (source), root, 255, 255, 0 , true) -- Output player's name and ping end end ) Now it doesn't work ._. Pls someone help!!!
OGF Posted April 16, 2013 Posted April 16, 2013 Is your problem still that it displays twice or what? because it works fine. If it is still displaying twice, then you are obviously running another eventHandler with "onPlayerChat" .
Sasu Posted April 16, 2013 Posted April 16, 2013 Sorry change: if msg == 'ping' and msgT == 1 then to if msg == 'ping' and msgT == 0 then And check in the meta that the type script is server. Execute command debugscript 3 on game to see if it has error.
xXMADEXx Posted April 17, 2013 Posted April 17, 2013 It doesn't work yet!!!!!! Two times it shows the output instead one (((( Then, there is probably another script somewhere?
Mega9 Posted April 17, 2013 Posted April 17, 2013 Script works fine, there is another resource causing double messages. I remember I had the same problem, but forgot what was causing it exactly. Try leaving only admin and this resource on and see what happens.
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