Jump to content

set nick


Castillo

Recommended Posts

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (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 by Guest

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

playerLoginCheckSkin (hitPlayer, ...

Wait, what?

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

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)

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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)

?

Posted

Thanks guys now works :D

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

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?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

?

Posted

thanks xbost, i wont get the script done i wanna learn miself :D

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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