TheIceman1 Posted February 27, 2013 Share Posted February 27, 2013 Why this dont show me(name,team,gang,role...) on labels?No errors function setplayerinf() local playerName = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local name = getPlayerName( playerName ) local team = getPlayerTeam( playerName ) local role = getElementData( playerName, "Role" ) local gang = getElementData ( playerName, "gang" ) local wl = getPlayerWantedLevel ( playerName ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[2], "Team:"..team ) guiSetText ( GUIEditor_Label[3], "Role:"..role ) guiSetText ( GUIEditor_Label[6], "Gang:"..gang ) end addEventHandler ( "onClientGUIclick", GUIEditor_Button[1], setplayerinf ) Link to comment
tosfera Posted February 27, 2013 Share Posted February 27, 2013 Why this dont show me(name,team,gang,role...) on labels?No errors function setplayerinf() local playerName = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local name = getPlayerName( playerName ) local team = getPlayerTeam( playerName ) local role = getElementData( playerName, "Role" ) local gang = getElementData ( playerName, "gang" ) local wl = getPlayerWantedLevel ( playerName ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[2], "Team:"..team ) guiSetText ( GUIEditor_Label[3], "Role:"..role ) guiSetText ( GUIEditor_Label[6], "Gang:"..gang ) end addEventHandler ( "onClientGUIclick", GUIEditor_Button[1], setplayerinf ) why are you using playerName, and not getLocalPlayer()? local name = getPlayerName( getLocalPlayer() ) local team = getPlayerTeam( getLocalPlayer() ) local role = getElementData( getLocalPlayer() , "Role" ) local gang = getElementData ( getLocalPlayer() , "gang" ) or if you want to get it from a gridview list, just get the data out of the row you selected. Much easier. Link to comment
Castillo Posted February 27, 2013 Share Posted February 27, 2013 To get the data of the selected player you must use getPlayerFromName. function setplayerinf ( ) local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( GUIEditor_Grid[1], row, 1 ) local player = getPlayerFromName ( playerName ) if ( player ) then local name = getPlayerName( player ) local team = getPlayerTeam( player ) local role = getElementData( player, "Role" ) local gang = getElementData ( player, "gang" ) local wl = getPlayerWantedLevel ( player ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[2], "Team:"..team ) guiSetText ( GUIEditor_Label[3], "Role:"..role ) guiSetText ( GUIEditor_Label[6], "Gang:"..gang ) end end end addEventHandler ( "onClientGUIclick", GUIEditor_Button[1], setplayerinf, false ) The wanted level part won't work, because getPlayerWantedLevel returns the local player wanted level if you use it client side, you can't get a remote player's wanted level. Link to comment
TheIceman1 Posted February 28, 2013 Author Share Posted February 28, 2013 To get the data of the selected player you must use getPlayerFromName. function setplayerinf ( ) local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( GUIEditor_Grid[1], row, 1 ) local player = getPlayerFromName ( playerName ) if ( player ) then local name = getPlayerName( player ) local team = getPlayerTeam( player ) local role = getElementData( player, "Role" ) local gang = getElementData ( player, "gang" ) local wl = getPlayerWantedLevel ( player ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[2], "Team:"..team ) guiSetText ( GUIEditor_Label[3], "Role:"..role ) guiSetText ( GUIEditor_Label[6], "Gang:"..gang ) end end end addEventHandler ( "onClientGUIclick", GUIEditor_Button[1], setplayerinf, false ) The wanted level part won't work, because getPlayerWantedLevel returns the local player wanted level if you use it client side, you can't get a remote player's wanted level. Nothing happens. Link to comment
Vision Posted February 28, 2013 Share Posted February 28, 2013 onClientGUIclick Should be onClientGUIClick Link to comment
TheIceman1 Posted February 28, 2013 Author Share Posted February 28, 2013 But why this doesn't shows player team? function setplayerinf ( ) local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( GUIEditor_Grid[1], row, 1 ) local player = getPlayerFromName ( playerName ) if ( player ) then local name = getPlayerName( player ) local team = getPlayerTeam ( player ) local tname = getTeamName ( team ) local role = getElementData( player, "Role" ) local gang = getElementData ( player, "gang" ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[2], "Team:"..tname ) guiSetText ( GUIEditor_Label[3], "Role:"..role ) guiSetText ( GUIEditor_Label[6], "Gang:"..gang ) end end end addEventHandler ( "onClientGUIClick", GUIEditor_Grid[1], setplayerinf, false ) Link to comment
Castillo Posted February 28, 2013 Share Posted February 28, 2013 The player has a team? Link to comment
TheIceman1 Posted February 28, 2013 Author Share Posted February 28, 2013 The player has a team? Yes Link to comment
Castillo Posted February 28, 2013 Share Posted February 28, 2013 Do you get any error on debugscript? since this a client side script, the error won't appear on the server console. Link to comment
TheIceman1 Posted February 28, 2013 Author Share Posted February 28, 2013 Do you get any error on debugscript? since this a client side script, the error won't appear on the server console. Fixed. 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