codeluaeveryday Posted October 20, 2011 Share Posted October 20, 2011 Hey guys, i am working on a small project, i need to know how to get all players into a gridlist, could i please have an example, and a brief explanation? Also can we do this with the maps (RACE)? Link to comment
^Dev-PoinT^ Posted October 20, 2011 Share Posted October 20, 2011 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
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 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 Thank you. And what about displaying all the maps? Change player? i think i can learn. Link to comment
TAPL Posted October 20, 2011 Share Posted October 20, 2011 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
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 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
TAPL Posted October 20, 2011 Share Posted October 20, 2011 use guiGridListGetSelectedItem with guiGridListGetItemText https://wiki.multitheftauto.com/wiki/Gui ... lectedItem Link to comment
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 use guiGridListGetSelectedItem with guiGridListGetItemTexthttps://wiki.multitheftauto.com/wiki/Gui ... lectedItem Thanks tapl, but its still not sending, um, ill add the takeplayercash soon, but can you explain why this isnt working for me? Maybe i gotta trigger a server event? then so be it? Link to comment
TAPL Posted October 20, 2011 Share Posted October 20, 2011 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 Link to comment
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 look at wiki examplehttps://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
TAPL Posted October 20, 2011 Share Posted October 20, 2011 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
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 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
TAPL Posted October 20, 2011 Share Posted October 20, 2011 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
^Dev-PoinT^ Posted October 20, 2011 Share Posted October 20, 2011 lol you replay fast Then me Tapl i alreday Made it lol Link to comment
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 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
TAPL Posted October 20, 2011 Share Posted October 20, 2011 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
codeluaeveryday Posted October 20, 2011 Author Share Posted October 20, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now