Jump to content

set nick


Castillo

Recommended Posts

hi, im trying to get the name from a edit then setPlayerName from that edit, how would i do that?

edit: also how i can do to show a window only one time to every new player, i mean when a player already saw that window he wont get it again on next time. i hope someone understand what i mean ;)

sorry for bad english

Link to comment

so you have nothing?

did you try anthing btw? or wanting us to do that?

make a gui, triggerServerEvent, and to save the info that window was already shown you can use account data, sql, or xml.

and important information:

when you change someones name, it will be restored for him/her after disconnecting. so if you do that window to prevent "Player"'s to be on server, thats not a good idea to show that window once

Link to comment

the window is a skin selector window, and i want only 1 time show it to the player cause with that way nobody will use the skin shop and i dont like that idea, so i wanted to show one time the select window to every new player in server.

Link to comment

ok well i did a account data but dont works it says bad argument when setAccountData and getAccountData when a player login, here is my code.

function playerLoginCheckSkin (hitPlayer,thePreviousAccount, theCurrentAccount, autoLogin)
local accountData = getAccountData (theCurrentAccount, "rpg-skins")
if not (accountData) then
     skin = setAccountData (theCurrentAccount, "rpg-skins", 15)
triggerClientEvent ("showWin", getRootElement(), hitPlayer)	  
if (accountData) then	
triggerClientEvent ("dontShowWin", getRootElement(), hitPlayer)	  	
end
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLoginCheckSkin)

Edited by Guest
Link to comment

he means that this line should not be like this *)

player events are sending player element as the source, so hitPlayer is not needed there:

function playerLoginCheckSkin (thePreviousAccount, theCurrentAccount, autoLogin)
local accountData = getAccountData (theCurrentAccount, "rpg-skins")
if not accountData then
setAccountData (theCurrentAccount, "rpg-skins", 15)
triggerClientEvent (source, "showWin", getRootElement())    
else   
triggerClientEvent (source, "dontShowWin", getRootElement())        
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLoginCheckSkin)

(also, player you wish to trigger the event for must go in the first parameter of triggerClientEvent)

Link to comment
u mean that this line should be like this? because i got same problem, so if u can be a bit more expecific.

function playerLoginCheckSkin (hitPlayer,thePreviousAccount, theCurrentAccount, autoLogin)

My point was, what are you doing, inserting completely random arguments into handler functions - it will screw up and that's guaranteed because that's how function arguments work in Lua - the order is everything, the names are completely arbitrary and insignificant.

As I thought should be fairly obvious once I showed you it was there, the issue here is the "hitPlayer" argument that has no connection whatsoever with a login event. What did you even put it there for?

Link to comment

client part:

-- this goes into your button click event:
local playerName = guiGetText(yourGuiElementWithPlayerName)
if playerName then 
triggerServerEvent("nameChangeRequest", getLocalPlayer(), playerName)
else 
outputChatBox("Please enter the name")
end

server:

addEvent("nameChangeRequest", true) 
addEventHandler("nameChangeRequest", getRootElement(), 
function(playerName)
setPlayerName(source, playerName)
end
)

something like that.

of course you can add some more checks like if newname == currentname or some unwanted symbols,

well i can too, but i had no sleep for 20 hours :D

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