Jump to content

Help pls


TheIceman1

Recommended Posts

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

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

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

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