King12 Posted September 22, 2014 Share Posted September 22, 2014 Hello, I've used this function getPlayerFromPartialName : function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end it worked fine with my AddCommandHandler event, but when it outputs the name, you will see the name you wrote. for example, my name is King12 if I write /setxp Ki 1000 it will output Ki only not my full name.. My codes : addCommandHandler ( "setlevel", function( thePlayer, _, playerName, Level ) local Level = tonumber ( Level ) or 0 local ThePlayer = getPlayerFromPartialName(playerName) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then if ( ThePlayer ) then setElementData( ThePlayer,"Level",Level ) outputChatBox ( "Succesfully set " ..playerName.. "#00C800's Level to "..Level.." !", getRootElement(), 0, 200, 0, true , source ) triggerClientEvent(ThePlayer, 'LevelSound', ThePlayer ) else outputChatBox ( "Couldn't find '" ..playerName1.. "#00C800'", getRootElement(), 200, 0, 0, true , source ) end end end ) Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 (edited) addCommandHandler ( "setlevel", function( thePlayer, _, playerName, Level ) local Level = tonumber ( Level ) or 0 local ThePlayer = getPlayerFromPartialName(tostring(playerName)) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then if ( ThePlayer ) then setElementData( ThePlayer,"Level",Level ) outputChatBox ( "Succesfully set " ..getPlayerName(ThePlayer).. "#00C800's Level to "..Level.." !", getRootElement(), 0, 200, 0, true , source ) triggerClientEvent(ThePlayer, 'LevelSound', ThePlayer ) else outputChatBox ( "Couldn't find '" ..playerName1.. "#00C800'", getRootElement(), 200, 0, 0, true , source ) end end end ) Edited September 22, 2014 by Guest Link to comment
#DRAGON!FIRE Posted September 22, 2014 Share Posted September 22, 2014 (edited) try this : addCommandHandler ( "setlevel", function( thePlayer, _, playerName, Level ) local Level = tonumber ( Level ) or 0 local ThePlayer = getPlayerFromPartialName(playerName) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then if ( ThePlayer ) then setElementData( ThePlayer,"Level",Level ) outputChatBox ( "Succesfully set " ..getPlayerName ( ThePlayer ).. "#00C800's Level to "..Level.." !", thePlayer, 0, 200, 0, true ) triggerClientEvent(ThePlayer, 'LevelSound', ThePlayer ) else outputChatBox ( "Couldn't find '" ..playerName.. "#00C800'", thePlayer, 200, 0, 0, true ) end end end ) Edited September 22, 2014 by Guest Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 try this : addCommandHandler ( "setlevel", function( thePlayer, _, playerName, Level ) local Level = tonumber ( Level ) or 0 local ThePlayer = getPlayerFromPartialName(playerName) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then if ( ThePlayer ) then setElementData( ThePlayer,"Level",Level ) outputChatBox ( "Succesfully set " ..getPlayerName ( playerName ).. "#00C800's Level to "..Level.." !", thePlayer, 0, 200, 0, true ) triggerClientEvent(ThePlayer, 'LevelSound', ThePlayer ) else outputChatBox ( "Couldn't find '" ..playerName.. "#00C800'", thePlayer, 200, 0, 0, true ) end end end ) Wait? getPlayerName with a text which is not a string? First arguement should be the player element shouldn't it be? Link to comment
King12 Posted September 22, 2014 Author Share Posted September 22, 2014 Thanks alot guys.. :> Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 Thanks alot guys.. :> No problem! Link to comment
#DRAGON!FIRE Posted September 22, 2014 Share Posted September 22, 2014 it's not needed tostring . Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 it's not needed tostring . And IS IT A PLAYER ELEMENT? Link to comment
#DRAGON!FIRE Posted September 22, 2014 Share Posted September 22, 2014 what u mean ! ? Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 what u mean ! ? No need to argue. Please don't reply, you should understand your mistake. If you use getPlayerName with "ki" it will not work. getPlayerName needs a element which is a player not player's name. Check out wiki. He defined ThePlayer with the function which returns the player name so you can use getPlayerName on it. Your arguement was wrong. You should've used ThePlayer. Link to comment
#DRAGON!FIRE Posted September 22, 2014 Share Posted September 22, 2014 Yea i don't see it .. ty .. edited Link to comment
Anubhav Posted September 22, 2014 Share Posted September 22, 2014 No problem, but don't do that mistake again. You should always read the script carefully. Don't reply please. Topic should be locked as problem is solved. Link to comment
#DRAGON!FIRE Posted September 22, 2014 Share Posted September 22, 2014 No problem, but don't do that mistake again. You should always read the script carefully. Don't reply please. Topic should be locked as problem is solved. bro u don't see yourself .. ? we are human ! and we do mistake but u don't see yourself when u mistake .. my mistake i'm don't see this problem .. but your mistakes is real big mistake next time see yourself Before see my small mistakes last reply 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