Jump to content

problem with chat


[UCG]Mike

Recommended Posts

Posted

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

Posted

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 )

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

Posted

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 ) 

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

Posted
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" /> 
    

Posted
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 :D

Posted

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.

Posted

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.

Posted
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

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

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