Jump to content

PM system


Mann56

Recommended Posts

Posted

Hey there, I need some help i have created a gridlist which gets all player names but i can't figure out how to send the selected player the message . I used the following function.

 pmer = localPlayer 
     selectedPlayer = guiGridListGetSelectedItem(gridThing) 
     guiSetInputEnabled(true) 
     pmto = getPlayerFromName(selectedPlayer) 
     text = guiGetText(editBox) 
     outputChatBox("[PM] -> "..selectedPlayer.." : "..text.."",localPlayer,255,255,0) 
     outputChatBox("[PM] -> "..pmer.." : "..text.."",selectedPlayer,255,255,0) 

As i am alone on my local i exactly dont know will it work but is the function guiGridListGetSelectedItem ok? As there is no related function other than this.

I would look for some help....

Thanks...

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

no, you need to use guiGridListGetItemText.

local playerName = guiGridListGetItemText(gridThing,row,Column) 
local player = getPlayerFromName(playerName) 
if player then 
  
end  

and the outputChatBox must be server side.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
no, you need to use guiGridListGetItemText.
local playerName = guiGridListGetItemText(gridThing,row,Column) 
local player = getPlayerFromName(playerName) 
if player then 
  
end  

and the outputChatBox must be server side.

Thanks the functions were a bit complicated by names and so i must trigger sver event?

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

Thanks the functions were a bit complicated by names and so i must trigger sver event?

Yeh, example

function SendMessage () 
    local row,column = guiGridListGetSelectedItem (gridThing) 
        if row == -1 then return end 
            if row and column and row >=0 and column >=0 then 
            local playerName = guiGridListGetItemText(gridThing,row,colmun) 
            local player = getPlayerFromName(playerName) 
            if player then 
                local text = guiGetText(editBox) 
                if text then 
                    triggerServerEvent( "onPlayerSendPM", localPlayer,text, player) 
                guiSetText (editBox, "" )            
            end 
        end 
    end 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Dude the trigger server event has 4 args?

Edit : Dude ain't working here's my code:

Client:

local pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) 
gridThing = guiCreateGridList(12, 29, 331, 468, false, pmWindow) 
column = guiGridListAddColumn(gridThing, "Name", 0.9) 
editBox = guiCreateEdit(15, 510, 291, 29, "", false, pmWindow) 
closeButton = guiCreateButton(315, 509, 28, 30, "Send", false, pmWindow) 
guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") 
guiSetVisible(pmWindow, false)  
showCursor(false)  
  
local pmEnabled = false 
  
function dxText () 
    if not pmEnabled then return end  
    dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender", root, dxText) 
  
function togglePM () 
    pmEnabled = not pmEnabled  
    guiSetVisible(pmWindow, pmEnabled)  
    showCursor(pmEnabled)  
     
end 
bindKey("F3","up", togglePM) 
  
function showDxText() 
addEventHandler("onClientRender", root, 
    function() 
        dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
    end 
) 
end 
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
  
function () 
for i,v in pairs(getElementsByType("player")) do  
       row = guiGridListAddRow(gridThing) 
       guiGridListSetItemText ( gridThing, row, column, getPlayerName ( v ), false, false ) 
end 
       
end 
  
) 
  
function SendMessage () 
     pmer = localPlayer 
    local row,column = guiGridListGetSelectedItem (gridThing) 
        if row == -1 then return end 
            if row and column and row >=0 and column >=0 then 
            local playerName = guiGridListGetItemText(gridThing,row,colmun) 
            local player = getPlayerFromName(playerName) 
            if player then 
                local text = guiGetText(editBox) 
                if text then 
                    triggerServerEvent( "onPlayerSendPM", localPlayer,text, player) 
                guiSetText (editBox, "" )           
            end 
        end 
    end 
end 
addEventHandler("onClientGuiClick",closeButton,SendMessage) 
  

Server

