Wei Posted May 3, 2012 Posted May 3, 2012 Hi. I don't know how to add players to grid and how I can get selected item, how can I remove blip. Please help me. This is my gui: playerBlipWindow = guiCreateWindow(384,150,199,294,"Player blip panel",false) guiWindowSetSizable(playerBlipWindow,false) gridListOfPlayers = guiCreateGridList(9,23,181,201,false,playerBlipWindow) guiGridListSetSelectionMode(gridListOfPlayers,2) guiGridListAddColumn(gridListOfPlayers,"Players",0.2) blipUnblipBut = guiCreateButton(9,232,85,52,"Blip/ \n Unblip",false,playerBlipWindow) closeBut = guiCreateButton(97,233,85,52,"Close",false,playerBlipWindow) Diet with russian vodka, lose 3 days in one week !
Castillo Posted May 3, 2012 Posted May 3, 2012 playerBlipWindow = guiCreateWindow(384,150,199,294,"Player blip panel",false) guiWindowSetSizable(playerBlipWindow,false) gridListOfPlayers = guiCreateGridList(9,23,181,201,false,playerBlipWindow) guiGridListAddColumn(gridListOfPlayers,"Players",0.2) blipUnblipBut = guiCreateButton(9,232,85,52,"Blip/ \n Unblip",false,playerBlipWindow) closeBut = guiCreateButton(97,233,85,52,"Close",false,playerBlipWindow) function loadPlayers ( ) guiGridListClear ( gridListOfPlayers ) -- Clear current items. for index, player in ipairs ( getElementsByType ( "player" ) ) do -- Loop the current players. guiGridListSetItemText ( gridListOfPlayers, guiGridListAddRow ( gridListOfPlayers ), 1, tostring ( getPlayerName ( player ) ), false, false ) -- Add a row and set the text to the player name. end end addEventHandler ( "onClientResourceStart", resourceRoot, loadPlayers ) addEventHandler ( "onClientPlayerJoin", root, loadPlayers ) addEventHandler ( "onClientPlayerQuit", root, loadPlayers ) addEventHandler ( "onClientPlayerChangeNick", root, loadPlayers ) As for blips you must use: createBlipAttachedTo destroyElement San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Wei Posted May 3, 2012 Author Posted May 3, 2012 Thank you !! Diet with russian vodka, lose 3 days in one week !
Castillo Posted May 3, 2012 Posted May 3, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Wei Posted May 3, 2012 Author Posted May 3, 2012 (edited) function randomFunction(button) if (button) ~= "left" then return end if (source == closeBut) then guiSetVisible( playerBlipWindow, false) showCursor(false) elseif ( source == blipUnblipBut ) then local playerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) playerBlip = createBlipAttachedTo( playerName, 40 ) setElementData(getLocalPlayer(), "isPlayerBlipped", true) elseif ( getElementData(getLocalPlayer(), "isPlayerBlipped", true)) and (source == blipUnblipBut) then destroyElement(playerBlip) setElementData(getLocalPlayer(), "isPlayerBlipped", false) end end addEventHandler("onClientGUIClick", resourceRoot, randomFunction, true) Whats wrong. Error: Bag argument @ createBlipAttachedTo Edited May 3, 2012 by Guest Diet with russian vodka, lose 3 days in one week !
Kenix Posted May 3, 2012 Posted May 3, 2012 (edited) Whats wrong. Error: Bag argument @ createBlipAttachedTo CUT local playerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) playerBlip = createBlipAttachedTo( playerName, 40 ) You use string. But you need use element. Read arguments. getPlayerFromName Edited May 3, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Wei Posted May 3, 2012 Author Posted May 3, 2012 It doesn't open the window. Whats wrong ? You not make your window showing. Edited. I forgot then at the end. Window is working now but it doesn't blip player Diet with russian vodka, lose 3 days in one week !
Kenix Posted May 3, 2012 Posted May 3, 2012 Updated http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Wei Posted May 3, 2012 Author Posted May 3, 2012 Blip works now but Unblip doesn't Diet with russian vodka, lose 3 days in one week !
Wei Posted May 3, 2012 Author Posted May 3, 2012 same... it only make more blips on it Diet with russian vodka, lose 3 days in one week !
Kenix Posted May 3, 2012 Posted May 3, 2012 local pPlayerBlip function randomFunction( sButton ) if sButton ~= 'left' then return end if source == closeBut then guiSetVisible( playerBlipWindow, false ) showCursor( false ) elseif source == blipUnblipBut then local sPlayerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) if pPlayerBlip then -- Check destroyElement( pPlayerBlip ) -- Delete end pPlayerBlip = createBlipAttachedTo( sPlayerName, 40 ) end end addEventHandler( 'onClientGUIClick', guiRoot, randomFunction, true ) -- Use guiRoot instead of resourceRoot ? Updated. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Wei Posted May 3, 2012 Author Posted May 3, 2012 Same again... Diet with russian vodka, lose 3 days in one week !
Jaysds1 Posted May 3, 2012 Posted May 3, 2012 try this: function randomFunction(button) if (button) == "left" then if (source == closeBut) then guiSetVisible( playerBlipWindow, false) showCursor(false) elseif ( source == blipUnblipBut ) then playerBlip = createBlipAttachedTo( playerName, 40 ) local playerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", true) if(getElementData(getPlayerFromName(playerName), "isPlayerBlipped"))then destroyElement(playerBlip) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", false) end end end end addEventHandler("onClientGUIClick", guiRoot,randomFunction, true) 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/
Wei Posted May 4, 2012 Author Posted May 4, 2012 Don't work... Diet with russian vodka, lose 3 days in one week !
Wei Posted May 4, 2012 Author Posted May 4, 2012 If you just copied, it will never work. I did not only copy it I've added the getPlayerFromName and stuff but not work Diet with russian vodka, lose 3 days in one week !
Jaysds1 Posted May 4, 2012 Posted May 4, 2012 try this now: addEventHandler("onClientGUIClick", guiRoot,function(button) if (button) == "left" then if (source == closeBut) then guiSetVisible( playerBlipWindow, false) showCursor(false) elseif ( source == blipUnblipBut ) then playerBlip = createBlipAttachedTo( playerName, 40 ) local playerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", true) if(getElementData(getPlayerFromName(playerName), "isPlayerBlipped"))then destroyElement(playerBlip) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", false) end end end end,false) 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/
Wei Posted May 4, 2012 Author Posted May 4, 2012 now both buttons doesn't work and no errors Diet with russian vodka, lose 3 days in one week !
Michael# Posted May 4, 2012 Posted May 4, 2012 addEventHandler ( 'onClientGUIClick', root, function ( btnSide ) if ( btnSide == 'left' ) then if ( source == closeBut ) then guiSetVisible ( playerBlipWindow, false ) showCursor ( false ) elseif ( source == blipUnblipBut ) then local uRow, uCol = guiGridListGetSelectedItem ( gridListOfPlayers ) if ( uRow and uCol and uRow ~= -1 and uCol ~= -1 ) then local playerName = guiGridListGetItemText ( gridListOfPlayers, uRow, uCol ) local playerBlip = createBlipAttachedTo ( getPlayerFromName ( playerName ), 40 ) setElementData ( getPlayerFromName ( playerName ), 'isPlayerBlipped', true ) end end end end ) You should use a var or button text to know if player is 'blipped' or not.
Jaysds1 Posted May 4, 2012 Posted May 4, 2012 Sorry, I found my mistake: addEventHandler("onClientGUIClick", guiRoot,function(button) if (button == "left") then if (source == closeBut) then guiSetVisible( playerBlipWindow, false) showCursor(false) elseif ( source == blipUnblipBut ) then local playerName = guiGridListGetItemText ( gridListOfPlayers, guiGridListGetSelectedItem ( gridListOfPlayers ), 1 ) if(getElementData(getPlayerFromName(playerName), "isPlayerBlipped"))then destroyElement(playerBlip) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", false) else playerBlip = createBlipAttachedTo( playerName, 40 ) setElementData(getPlayerFromName(playerName), "isPlayerBlipped", true) end end end end,true) 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/
Wei Posted May 4, 2012 Author Posted May 4, 2012 Jayz your code is not working Jaysds1 your code is workin thank you very much Diet with russian vodka, lose 3 days in one week !
Michael# Posted May 4, 2012 Posted May 4, 2012 Obviously don't work, you just copy the codes. You don't even see what I say.
Jaysds1 Posted May 4, 2012 Posted May 4, 2012 Jayz your code is not workingJaysds1 your code is workin thank you very much np 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