Old 11-29-2008   #1 (permalink)
Newbie
 
ZeekDaGeek's Avatar
 

Join Date: Oct 2008
Posts: 14
ZeekDaGeek is on a distinguished road
Default Wiremod Addition: E2: uniqueid support.

I wasn't quiet sure where to put this, but this a little code that I made and its useful to me, so it may be useful to everyone else, feel free to include it in the wiremodsvn. I don't know how to.


Quote:
Syntax:

Console Command
- findUniqueID [full name] - Echo's back the UniqueID of a player based on full name, which is not case sensitive.


E2 Commands
- e:uniqueid() - Returns the UniqueID of a player entity as a string, returns nothing if not player.
- getplayer(s) - Returns player entity using UniqueID, returns nothing if no player can be found by that uniqueid
Quote:
Reasoning/Usages:

Why UniqueID instead of SteamID?
- Lua does not have a way to create an entity variable from a SteamID.

Why use this when I could use a target finder specific to SteamID?
- With this, you could program a method of changing which players it'll target without needing to update an entity, or allow someone else to change or add a target who can't because of prop protection.

Why did you even make it?
- Actually a few people have requested something like this and they're always told to use target finders, here's an alternative.
Lua Code. I would add this to console.lua since its already included in init.lua, and its basically empty.
Code:
function finduniqueid( players, command, args )

	if (args) then

		local lowerargs = string.lower(table.concat(args," "))

		for spaceholder, theplayer in pairs(player.GetAll()) do
			local Nick = string.lower(theplayer:Nick())
			if (Nick == lowerargs) then
				players:PrintMessage( HUD_PRINTTALK, theplayer:Nick() .. "'s UniqueID is " .. theplayer:UniqueID() )
				return ""
			end
		end
	end

	players:PrintMessage( HUD_PRINTTALK, "findUniqueID USAGE:" )
	players:PrintMessage( HUD_PRINTTALK, "  findUniqueID [full name] - Fetches UniqueID based on full name, which is not case sensitive." )

end

concommand.Add( "finduniqueid", finduniqueid )

registerFunction("uniqueid", "e:", "s", function(self, args)
	local op1 = args[2]
	local rv1 = op1[1](self, op1)
	local entity = checkEntity(rv1)
	if(!entity) then return "" end
	if(!rv1:IsPlayer()) then return "" end
	return rv1:UniqueID()
end)

registerFunction("getplayer", "s", "e", function(self, args)
	local op1 = args[2]
	local rv1 = op1[1](self, op1)
	local getplayer = player.GetByUniqueID(rv1)
	if getplayer then return getplayer end
end)

Last edited by ZeekDaGeek; 11-29-2008 at 11:15 PM..
ZeekDaGeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 11-29-2008   #2 (permalink)
Wire Guru

 
Beer's Avatar
 

Join Date: Jul 2007
Location: Dallas, Texas
Posts: 536
Beer is on a distinguished road
Default Re: Wiremod Addition: E2: uniqueid support.

Moved to Wiremod Lua Coding




EDIT: Actually that looks pretty useful. Thanks for the contribution.

Last edited by Beer; 11-29-2008 at 11:39 PM..
Beer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-29-2008   #3 (permalink)
Wire uruG

 
Jat Goodwin's Avatar
 

Join Date: Aug 2008
Location: Las Vegas
Posts: 552
Jat Goodwin is a name known to allJat Goodwin is a name known to allJat Goodwin is a name known to allJat Goodwin is a name known to allJat Goodwin is a name known to allJat Goodwin is a name known to all
Send a message via Skype™ to Jat Goodwin
Default Re: Wiremod Addition: E2: uniqueid support.

who woo, /me installs.
__________________

Quote:
<l3ulletje> Cuddle importance > Reply on holo emitter importance.

<Anticept> I am asleep, then suddenly I hear a faint, but noticable "HELP MEEE HELP MEEEE, WHY ARE YOU DOING THIS?" followed by a gulp sound.

<-=Fox=-> Orgasm... oooh ahh... ok... so?
Add jatgoodwin on Xfire for WireMod help.
Jat Goodwin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 11:47 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.

Page top