Jump to content

ChatBox + Get local players


Fantanic

Recommended Posts

Hello ,

First of all i got a lil problem with a new chatbox (top bar).

When u type 'T' after a time if u put so much words u got 2 lines.

Well if i put "too much" words its only in 1 line so it 'f*cks up'.

So i want it if i put (amount) of words that it goes to the second line if i reach it for example i say :

teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeest

^ this stays on 1 line but i want it on 2 lines so it doesnt look f*cked up :

teeeeeeeeeeeeeeeeeee

eeeeest

(for example)

Second ,

Whats the function to get the players who are inside a interior?

(edit they need to be in the team 'criminals' but i only want to take the players who are inside there)

Sorry for bad english

Link to comment
  • Moderators

For the first one, try this:

local MAX_CHAR_PER_LINE = 40 --define the max amount of letters per line 
  
function chatMessageSplitter(message, messageType, isMine) 
    -- we will only send normal chat messages, action and team types will be ignored 
    if messageType ~= 0 or not isMine then return end 
    cancelEvent() --block the default behavior of chat system 
    --doing our own below 
    local nbChars = string.len(message) 
    for k=1, nbChars, MAX_CHAR_PER_LINE do 
        local line = string.sub(message, k, k+MAX_CHAR_PER_LINE-1) 
        triggerEvent("onPlayerChat", source, message messageType, true) 
    end 
end 
addEventHandler("onPlayerChat", root, chatMessageSplitter) 

Didn't tested yet, because I need to go out soon.

For the second question, what do you mean by interior ? Inside a building for example ? or the mta interior (in the code) ?

Link to comment

Im trying to make an bankrob .

But i want it so whos robbing that they gain the money and not the others for example player 1 - player 10 is in bankrob robbing and player 11 isnt inside the bank so only player 1- player 10 should get money and not player11.

(if posible all the people who are in the team Criminals inside the bank gets the money)

second anyway to get the max amount working on topbarchat script on the communty?

Link to comment

You can create a Col shape with radar if needed for a specific area and that area should be the bank and when a player hits that colshape then use setElementData ( hitElement, "PlayerinBank", true ) and then use another event oncolshapeleave ( or what ever it is ) and set the his element data to false and when you want to give money then get all players by

for i,v in pairs (getElementsByType("player") ) do  
if getElementData ( v, "PlayerinBank" ) == true then  
-- give him money  

Link to comment

Thanks ,

I've got a other problem i guess ;

addCommandHandler("aclObjectList",function(player,command,aclGroup) 
local ADMIN_GROUP = "Admin" 
    if(aclGroup~="")then 
        table = aclGroupListObjects(aclGetGroup(ADMIN_GROUP)) 
        count = 0 
        for objects,name in pairs(table)do 
            outputChatBox("ACL LIST: "..aclGroup.." #"..tostring(count).." Object: "..name..".",player) 
            count = count + 1 
        end 
    else 
        outputChatBox("Please add the aclGroup you want the list of.",player) 
        outputChatBox("Syntax: /aclObjectList aclGroup",player) 
    end 
end) 

(i want it so it only takes the ACL 'Admin' )

Link to comment
addCommandHandler ( "aclObjectList", 
    function ( player ) 
        local ADMIN_GROUP = "Admin" 
        local objects = aclGroupListObjects ( aclGetGroup ( ADMIN_GROUP ) ) 
        local count = 0 
        for object, name in pairs ( objects ) do 
            outputChatBox ( "ACL LIST: ".. ADMIN_GROUP .." #".. tostring ( count ) .." Object: ".. name ..".", player ) 
            count = ( count + 1 ) 
        end 
    end 
) 

Is that what you wanted?

Link to comment

Yes is it posible to get only the user.(name)?

addCommandHandler ( "aclObjectList", 
    function ( player ) 
        local ADMIN_GROUP = "Admin" 
        local objects = aclGroupListObjects ( aclGetGroup ( ADMIN_GROUP ) ) 
        local count = 0 
        for object, name in pairs ( user. ) do 
            outputChatBox ( "ACL LIST: ".. ADMIN_GROUP .." #".. tostring ( count ) .." Object: ".. name ..".", player ) 
            count = ( count + 1 ) 
        end 
    end 
) 

Is that what you wanted?

like this?

