Jump to content

SMS system on a gridlist help.


Chris!i!

Recommended Posts

  
GUIEditor = { 
    label = {}, 
    button = {}, 
    window = {}, 
    scrollbar = {}, 
    gridlist = {} 
} 
local screenW, screenH = guiGetScreenSize() 
GUIEditor.window[1] = guiCreateWindow((screenW - 644) / 2, (screenH - 597) / 2, 644, 597, "CST CnR - Messenger V1.0", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 0.90) 
guiSetVisible(GUIEditor.window[1], false) 
guiSetInputMode("no_binds_when_editing") 
players = guiCreateGridList(9, 57, 203, 403, false, GUIEditor.window[1]) 
column = guiGridListAddColumn(players, "Players", 0.9) 
GUIEditor.button[1] = guiCreateButton(9, 470, 203, 33, "Clear selected conversation", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(230, 555, 404, 32, "Close Window", false, GUIEditor.window[1]) 
GUIEditor.button[3] = guiCreateButton(9, 513, 203, 33, "Mute Player", false, GUIEditor.window[1]) 
GUIEditor.label[1] = guiCreateLabel(220, 22, 414, 524, "CST messenger is the default messenger app for normal messages to\nplayers.\n\n\nTo start a conversation with a online player, double click on the\nonline player name in the gridlist at the left side. Once you double\nclick a name, the conversation will start in here.\n\n\nYou can also start a single conversation by just a single command;\n/sms PartOfPlayerName messageHere\n\n\nThis will start your conversation with provided player. You can\nreply to a message by the following command; /re messageHere\n\n\nTo delete any conversation, select the online player you wanted\nyou wanted to delete the conversation with, and press clear\nselected conversation button.", false, GUIEditor.window[1]) 
search = guiCreateEdit(9, 24, 203, 28, "", false, GUIEditor.window[1]) 
setElementID(search, "CSTmessenger.SearchEdit") 
guiGridListSetSortingEnabled( players, false ) 
setElementID(players, "CSTmessenger.GridList") 
guiGridListSetSelectionMode( players, 2 ) 
send = guiCreateEdit(218, 512, 416, 33, "", false, GUIEditor.window[1]) 
sms = guiCreateGridList(576, 108, 416, 485, false, GUIEditor.window[1]) 
guiSetVisible(sms, false) 
guiSetVisible(send, false) 
  
  
  
  
  
function guiToggleVisible ( )         
        if ( guiGetVisible ( GUIEditor.window[1] ) == true ) then               
                guiSetVisible ( GUIEditor.window[1], false )  
                showCursor (false) 
        else               
                guiSetVisible ( GUIEditor.window[1], true )  
                showCursor (true) 
        end 
end 
bindKey ( "F10", "down", guiToggleVisible ) 
  
function closeShit ( ) 
 if source == GUIEditor.button[2] then 
guiSetVisible (GUIEditor.window[1], false) 
showCursor(false) 
end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[2], closeShit ) 
  
function setList() 
    for k, i in ipairs( getElementsByType( "player" ) ) do 
        local row = guiGridListAddRow( players ) 
        local playerTeam = getPlayerTeam( i ) 
        guiGridListSetItemText( players, row, 1, getPlayerName( i ), false, false ) 
        if ( playerTeam ) then 
            local r, g, b = getPlayerNametagColor( i ) 
            guiGridListSetItemColor( players, row, 1, r, g, b) 
        end  
    end 
end 
addEventHandler("onClientResourceStart", getRootElement(), setList) 
  
         
         
function searchPlayer () 
    guiGridListClear ( players ) 
    local text = guiGetText ( search ) 
    if ( text ~= "" ) then 
        for id, playeritem in ipairs ( getElementsByType( "player" ) ) do 
            row = guiGridListAddRow( players ) 
            --local playerTeam = getPlayerTeam( playeritem ) 
            if ( string.find ( string.upper( getPlayerName ( playeritem ) ), string.upper( text ), 1, true ) ) then 
                guiGridListSetItemText( players, row, 1, getPlayerName( playeritem ), false, false ) 
                --if ( playerTeam ) then 
                --  local r, g, b = getPlayerNametagColor( playeritem ) 
                    guiGridListSetItemColor( players, row, 1, 255, 255, 255 ) 
                 
            end 
        end 
    else 
        for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do 
            row = guiGridListAddRow( players ) 
            --local playerTeam = getPlayerTeam( playeritem ) 
            guiGridListSetItemText( players, row, 1, getPlayerName( playeritem ), false, false) 
            --if ( playerTeam ) then 
            --  local r, g, b = getPlayerNametagColor( playeritem ) 
                guiGridListSetItemColor( players, row, 1, 255, 255, 255 ) 
             
        end 
    end 
end 
addEventHandler( "onClientGUIChanged", search, searchPlayer, false ) 
  
function toggle() 
    if ( guiGetVisible( GUIEditor.window[1] ) ) then 
        guiSetVisible( GUIEditor.window[1], false ) 
        showCursor( false ) 
    else 
        guiGridListClear( players ) 
        setList() 
        showCursor( true ) 
        guiSetVisible( GUIEditor.window[1], true ) 
    end 
end 
addEvent( "showGUIEditor.window[1]Info", true ) 
addEventHandler( "showGUIEditor.window[1]Info", localPlayer, toggle ) 
  
function refreshall() 
    guiGridListClear( players ) 
    setList() 
end 
  
  

So i've been stuck in here, i want that when someone double clicks on "players" gridlist the second gridlist and the second edit box will be shown up and the SMS system i want it in a gridlist so any helps please?

Link to comment

Idea:

Save all the phones numbers in a database then,when the resource starts,store all the numbers in a table like this:

phoneNumbers[accountName]= thePhone number 
--The database's format should be accName TEXT,phoneNum TEXT/NUMBER 

After this,when a player uses the command /sms [number] [message] (Server) trigger a client event witch stores the message in a table

  
sendedSms={ } 
  
--When the event is triggered 
table.insert(sendedSms,sendedSms[phNumber][#sendedSms[phNumber] + 1],message)--not sure if works 
  
--the table would look like this: 
sendedSms = { 
        phNum1 = {sms1,sms2,...,smsN} 
} 
  

And when you want to make a gridlist with sms just cycle thru the messages

Link to comment
Idea:

Save all the phones numbers in a database then,when the resource starts,store all the numbers in a table like this:

phoneNumbers[accountName]= thePhone number 
--The database's format should be accName TEXT,phoneNum TEXT/NUMBER 

After this,when a player uses the command /sms [number] [message] (Server) trigger a client event witch stores the message in a table

  
sendedSms={ } 
  
--When the event is triggered 
table.insert(sendedSms,sendedSms[phNumber][#sendedSms[phNumber] + 1],message)--not sure if works 
  
--the table would look like this: 
sendedSms = { 
        phNum1 = {sms1,sms2,...,smsN} 
} 
  

And when you want to make a gridlist with sms just cycle thru the messages

Im sorry i dont use numbers thing, just /sms part of name msg

Thanks xXMADEXx for your help.

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