JR10 Posted June 23, 2011 Posted June 23, 2011 No problem. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted June 29, 2011 Author Posted June 29, 2011 I want to know how to show the amount of players on a gui, but the getPlayerCount is Server-side. this is what I have. Client-side players_on = guiCreateLabel(243,372,16,22,"0",false,rules) addEvent("players",true) addEventHandler("players",getRootElement(), function(count) guiSetText(player_on, count) end) Server-side local count = getPlayerCount triggerClientEvent("players",getRootElement(),count) If you don't get a reply by me, sorry my internet is going to be down about 1-3 days! My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted June 29, 2011 Posted June 29, 2011 (edited) --client side: players_on = guiCreateLabel(243,372,16,22,"0",false,rules) addEvent("players",true) addEventHandler("players",root, function(count) guiSetText(player_on, tostring(count)) end) --server side: addEventHandler("onPlayerJoin",root, function () local count = getPlayerCount() triggerClientEvent("players",getRootElement(),count) end) Edited June 29, 2011 by Guest San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted June 29, 2011 Author Posted June 29, 2011 it doesn't work! Edit: When someone joins, it's suppose to trigger the event and and show the amount of people/players online. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted June 29, 2011 Posted June 29, 2011 Copy the server side part again, you could have did what I changed to do what you want. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted June 29, 2011 Author Posted June 29, 2011 that's what i did, but it still shows 0 when i'm the only person online My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted June 29, 2011 Posted June 29, 2011 try this --client side addEventHandler('onClientResourceStart', resourceRoot, function() players_on = guiCreateLabel(243,372,16,22,"0",false,rules) triggerServerEvent('onDownloadingResourceFinish', root) end ) addEvent("players",true) addEventHandler("players",root, function(count) guiSetText(player_on, tostring(count)) end) --server side addEvent('onDownloadingResourceFinish', true) addEventHandler('onDownloadingResourceFinish', root, function() local count = getPlayerCount() triggerClientEvent("players",getRootElement(),count) end ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Kenix Posted June 29, 2011 Posted June 29, 2011 I create client side function : getPlayerCount = function() return #getElementsByType('player') end use it (tested). http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Jaysds1 Posted June 29, 2011 Author Posted June 29, 2011 JR10, this is part of the gui me and u were working on at the top! And volk-rus, that doesn't work! and yours too JR10. EDIT: Do you want me to upload the whole code? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted June 30, 2011 Posted June 30, 2011 here: --client side addEventHandler('onClientResourceStart', resourceRoot, function() players_on = guiCreateLabel(243,372,16,22,"0",false,rules) triggerServerEvent('onDownloadingResourceFinish', root) end ) addEvent("players",true) addEventHandler("players",root, function(count) guiSetText(players_on, tostring(count)) end) --server side addEvent('onDownloadingResourceFinish', true) addEventHandler('onDownloadingResourceFinish', root, function() local count = getPlayerCount() triggerClientEvent("players",getRootElement(),count) end ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted June 30, 2011 Author Posted June 30, 2011 thanks JR10. it worked now, How do i show how much Moderators or Admin are online? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted June 30, 2011 Posted June 30, 2011 I think this could help you: https://community.multitheftauto.com/index.php?p= ... ls&id=1029 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted June 30, 2011 Author Posted June 30, 2011 In the resource, the Admins online shows the player name, I want mine to show how much admins is online, but thanks anyways. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted June 30, 2011 Posted June 30, 2011 That's easily changeable, you just have to think for a while, and not come here and ask without even try. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted June 30, 2011 Author Posted June 30, 2011 lol, ok, I'll think first My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Kenix Posted June 30, 2011 Posted June 30, 2011 Jaysds1,oh ... You can use my function example : getPlayerCount = function() return #getElementsByType('player') end addCommandHandler('getCount',function() outputChatBox(getPlayerCount()) end) in client side http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Jaysds1 Posted June 30, 2011 Author Posted June 30, 2011 Volk-rus, I we're done with that now. I just need help with showing the amount of admins or moderators on a gui. thank u though My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 1, 2011 Posted July 1, 2011 local admins = {} for i, v in ipairs(getElementsByType('player')) do --if isPlayerAdmin then check if the player is admin table.insert(admins, v) --end end triggerClientEvent('admins', root, #admins) and the client event is the same guiSetText or something. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 1, 2011 Author Posted July 1, 2011 so this is the same thing as the players online function but just change the server-side function? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 1, 2011 Posted July 1, 2011 Well, yeah it's the same client side but change it server side like mine. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 1, 2011 Author Posted July 1, 2011 the debugscript says that the client side: <name> or '...' expected near ' # '. This is my code, Client-side: addEvent("admins",true) addEventHandler("admins", root, function(#admins) guiSetText(admins_on, tostring(#admin)) end) addEvent("mods",true) addEventHandler("mods", root, function(#mods) guiSetText(mods_on, tostring(#mods)) end) I used the code you gave me. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 1, 2011 Posted July 1, 2011 Remove that # client side but keep it server side. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 1, 2011 Author Posted July 1, 2011 It doesn't show that 1 admin is online. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 1, 2011 Posted July 1, 2011 Did you edit the server? and show me the full code now. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 1, 2011 Author Posted July 1, 2011 Server-side local admins = {} for i, v in ipairs(getElementsByType('player')) do --if isPlayerAdmin then check if the player is admin table.insert(admins, v) --end end triggerClientEvent('admins', root, #admins) local mods = {} for i, v in ipairs(getElementsByType('player')) do --if isPlayerAdmin then check if the player is admin table.insert(mods, v) --end end triggerClientEvent('mods', root, #mods) Client-side addEvent("admins",true) addEventHandler("admins", root, function(admins) guiSetText(admins_on, tostring(#admin)) end) addEvent("mods",true) addEventHandler("mods", root, function(mods) guiSetText(mods_on, tostring(#mods)) end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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