• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Reach x level get x points

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,767
Solutions
5
Reaction score
769
Hello,
Someone requested this script and I made it.

Here is how it works, you get X level then you receive x Premium Point.

Add in creaturescript.xml
XML:
	<event type="advance" name="5points" event="script" value="5pts.lua"/>

I made it so it gives 5points at level 300
add 5pts.lua to /script
Lua:
--- Created by Amiroslo----
local t = {}

local points = 5 -- amount of premium points

function onAdvance(cid, type, oldlevel, newlevel)
   if (oldlevel ~= newlevel and type == SKILL__LEVEL) then
   if (newlevel >= 300 and getPlayerStorageValue(cid, 12345) == -1) then
        local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
                 db.executeQuery(p)
    doSendAnimatedText(pos, 'You have reached level 300 and you have received 5 Points!', RED)
    setPlayerStorageValue(cid, 12345, 1)
  end
  end
  return true
end
Change
if (newlevel >= 300
>>> to the level you want
and
local points = 5 -- amount of premium points

and in login.lua
Lua:
	registerCreatureEvent(cid, "5points")

Rep++ if I helped you :D
 
Last edited:
I know, didnt have time :p
will when I have

edit: fixed it, not really good tabbing, did it fast!
 
I miss read the db.execute sorry.
 
Last edited:
it will
I tried it, It added 5, tied again, had 10 :)
 
"UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="

This will "SET" his premium points to 5 or w/e not add 5 to them :eek:

Actually it will.
It'll set the premium points to old value + 5 :p.
 
Last edited:
I just read Set then pasted the comment didn't read the full line, and if he used add it would be better. :)
 
Script is exploitable. If you die >300 lvl, you'll get moar points.
 
Lua:
local t = {}
local points = 5 -- amount of premium points
function onAdvance(cid, type, oldlevel, newlevel)
	if (oldlevel ~= newlevel and type == SKILL__LEVEL) then
		if (newlevel >= 300 and getPlayerStorageValue(cid, 12345) == -1) then
			local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
			db.executeQuery(p)
			doSendAnimatedText(pos, 'You have reached level 300 and you have received 5 Points!', RED)
			setPlayerStorageValue(cid, 12345, 1)
		end
	end
return true
end
Kinda looks cleaner this way.
But, it is your script, so tab it however you want.
 
I dont get the messege in game "You have reached level 300 and you have received 5 Points!"
Here is a picture on the bug at my tfs
5pts.jpg
 
I dont get the messege in game "You have reached level 250 and you have received 4 Points!"
Here is a picture on the bug at my tfs
View attachment 13343

local t = {}
local points = 4 -- amount of premium points
function onAdvance(cid, type, oldlevel, newlevel)
if (oldlevel ~= newlevel and type == SKILL__LEVEL) then
if (newlevel >= 250 and getPlayerStorageValue(cid, 12345) == -1) then
local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
db.executeQuery(p)
doSendAnimatedText(pos, 'You have reached level 250 and you have received 4 Points!', RED)
setPlayerStorageValue(cid, 12345, 1)
end
end
return true
end
 
I dont get the messege in game "You have reached level 250 and you have received 4 Points!"
Here is a picture on the bug at my tfs
View attachment 13343

try this

Lua:
local t = {}
local points = 4 -- amount of premium points
function onAdvance(cid, type, oldlevel, newlevel)
if (oldlevel ~= newlevel and type == SKILL__LEVEL) then
if (newlevel >= 250 and getPlayerStorageValue(cid, 12345) == -1) then
local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
db.executeQuery(p)
doCreatureSay(cid, 'You have reached level 250 and you have received 4 Points!')
setPlayerStorageValue(cid, 12345, 1)
end
end
return true
end
 
Last edited:
Back
Top