• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

(Function) Name Contains (To be used with if's)

Oneda

Aspiring Spriter
Joined
Dec 3, 2013
Messages
159
Solutions
2
Reaction score
104
Location
Brazil
Well, now I some kind of function to check if the player name contains something.
Basically to use with IF's and shit.

Example:
Code:
playerNameContains(cid, WORD HERE)



"WORD HERE" obviously meaning the word I would like to check if the player has on his name.
Would appreciate if someone could help me.

Att, Oneda.
 
function playerNameContains(cid, str)
return getPlayerName(cid):lower():find(str) and true or false
end
 
Well, it actually KINDA works?

It doesnt shows any error on console, tried 3 different ways.

1: playerNameContains(cid, Test)
2: playerNameContains(cid, "Test")
3: playerNameContains(cid, 'Test')

But, none of them would let the script continue.
Maybe a error on the script?

Code:
function onSay(cid, words, param, channel)
local vocation = getPlayerVocation(cid)
local storage = getCreatureStorage(cid, 85987)


if playerNameContains(cid, Test) then
        doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';")
    return true
else
        doPlayerSendCancel(cid, "Your name must contain Test to use this command")
    end
end

The actuall error is that instead of setting the Storage to +1 eachtime I execute the command, it just gives the doPlayerSendCancel instead.

Before you ask, yes, my name contains Tester in it. :P
 
function playerNameContains(cid, str)
return getPlayerName(cid):lower():find(str:lower()) and true or false
end
 
Solution
Back
Top