• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua The 'param' argument

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
Hey guys,

I'm currently working on a presentation/paper on OT servers for a class in college. I was in the middle of explaining how Lua works and I couldn't remember what exactly the parameter called 'param' (in functions such as onSay(cid, words, param)) is. So if someone could tell me what the value is that would be great.

Thanks
 
The param, short for parameter is what comes after the command separated by the character you indicated. If you did not specify the character that separates the command parameter is a space.

Examples:
!mycommand OHGOD
Parameter will be "OHGOD"

!mycommand OH,MY,GOD
Parameter will be "OH,MY,GOD"

!mycommand OH MY GOD
Parameter will be "OH MY GOD"

Goi it ? ;]
 
A param is the value next to the "word".

I.e.
Code:
/buy [U]aol[/U]

Here the param == "aol".

You can also have multiple params.

I.e.
Code:
/buy aol,2

Here you see 2 params, this is the more difficult part.
Standard it will recognise only 1 param, but you are able to make multiple params by "exploding" it.
It will be something like "param[1],param[2]" etc..
You are also able to have numberic values ad ofcourse the string value.

Example how to "explode" the value param. (newType.lua)
Code:
[B]local t = string.explode(param, ",")[/B]
	[B]t[1] = tonumber(t[1])[/B] -- param 1 (tonumber means numberic value)
	if(not t[1]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
		return true
	end

	local pid = cid
	if(t[2]) then -- param 2
		pid = getPlayerByNameWildcard(t[2])
		if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
			return true
		end
	end

You can see here that the first param has to be numberic value, and the second param is a string.

This script will i.e. work like this:
Code:
/newType 453,Ganja -- outfitid,name

However, the string value is optional in this script, so if it is not present, it will automatically focus on the "CID"

Hope you understand, if not, feel free to ask for more support :).
 
Back
Top