Jump to content

update player list on nick change


Fist

Recommended Posts

Hello!

How i could find player name in gridlist when he changes name and update's it with the new name in gridlist?

i tried this but didnt work, it gave me errors that he gets boolen or user data i tried to use tostring() also getPlayerName(), didnt work either.

client code:

  
function updatePlayerList(oldNick,newNick) 
    if string.find(oldNick,gridlistPlayers1) then 
        guiGridListSetItemText(gridlistPlayers1, 0, string.find(oldNick,gridlistPlayers1), newNick, false, false) 
    end 
end 
addEvent("updatePlayerList",true) 
addEventHandler("updatePlayerList",root,updatePlayerList) 
  

server code:

  
function updatePlayerListOnNickChange(oldNick,newNick) 
    triggerClientEvent(source,"updatePlayerList",source,oldNick,newNick) 
end 
addEventHandler("onPlayerChangeNick",root,updatePlayerListOnNickChange) 
  

Link to comment
whats the line number that has error, post the full error please

its wroten in topic, error is that he gets userdata or boolen, even tough i convert oldNick and newNick to string or to playerName

anyway here is image

R66uRSQ.png

its 3th line in client side script.

Link to comment

this is strange, i guess its caused because you passed source then oldNick then newNick to updatePlayer function, here:

triggerClientEvent(source,"updatePlayerList",source,oldNick,newNick) 

try this:

triggerClientEvent(source,"updatePlayerList",oldNick,newNick, source) 

Link to comment
i dont think string.find is the function you wanna use, it returns the number where the string starts and ends

example: string.find("i will say YES", "will") -- returns >> 3 6

http://www.lua.org/pil/20.1.html

no i needed to use it, i just made it work with my friends help, he explained me how it works. :D

and btw your code what u gave me about triggering client event, was wrong either. So please learn first by your self scripting before helping others.

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