I'm making a reward based system for having a username in a steam name and I have got this far so far
local XPTimer = 0
local XPTimer = CurTime() + 10
if(XPTimer <= CurTime()) then
if string.find("SERVERNAME", ply:SteamName()) then
starwarsrp.ply:AddMoney(500)
starwarsrp.notify(ply, 3, 4, "You were awarded £500 for being part of SERVERNAME team!")
end
else
Msg("didnt work")
end
XPTimer = CurTime() + 10
I am receiving the "else" message in the console "didn't work" and the timer doesn't seem to be working. Is there a thing I am doing wrong here. I appreciate the feedback!
Judging by
string.find("SERVERNAME", ply:SteamName())
, you are trying to findSteamName
value in"SERVERNAME"
string, which is likely to fail all the time, unless your Steam name happens to be a sub-string ofSERVERNAME
. You were probably thinking about getting the value ofSERVERNAME
environmental variable and for this you need to useos.getenv("SERVERNAME")
, so something likestring.find(os.getenv("SERVERNAME") or "", ply:SteamName())
may work better (you needor ""
asos.getenv
may returnnil
when SERVERNAME is not set andstring.find
will throw an error on thenil
passed to it).