Jump to content

New Chat


Recommended Posts

Posted

Hello guys, does anybody know how to create a new chat? or edit the old chats?

Like example Gang chat, thanks for help.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Are you talking about a new chat system or editing a current chat command?

You can bind keys to the player to act like "T" and "Y" keys.

bindKey ( thePlayer, "U", "down", "chatbox", "Local Chat" ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

creating a new chat system

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

No, you don't understand, I want to create a new chat like team chat.

I will name it gang chat. I need just functions to create it, or an example...

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do -- Loop all the players.  
            bindKey ( player, "U", "down", "chatbox", "GangChat" ) -- Bind the key "U" to the "GangChat" command. 
        end 
    end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        bindKey ( source, "U", "down", "chatbox", "GangChat" ) -- Bind the key "U" to the "GangChat" command. 
    end 
) 
  
function gangChat ( thePlayer, _, ... ) 
    local text = table.concat ( { ... }, " " ) 
    if ( #text > 0 ) then 
        outputChatBox ( text, thePlayer ) 
    end 
end 
addCommandHandler ( "GangChat", gangChat ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Thanks working, but is there a way to lt only people who get invited can talk in gang chat?

like example /invite randomplayer then we are the only players who can talk in gang chat and other people can't see

I edited the code to keep showing player name

addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do -- Loop all the players. 
            bindKey ( player, "U", "down", "chatbox", "gangChat" ) -- Bind the key "U" to the "GangChat" command. 
        end 
    end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        bindKey ( source, "U", "down", "chatbox", "gangChat" ) -- Bind the key "U" to the "GangChat" command. 
    end 
) 
  
function gangChat ( thePlayer, _, ... ) 
    local text = table.concat ( { ... }, " " ) 
    if ( #text > 0 ) then 
        outputChatBox ("#FF32AA (GANG) "..getPlayerName(thePlayer)..": #FFFFFF" ..text, thePlayer, 255, 255, 255, true ) 
    end 
end 
addCommandHandler ( "gangChat", gangChat ) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Lol no! Setelementdata, thats all.

For example.

addCommandHandler("invite", 
    function (player, cmd, name) 
        if not name then return end 
        setElementData(getPlayerFromName(name), "invited", true) 
    end 
) 

And then you are just checking

if (getElementData(player, "invited") then 

Posted

But how to check if the player is invited or not? If the player is invited he can use the chat, if not he cant use the chat or see the chat.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted
Lol no! Setelementdata, thats all.

For example.

addCommandHandler("invite", 
    function (player, cmd, name) 
        if not name then return end 
        setElementData(getPlayerFromName(name), "invited", true) 
    end 
) 

And then you are just checking

if (getElementData(player, "invited") then 

Will only work for one group chat and you will have to invite the guys each time they reconnect.

I would use element datas to know in which group the guy is and persist the data in database (Mysql or account datas).

The invite command will check in which group the player who wrote the cmd is and then add the target player to that group.

Then the chat will display group messages between guys that are in the same group.

The rEvolution is coming ...

Posted
But how to check if the player is invited or not? If the player is invited he can use the chat, if not he cant use the chat or see the chat.

And then you are just checking

if (getElementData(player, "invited") then 

Posted

Well I wrote you how, but...

    addEventHandler ( "onResourceStart", resourceRoot, 
        function ( ) 
            for _, player in ipairs ( getElementsByType ( "player" ) ) do -- Loop all the players. 
                bindKey ( player, "U", "down", "chatbox", "gangChat" ) -- Bind the key "U" to the "GangChat" command. 
            end 
        end 
    ) 
      
    addEventHandler ( "onPlayerJoin", root, 
        function ( ) 
            bindKey ( source, "U", "down", "chatbox", "gangChat" ) -- Bind the key "U" to the "GangChat" command. 
        end 
    ) 
      
    function gangChat ( thePlayer, _, ... ) 
        local isInvited = getElementData ( thePlayer, "invited" ) or false 
        if ( isInvited ) then 
            local text = table.concat ( { ... }, " " ) 
            if ( #text > 0 ) then 
                outputChatBox ("#FF32AA (GANG) "..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 ) ) 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 ) 

Posted

Does this depend many gang chats? I mean if i have a gang chat with player 1

then player2 and player3 can have their own gang chat too like example

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted

Yes of course, excepted if you are using the element data "invited" like who am I did.

The rEvolution is coming ...

Posted

Okay thanks gonna try

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I have a problem, when i invite a player, i can't use gangChat but he can use them, i want to both can talk in the gang chat, like a pm chat box

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted
I have a problem, when i invite a player, i can't use gangChat but he can use them, i want to both can talk in the gang chat, like a pm chat box

A gang chat is not the same as PM because PM is between two players only (at least for me).

You have to do another command first to create the gang/group and then you will invite other players in it.

If you don't want to let anyone be able to create a gang/group (then definied by the script), you will have to create the group 1st and then you need to put AT LEAST one guy into it (usually the leader).

In your case, the player1 who is not in a gang/group is inviting player2 in a gang he doesn't own.

The rEvolution is coming ...

Posted

I want make it like a group pm if you know what i mean

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Help?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted

You don't want to use other resources but you can't do it yourself either even after we told you the main idea and the functions you would have to use.

Learn to script simple stuff first. Check the Introduction to Scripting available on the wiki main page.

function createGang( thePlayer, cmd, gngName ) 
    if not thePlayer or not cmd then return end 
    if not gngName then  
        return outputChatBox("SYNTAX: /createGang ") 
    end 
  
    if getElementData(thePlayer, "gang") then 
        return outputChatBox("You are already in a gang. Do /leaveGang to leave it.", thePlayer) 
    end 
  
    if isGangAlreadyExist(gngName) then 
        return outputChatBox("The gang "..gngName.." already exist !", thePlayer) 
    end 
  
    local newGang = createElement("gang") 
    setElementData(newGang, "name", gngName) 
    setElementData(newGang, "leader", gngName) 
    setElementData(newGang, "members", {}) 
  
    outputChatBox("You successfully created the "..gngName.." gang and you are the leader !", thePlayer) 
end 
addCommandHandler("createGang", createGang, false, false) 
  
function inviteInGang( thePlayer, cmd, playerName ) 
    if not thePlayer or not cmd then return end 
    if not playerName then 
        return outputChatBox("SYNTAX: /invite ", thePlayer) 
    end 
  
    local gang = getElementData(thePlayer, "gang") 
    if not gang then 
        return outputChatBox("You must be part of a gang first. Do /createGang to create your own.", thePlayer) 
    end 
  
    local newMember = getPlayerFromName(playerName) 
    if not newMember then 
        return outputChatBox("Player "..playerName.." not found !", thePlayer) 
    end 
  
    if newMember == thePlayer then 
        return outputChatBox("You can't invite your self into a gang !", thePlayer) 
  
    if getElementData(newMember, "gang") then 
        return outputChatBox("The player "..playerName.." is already in a gang. Ask him to leave first.", thePlayer) 
    end 
  
    if addNewMemberToGang(gang, newMember) then 
        local gangName = getElementData(gang, "name") or "" 
        outputChatBox("Congrats ! You are now part of the "..tostring(gangName).." gang !", newMember) 
        outputChatBox(playerName.." is now a member of your gang !", thePlayer) 
    else 
        outputChatBox("An error has occured. Please contact an administrator.", thePlayer) 
    end 
end 
addCommandHandler("invite", inviteInGang, false, false) 
  
function leaveGang( thePlayer ) 
    if not thePlayer then return end 
    local gang = getElementData(thePlayer, "gang") 
    if not gang then 
        return outputChatBox("You already aren't in a gang !", thePlayer) 
    end 
  
    if removeMemberFromGang( gang, thePlayer ) then 
        local gangName = getElementData(gang, "name") or "" 
        local leader = getElementData(gang, "leader") 
        outputChatBox("You successfully left the "..tostring(gangName).." gang !", thePlayer) 
        if leader and isElement(leader) then 
            outputChatBox(playerName.." left your gang !", leader) 
        end 
    else 
        outputChatBox("An error has occured. Please contact an administrator.", thePlayer) 
    end 
end 
addCommandHandler("leaveGang", leaveGang, false, false) 
  
function addNewMemberToGang( theGang, thePlayer ) 
    if not theGang or not thePlayer then return end 
    local members = getElementData(theGang, "members") 
    table.insert(members, thePlayer) 
    return (setElementData(newMember, "gang", theGang) and  
        setElementData(theGang "members", members)) 
end 
  
function removeMemberFromGang( theGang, thePlayer ) 
    if not theGang or nor thePlayer then return end 
    local tmp = getElementData(theGang, "members") or {} 
    local members = {} 
    for k, member in ipairs(members) do 
        if member ~= thePlayer then table.insert(members, member) end 
    end 
    return (removeElementData(thePlayer, "gang") and 
        setElementData(theGang, "members", members)) 
end 
  
function isGangAlreadyExist( gngName ) 
    for k, theGang in ipairs (getElementsByType("gang")) do 
        local name = getElementData(theGang, "name") or "" 
        if name == gngName then return true end 
    end 
    return false 
end 
  
function gangChat ( thePlayer, _, ... ) 
    local text = table.concat ( { ... }, " " ) 
    local theGang = getElementData(thePlayer, "gang") 
    if #text == 0 or not theGang then return end 
    local members = getElementData(theGang, "members") or {} 
    local playerName = getPlayerName(thePlayer) 
    for k, member in ipairs (members) do 
        outputChatBox ("#FF32AA (GANG) "..playerName..": #FFFFFF"..text, member, 255, 255, 255, true ) 
    end 
end 
addCommandHandler ( "gangChat", gangChat ) 
addCommandHandler ( "gc", gangChat ) 

This script may have bugs since I didn't test it.

The rEvolution is coming ...

Posted (edited)

Gonna try

Edited by Guest

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Thanks man its working :)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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