Jump to content

problem with chat


[UCG]Mike

Recommended Posts

hey guys i have problem ( when i add Chat Zone resource i have problem when talk in say and i need any fix plz )

FwffBme.png

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

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

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

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

so fixed it

Link to comment
        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

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