Snaik Posted April 14, 2012 Share Posted April 14, 2012 function addPlayerCustomTag ( thePlayer, command, newTag ) --Let's make sure the newTag param has been entered... if ( newTag ) then --Grab their current playername for saving. local sPlayerNickname = getPlayerName ( thePlayer ) --Create their new nickname with their tag local sNewPlayerNickname = newTag .. " " .. sPlayerNickname --Let's first load the element data, see if it's there already --The reason for this is that if a player were to do /addtag twice, --the tag would be prepended a second time local sOldNick = getElementData( thePlayer, "tempdata.originalnick" ) if ( sOldNick == false ) then --Save their orignal nickname in their element data setElementData ( thePlayer, "tempdata.originalnick", sPlayerNickname ) end --Set their new nickname globally setPlayerName ( thePlayer, sNewPlayerNickname ) --Tell them it's done outputChatBox ( "Your new nickname has been set, to put it back to its original state you can use /deltag", thePlayer ) else --The newTag param was not entered, give an error message outputChatBox ( "/addtag - Incorrect syntax, Correct: /addtag ", thePlayer ) end end addCommandHandler ( "addtag", addPlayerCustomTag ) function removePlayerCustomTag ( thePlayer, command ) --We first need to check that they have already used /addtag, let's do that now local sOldNick = getElementData( thePlayer, "tempdata.originalnick" ) if ( sOldNick ) then --Great, they have a tag added, let's reset them --First we will want to reset the element data back to its default (that being false) setElementData ( thePlayer, "tempdata.originalnick", false ) --Now set the client name back setClientName ( thePlayer, sOldNick ) --Notify them outputChatBox ( "Your old nickname has been set", thePlayer ) end end addCommandHandler ( "deltag", removePlayerCustomTag ) "setElementData ( thePlayer, "tempdata.originalnick", false )" Could someone tell me what is the source of "tempdata.originalnick" , I don't get what it is ? I'm not good at english Link to comment
Aibo Posted April 15, 2012 Share Posted April 15, 2012 "tempdata.originalnick" is a string, a key used to reference the element data. it has no source. state your question/problem more clearly. Link to comment
Snaik Posted April 15, 2012 Author Share Posted April 15, 2012 (edited) Where can i get these strings ? Maybe im getting this wrong . Edited April 15, 2012 by Guest Link to comment
Aibo Posted April 15, 2012 Share Posted April 15, 2012 where did you get this script? do you have any right to publish it here? Link to comment
Snaik Posted April 15, 2012 Author Share Posted April 15, 2012 I got it from Mta sa wiki, https://wiki.multitheftauto.com/wiki/SetElementData . Link to comment
Aibo Posted April 15, 2012 Share Posted April 15, 2012 and it is explained there how it works. you get the string key from your head, keeping in mind its purpose. Link to comment
Snaik Posted April 15, 2012 Author Share Posted April 15, 2012 We can set the data of what elements ? i mean if i want to set the player's max health how can i do it ? Link to comment
arezu Posted April 15, 2012 Share Posted April 15, 2012 setElementData(player, "blabla", true) is almost the same as: local data = {} data[player] = {} data[player]["blabla"] = true with the exception that you can easily get access to the element data from any file (client and server side) and element data gets automatically removed when the element gets destroyed. setElementData can only be used on elements, and it sets a value for an unique string given by the player. Link to comment
Aibo Posted April 15, 2012 Share Posted April 15, 2012 of any element. the data you set does not affect an element behavior (unless you script it). so no, you can't change player's max health with element data. iirc you cant change player's max health anyway, unless you script your own health system or extend the existing. Link to comment
Snaik Posted April 15, 2012 Author Share Posted April 15, 2012 Now im getting what it does, thx guys . 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