oh also how to get it in gridlist? (only need the functions and a example that i can script it by myself for putting it in gridlist)

Link to comment

Hm u know whats wrong with this? i try to copy the message :

addCommandHandler ( "SAPDHQ", 
    function ( player ) 
local accName = getAccountName ( getPlayerAccount ( player ) ) -- get his account name 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
        local ADMIN_GROUP = "SAPD HQ" 
        local objects = aclGroupListObjects ( aclGetGroup ( ADMIN_GROUP ) ) 
        local count = 1 
        for object, name in pairs ( objects ) do 
            outputChatBox ( "Group List: ".. ADMIN_GROUP .." #".. tostring ( count ) .." Object: ".. name ..".", player ) 
            count = ( count + 1 ) 
            setClipboard("Group List:  .. ADMIN_GROUP .. #.. tostring ( count ) .. Object: .. name ..") 
        end 
    end 
end 
) 
  

with removing the check that hes in aclgroup (that only 'admin' can use it it still doesnt copy the text)

Link to comment
Hm u know whats wrong with this? i try to copy the message :
addCommandHandler ( "SAPDHQ", 
    function ( player ) 
local accName = getAccountName ( getPlayerAccount ( player ) ) -- get his account name 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
        local ADMIN_GROUP = "SAPD HQ" 
        local objects = aclGroupListObjects ( aclGetGroup ( ADMIN_GROUP ) ) 
        local count = 1 
        for object, name in pairs ( objects ) do 
            outputChatBox ( "Group List: ".. ADMIN_GROUP .." #".. tostring ( count ) .." Object: ".. name ..".", player ) 
            count = ( count + 1 ) 
            setClipboard("Group List:  .. ADMIN_GROUP .. #.. tostring ( count ) .. Object: .. name ..") 
        end 
    end 
end 
) 
  

with removing the check that hes in aclgroup (that only 'admin' can use it it still doesnt copy the text)

setClipboard is client side function.

Link to comment

Just add this line:

triggerClientEvent (player, "EventName",player ) 
  

or if you want to pass arguements

triggerClientEvent (player, "EventName",player, ADMIN_GROUP, name, tostring ( count ) )   
  

Client side

  
function greetingHandler ( ADMIN_GROUP, name,  count )   
    -- do your stuff 
end 
addEvent( "EventName", true ) 
addEventHandler( "EventName", getRootElement(), greetingHandler ) 

Link to comment

it might be difficult for you to make a big difficult and complicated bank rob so why don't you try some of the simple functions?

like --

local marker = createMarker(x, y, z, "cylinder", size, r, g, b, a) 
function bankMoney (hitElement) 
   if hitElement == localPlayer then 
      if isElementWithinMarker(hitElement) then -- checks if the player is within the marker so even if the function is in global the money goes to only the players who is within the marker......... 
      money functions  
      end 
   end 
end 
addEventHandler("onClientMarkerHit", marker, bankMoney) 

Link to comment
  • Moderators
it might be difficult for you to make a big difficult and complicated bank rob so why don't you try some of the simple functions?

like --

local marker = createMarker(x, y, z, "cylinder", size, r, g, b, a) 
function bankMoney (hitElement) 
   if hitElement == localPlayer then 
      if isElementWithinMarker(hitElement) then -- checks if the player is within the marker so even if the function is in global the money goes to only the players who is within the marker......... 
      money functions  
      end 
   end 
end 
addEventHandler("onClientMarkerHit", marker, bankMoney) 

this if statement:

if isElementWithinMarker(hitElement) then 
  
end 

is totally useless for two reasons:

1 - this condition is wrong since this function takes 2 arguments (theElement, theMarker)

2 - It will always return true because you are checking if the element that entered into the marker is in the marker. Ofc he is in, he just entered in it.

I also wonder why do you want to do it on the client-side ?

Link to comment
Just add this line:
triggerClientEvent (player, "EventName",player ) 
  

or if you want to pass arguements

triggerClientEvent (player, "EventName",player, ADMIN_GROUP, name, tostring ( count ) )   
  

Client side

  
function greetingHandler ( ADMIN_GROUP, name,  count )   
    -- do your stuff 
end 
addEvent( "EventName", true ) 
addEventHandler( "EventName", getRootElement(), greetingHandler ) 

i meant how to get the message , so i should use "ADMIN_GROUP" "name" "count" ? or what u mean

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