• 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!

getGenderPronoun(cid, uppercase) : He, he, She, she

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
It's a function I recently made for my reputation system. Well if you read the thread's title you know what does it do. Might be useful for other scripts, I guess...

If you want it @ lowercase, then must be: getGenderPronoun(cid)
-> he, she
If you want it @ uppercase, then must be: getGenderPronoun(cid, true)
-> He, She

Lua:
function getGenderPronoun(cid, uppercase)
    return (getPlayerSex(cid) == 0 and (uppercase and 'Sh' or 'sh') or (uppercase and 'H' or 'h')) .. 'e'
end
:peace:
 
Last edited:
ow another variant
Code:
function getGenderPronoun(cid, uppercase)
	return string.gsub(getPlayerSex(cid) == 0 and 'she' or 'he', '^%l', uppercase and string.upper or string.lower)
end
 
Cykotitan, How do I understand the operation of each variable?
Example: return string.gsub
Wath is this? :S
 
Cykotitan, How do I understand the operation of each variable?
Example: return string.gsub
Wath is this? :S
lua-users wiki: String Library Tutorial
string.gsub(s, pattern, replace [, n])

s:gsub(pattern, replace [,n])

This is a very powerful function and can be used in multiple ways. Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made:

> = string.gsub("Hello banana", "banana", "Lua user")
Hello Lua user 1
> = string.gsub("banana", "a", "A", 2) -- limit substitutions made to 2
bAnAna 2
 
Back
Top