addEvent("onPlayerSendPm",true) 
addEventHandler("onPlayerSendPm",resourceRoot, 
function (text,player,) 
outputChatBox("[PM] -> "..player.." : "..text.."",client,255,255,0) 
outputChatBox("[PM] -> "..pmer.." : "..text.."",player,255,255,0) 
end 
) 

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

Many things wrong in your code

pmer it's not defined here

eafe44e529.png

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Many things wrong in your code

pmer it's not defined here

eafe44e529.png

it's defined in client

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

it's defined in client

are you serious so why you use it server side ???

anyways try this

-- Client side

local pmEnabled = false 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function () 
    pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) 
    gridThing = guiCreateGridList(12, 29, 331, 468, false, pmWindow) 
    column = guiGridListAddColumn(gridThing, "Name", 0.9) 
    editBox = guiCreateEdit(15, 510, 291, 29, "", false, pmWindow) 
    closeButton = guiCreateButton(315, 509, 28, 30, "Send", false, pmWindow) 
    guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") 
    guiSetVisible(pmWindow, false) 
    showCursor(false) 
     
    addEventHandler("onClientGuiClick",closeButton,SendMessage,false) 
end  
) 
  
  
function dxText () 
    if not pmEnabled then return end 
    dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
addEventHandler("onClientRender", root, dxText) 
  
function togglePM () 
    pmEnabled = not pmEnabled 
    guiSetVisible(pmWindow, pmEnabled) 
    showCursor(pmEnabled) 
    for i,v in pairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(gridThing) 
       guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) 
    end 
end 
bindKey("F3","up", togglePM) 
  
  
function SendMessage () 
    local row,column = guiGridListGetSelectedItem (gridThing) 
        if row == -1 then return end 
            if row and column and row >=0 and column >=0 then 
            local playerName = guiGridListGetItemText(gridThing,row,colmun) 
            local player = getPlayerFromName(playerName) 
            if player then 
                local text = guiGetText(editBox) 
                if text =~ "" then 
                    triggerServerEvent( "onPlayerSendPM",resourceRoot,text, player) 
                guiSetText (editBox, "" )           
            end 
        end 
    end 
end 
  

-- Server side

addEvent("onPlayerSendPm",true) 
addEventHandler("onPlayerSendPm",resourceRoot, 
    function (text,player) 
    outputChatBox("[PM] -> "..getPlayerName(player).." : "..text.."",client,255,255,0) 
    outputChatBox("[PM] -> "..getPlayerName(client).." : "..text.."",player,255,255,0) 
end 
) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted (edited)
Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c

simply you need to use "guiGridListClear()" before you add player names inside the gridlist.

Edited by Guest

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Dude i cant see the pm messages still and when i close f3 and again open it my name instead of showing one time shows three times :c

simply you do use "guiGridListClear()" before you add player names inside the gridlist.

oh, i gotta go through all gui functions

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

oh, i gotta go through all gui functions

function togglePM () 
    pmEnabled = not pmEnabled 
    guiSetVisible(pmWindow, pmEnabled) 
    showCursor(pmEnabled) 
    guiGridListClear (gridThing) 
    for i,v in pairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(gridThing) 
       guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) 
    end 
end 
bindKey("F3","up", togglePM) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

oh, i gotta go through all gui functions

function togglePM () 
    pmEnabled = not pmEnabled 
    guiSetVisible(pmWindow, pmEnabled) 
    showCursor(pmEnabled) 
    guiGridListClear (gridThing) 
    for i,v in pairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(gridThing) 
       guiGridListSetItemText ( gridThing, row, column, getPlayerName( v ), false, false ) 
    end 
end 
bindKey("F3","up", togglePM) 

Working now nvm there were some spelling mistakes LOL

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

Posted

Working now nvm there were some spelling mistakes LOL

there is many thig wrong in your code. sorry i don't have time to fix them all

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

It's fixed ;)

"When i'll grow older, i'll be stronger, they'll call me freedom, just like a waving flag"

"Have confidence in yourself, no problem is impossible in life"

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