Jump to content

Please help been stuck on this for a week (gangchat)


Dentos

Recommended Posts

So i got this script for gangchat but it wont work :/ I got no idea what to do

addEventHandler ( "onResourceStart", resourceRoot,

function ( )

for _, player in ipairs ( getElementsByType ( "player" ) ) do

bindKey ( player, "Y", "down", "chatbox", "gangChat" )

end

end

)

addEventHandler ( "onPlayerJoin", root,

function ( )

bindKey ( source, "Y", "down", "chatbox", "gangChat" )

end

)

function gangChat ( thePlayer, _, ... )

local isInvited = getElementData ( thePlayer, "invited" ) or false

if ( isInvited ) then

local text = table.concat ( { ... }, " " )

if ( #text > 0 ) then

outputChatBox ("#FF32AA [GangChat] "..getPlayerName(thePlayer)..": #FFFFFF" ..text, thePlayer, 255, 255, 255, true )

end

end

end

addCommandHandler ( "gangChat", gangChat )

function invitePlayer ( thePlayer, _, playerName )

if not playerName then return end

local playerToInvite = getPlayerFromName(playerName)

if ( isElement ( playerToInvite ) ) and getElementType( argument ) == "player" then

setElementData ( playerToInvite, "invited", true )

outputChatBox ( "You have been invited to the chat.", playerToInvite)

else

outputChatBox ( "There is no such a player!", thePlayer )

end

end

addCommandHandler ( "invite", invitePlayer )

Ive tried many other gang chat resources and nothing whatever I do it wont work :/

Link to comment
addEventHandler ( "onResourceStart", resourceRoot, 
function ( ) 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do  
        bindKey ( player, "Y", "down", "chatbox", "gangChat" )  
    end 
end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
function ( ) 
    bindKey ( source, "Y", "down", "chatbox", "gangChat" ) 
end 
) 
  
function gangChat ( thePlayer, _, ... ) 
local isInvited = getElementData ( thePlayer, "invited" ) or false 
    if ( isInvited ) then 
        local text = table.concat ( { ... }, " " ) 
        if ( #text > 0 ) then 
            outputChatBox ("#FF32AA [GangChat] "..getPlayerName(thePlayer)..": #FFFFFF" ..text, thePlayer, 255, 255, 255, true ) 
        end 
    end 
end 
addCommandHandler ( "gangChat", gangChat ) 
  
function invitePlayer ( thePlayer, _, playerName ) 
    if not playerName then return end 
        local playerToInvite = getPlayerFromName(playerName) 
  
        if ( isElement ( playerToInvite ) ) and getElementType( playerToInvite ) == "player" then -- At function 'getElementType' you have 'argument' as the argument but this variable doesn't exist so I supposed is 'playerToInvited' 
            setElementData ( playerToInvite, "invited", true ) 
            outputChatBox ( "You have been invited to the chat.", playerToInvite) 
        else 
            outputChatBox ( "There is no such a player!", thePlayer ) 
        end 
    end 
end 
addCommandHandler ( "invite", invitePlayer ) 

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