Castillo Posted March 1, 2010 Share Posted March 1, 2010 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
dzek (varez) Posted March 1, 2010 Share Posted March 1, 2010 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
Castillo Posted March 1, 2010 Author Share Posted March 1, 2010 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
Castillo Posted March 2, 2010 Author Share Posted March 2, 2010 (edited) 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 March 2, 2010 by Guest Link to comment
robhol Posted March 2, 2010 Share Posted March 2, 2010 playerLoginCheckSkin (hitPlayer, ... Wait, what? Link to comment
Castillo Posted March 2, 2010 Author Share Posted March 2, 2010 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) Link to comment
Aibo Posted March 2, 2010 Share Posted March 2, 2010 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
Castillo Posted March 2, 2010 Author Share Posted March 2, 2010 Thanks guys now works Link to comment
robhol Posted March 2, 2010 Share Posted March 2, 2010 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
Castillo Posted March 2, 2010 Author Share Posted March 2, 2010 i forgot already what i tryed with "hitPlayer" but anyway now is fixed and thanks to us. now can someone tell me how to use setPlayerName using a guiEdit? Link to comment
Aibo Posted March 2, 2010 Share Posted March 2, 2010 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 Link to comment
Castillo Posted March 2, 2010 Author Share Posted March 2, 2010 thanks xbost, i wont get the script done i wanna learn miself 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