[UCG]Mike Posted August 6, 2014 Share Posted August 6, 2014 hey guys i have problem ( when i add Chat Zone resource i have problem when talk in say and i need any fix plz ) local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) if ( msgtype == 0 ) then local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end cancelEvent ( ) end end addEventHandler ( "onPlayerChat", root, chatbox ) i dont want to talk 2 time Link to comment
xTravax Posted August 6, 2014 Share Posted August 6, 2014 cancel the event after line 9, not in the end of function Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) if ( msgtype == 0 ) then local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end cancelEvent ( ) end end addEventHandler ( "onPlayerChat", root, chatbox ) Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 [quote="Mr.Risk"]local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) cancelEvent ( ) if ( msgtype == 0 ) then local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end end end addEventHandler ( "onPlayerChat", root, chatbox )[/quote] Right ? Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 Test it, then you know or it's right. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 Test it, then you know or it's right. no its not working Link to comment
xTravax Posted August 6, 2014 Share Posted August 6, 2014 ugh i told you after 9 line,not on line 9 local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) if ( msgtype == 0 ) then cancelEvent ( ) local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end end end addEventHandler ( "onPlayerChat", root, chatbox ) Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 its not working too Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 Checked debugscript 3? I doubt it's not working. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 Checked debugscript 3? I doubt it's not working. no errors in debugscript 3 Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 It just works on my server. So, do it again, lol. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 no bro its not working any one give me his mod Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 ugh i told you after 9 line,not on line 9 local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) if ( msgtype == 0 ) then cancelEvent ( ) local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end end end addEventHandler ( "onPlayerChat", root, chatbox ) Well try this again then, is the script running, is it server-side in meta? This just works. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 local tab = { [ 'Los Santos' ] = 'LS'; [ 'Las Venturas' ] = 'LV'; [ 'San Fierro' ] = 'SF'; } function chatbox ( text, msgtype ) if ( msgtype == 0 ) then cancelEvent ( ) local name = getPlayerName ( source ) local playerX, playerY, playerZ = getElementPosition ( source ) local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerX, playerY, playerZ = getElementPosition ( player ) local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) if ( zoneName == playerZoneName ) then outputChatBox ( "(".. playerZoneName ..")".. name ..":".. text, player, r, g, b, true ) end end end end addEventHandler ( "onPlayerChat", root, chatbox ) "Mr.Risk" type="script" version="1.0" description="Chat-Zone" /> Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 Mmm, well it's working on my server. Are you really sure it's running? And using 't' chat? Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 Mmm, well it's working on my server. Are you really sure it's running? And using 't' chat? ye can you give me your script, its not a big resource, its a simple script Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 I used what you send me... It's working by me... So no need for that. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 so what the soulution ? Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 I have no idea what you are doing wrong. It just should work. Make a new resource, then maybe it solves while you don't know what you did wrong. Link to comment
xTravax Posted August 6, 2014 Share Posted August 6, 2014 not sure if this is the cause but you are overwriting stuff local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) ofc its showing none when you named 2 local variables with same name,change it so its like playerZoneName and playerZoneName2 or something local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) here same thing if ( zoneName == playerZoneName ) then you have defined zoneName as 2 variables,as you named them both the same name, 2nd one is overwriting first one and zoneName = (tab [ zoneName ] or "None" ) so that's why it doesn't output anything to chat as zoneName isn't 'playerZoneName' sry for messy post. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 not sure if this is the cause butyou are overwriting stuff local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) ofc its showing none when you named 2 local variables with same name,change it so its like playerZoneName and playerZoneName2 or something local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) here same thing if ( zoneName == playerZoneName ) then you have defined zoneName as 2 variables,as you named them both the same name, 2nd one is overwriting first one and zoneName = (tab [ zoneName ] or "None" ) so that's why it doesn't output anything to chat as zoneName isn't 'playerZoneName' sry for messy post. so fixed it Link to comment
Et-win Posted August 6, 2014 Share Posted August 6, 2014 local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) local playerZoneName = ( tab [ playerZoneName ] or "None" ) 'getZoneName' returns a string of the zone name. If it is in the table, then that is 'playerZoneName', otherwise "None". So this can't be the problem. local zoneName = getZoneName ( playerX, playerY, playerZ, true ) local zoneName = ( tab [ zoneName ] or "None" ) Same for this one. @Mr.Risk: I doubt that nothing output's in the chatbox. Also, if I see the meta file, I highly doubt you made this script. Link to comment
[UCG]Mike Posted August 6, 2014 Author Share Posted August 6, 2014 resource faild now 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