Jump to content

[Help] gridlist


Stranger

Recommended Posts

hello guys

i have a little problem in this code :

addEventHandler("onClientMarkerHit", marker, 
function () 
guiSetVisible(win, true) 
showCursor(true) 
local pla = getPlayerFromName(getLocalPlayer()) 
for _,v in ipairs (pla) do 
guiGridListAddRow(v) 
end 
end 
) 

will i try to make the players show in the 'gridlist' but no, i don't know why, so can you help me :?:

Link to comment

You know what is getPlayerFromName does?

This is much stupid to do such thing.

You trying to get the local player using getPlayerFromName which it's require string not element and it actually make no sense to do because local player is already predefined!?

This make no sense at all.

local pla = getPlayerFromName(getLocalPlayer()) 

pla is not table and it's not even a element because it would be always false regarding to what you did above.

for _,v in ipairs (pla) do 

This is not a magic, it only will add the row and you also need to set a text to the row using guiGridListSetItemText

guiGridListAddRow(v) 

I don't understand why you did all this mess which you can simply open the wiki and copy the example of function guiGridListAddRow.

Link to comment

You can use this and be sure to replace gridList and column with your.

function updateList(old, new) 
    if eventName == "onClientPlayerJoin"  then 
        local row = guiGridListAddRow(gridList) 
        guiGridListSetItemText(gridList, row, column, getPlayerName(source), false, false) 
    elseif eventName == "onClientPlayerQuit"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == getPlayerName(source) then 
                guiGridListRemoveRow(gridList, i) 
            end 
        end 
    elseif eventName == "onClientPlayerChangeNick"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == old then 
                guiGridListSetItemText(gridList, i, column, new, false, false) 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, updateList) 
addEventHandler("onClientPlayerQuit", root, updateList) 
addEventHandler("onClientPlayerChangeNick", root, updateList) 

Link to comment

your code it's work fine, but when player join, his name don't show but the other people they can see it, but if he quit and join all the name in the grid will removed, i didn't mean like that, i mean when someone click the 'close' button then clear grid list, i wan't the grid refresh every 5 secs, is that possible ?

Link to comment

what is the problem in this code ?

addEventHandler("onClientGUIClick", root, 
function () 
local row2, col = guiGridListGetSelectedItem(grid) 
local select = guiGridListGetItemText(grid, row2, col) 
if (source == warp) then 
if select then 
triggerServerEvent("warp", getLocalPlayer()) 
end 
end 
end 
) 

server :

  
addEvent("warp", true) 
addEventHandler("warp", root, 
function () 
    x,y,z = getElementPosition(client) 
  setElementPosition(source, x+1,y+1,z+1) 
end 
) 

the problem is when i select player and press warp nothing happend, i wan't when some one select a player and press warp then warp to him

Link to comment
now i did use it with your code, but another porblem show, that if player quit "his name still in the grid list", or if he change his nick ...

That's because you didn't follow this:

You can use this and be sure to replace gridList and column with your.
what is the problem in this code ?
addEventHandler("onClientGUIClick", root, 
function () 
local row2, col = guiGridListGetSelectedItem(grid) 
local select = guiGridListGetItemText(grid, row2, col) 
if (source == warp) then 
if select then 
triggerServerEvent("warp", getLocalPlayer()) 
end 
end 
end 
) 

server :

  
addEvent("warp", true) 
addEventHandler("warp", root, 
function () 
    x,y,z = getElementPosition(client) 
  setElementPosition(source, x+1,y+1,z+1) 
end 
) 

the problem is when i select player and press warp nothing happend, i wan't when some one select a player and press warp then warp to him

addEventHandler("onClientGUIClick", root, 
function () 
    if (source == warp) then 
        local row, col = guiGridListGetSelectedItem(grid) 
        local select = guiGridListGetItemText(grid, row, col) 
        if select and select ~= "" then 
            local player = getPlayerFromName(select) 
            if player then 
                local x, y, z = getElementPosition(player) 
                setElementPosition(localPlayer, x+1, y+1, z+1) 
            end 
        end 
    end 
end) 

No need for server side.

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