Jump to content

Getting all players into a gridlist?


Recommended Posts

you mean like this

function createPlayerList () 
    --Create the grid list element 
    local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    --Create a players column in the list 
    local column = guiGridListAddColumn( playerList, "Player", 0.85 ) 
    if ( column ) then --If the column has been created, fill it with players 
        for id, player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow ( playerList ) 
            guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
        end 
    end 
end 

?

Link to comment
you mean like this
function createPlayerList () 
    --Create the grid list element 
    local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    --Create a players column in the list 
    local column = guiGridListAddColumn( playerList, "Player", 0.85 ) 
    if ( column ) then --If the column has been created, fill it with players 
        for id, player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow ( playerList ) 
            guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) 
        end 
    end 
end 

?

Thank you, ill remember the get elements by type now :D Thank you.

And what about displaying all the maps? Change player? i think i can learn.

Link to comment

for maps you will need to get all resources (table) and get the resource name and get Resource Info to check if is map and the gamemodes is race then trigger it to client and place them into a gridlist

[url=https://wiki.multitheftauto.com/wiki/GetResources]https://wiki.multitheftauto.com/wiki/GetResources[/url] 
[url=https://wiki.multitheftauto.com/wiki/GetResourceName]https://wiki.multitheftauto.com/wiki/GetResourceName[/url] 
[url=https://wiki.multitheftauto.com/wiki/GetResourceInfo]https://wiki.multitheftauto.com/wiki/GetResourceInfo[/url] 

Link to comment

I am trying to make a send money tab in my GUI, this wont work, plus i get errors for the first part.

Whats wrong with this:

    local sharemoneylistplayers = guiCreateGridList(4,32,228,213,false,GUIEditor_Tab[1]) 
    local sharemoneycolumn = guiGridListAddColumn( sharemoneylistplayers, "Player", 0.85 ) 
    if ( sharemoneycolumn ) then 
        for id, player in ipairs(getElementsByType("player")) do 
            local sharemoneyrow = guiGridListAddRow ( sharemoneylistplayers ) 
            guiGridListSetItemText ( sharemoneylistplayers, sharemoneyrow, sharemoneycolumn, getPlayerName ( player ), false, false ) 
        end 
    end 
  
    function sendmoney() 
    local getmoney = guiGetText (editboxmoneyamount) 
    local getplayer = guiGridListGetItemText ( sharemoneylistplayers, sharemoneyrow, sharemoneycolumn) 
    givePlayerMoney (getplayer,getmoney) 
    local name = getPlayerName(getLocalPlayer()) 
    outputChatBox(name.." has sent "..getmoney.." to "..getplayer.."!",getRootElement(), 0,255,0,true) 
    end 
addEventHandler ( "onClientGUIClick", sendmoneybutton, sendmoney, false ) 

Link to comment
look at wiki example

https://wiki.multitheftauto.com/wiki/Gui ... lectedItem

make it Server Side better becuase getRootElement() on outputChatBox won't work in Client side

D: ehh, this isnt working ive tried alot of attempts, i dont understand, i sware scripting is in my blood... I just need some boosters.

Client:

  
    local sharemoneylistplayers = guiCreateGridList(4,32,228,213,false,GUIEditor_Tab[1]) 
    local sharemoneycolumn = guiGridListAddColumn( sharemoneylistplayers, "Player", 0.85 ) 
    if ( sharemoneycolumn ) then 
        for id, player in ipairs(getElementsByType("player")) do 
            local sharemoneyrow = guiGridListAddRow ( sharemoneylistplayers ) 
            guiGridListSetItemText ( sharemoneylistplayers, sharemoneyrow, sharemoneycolumn, getPlayerName ( player ), false, false ) 
        end 
    end 
  
function sendmoney() 
        local getmoney = guiGetText (editboxmoneyamount) 
    local getplayer = guiGridListGetItemText ( sharemoneylistplayers, guiGridListGetSelectedItem ( sharemoneylistplayers ), 1 ) 
    triggerServerEvent("sendmoney",getmoney,getplayer, getLocalPlayer()) 
    end 

and server:

addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    givePlayerMoney (getplayer,getmoney) 
    outputChatBox(name.." has sent "..getmoney.." to "..getplayer.."!",getRootElement(), 0,255,0,true) 
end 

I really dont understand...

Link to comment

where the event in client side?

triggerServerEvent("sendmoney",getLocalPlayer(),getmoney,getplayer) 

addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..toWho.."!",getRootElement(), 0,255,0,true) 
end 

Link to comment
where the event in client side?
triggerServerEvent("sendmoney",getLocalPlayer(),getmoney,getplayer) 

addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..toWho.."!",getRootElement(), 0,255,0,true) 
end 

Thank you TAPL, its just one step away, it says its not added serverside.. It is added in the server side, my other button works which trigger's server side, please help, this is really the hardest tab out of the rest. Its for my zombie server, please help. I put hours into the panel, and now i am willing to put 100x more hours!

Link to comment
addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..toWho.."!",getRootElement(), 0,255,0,true) 
end) 

you was forgot ")" in last line

Link to comment
addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..toWho.."!",getRootElement(), 0,255,0,true) 
end) 

you was forgot ")" in last line

Thank you, it is just one line away from success?

local toWho = getPlayerFromName (getplayer)

this line says it cant concatenate local toWho (a userdata value)?

Link to comment

oh lol

addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..getplayer.."!",root, 0,255,0,true) 
end) 

Link to comment
oh lol
addEvent("sendmoney",true) 
addEventHandler("sendmoney", getRootElement(), 
function (getmoney,getplayer) 
    local name = getPlayerName(source) 
    local toWho = getPlayerFromName (getplayer) 
    givePlayerMoney (toWho,tonumber(getmoney)) 
    takePlayerMoney(source,tonumber(getmoney)) 
    outputChatBox(name.." has sent "..tonumber(getmoney).." to "..getplayer.."!",root, 0,255,0,true) 
end) 

OMG OMG OMG, thank you Tapl

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