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

Make Creaturescript Faster.

DukeeH

Active Member
Joined
Dec 6, 2010
Messages
550
Solutions
3
Reaction score
39
How to make this script faster? (it is too slow the first login of new characters)
LUA:
function onLogin(cid)
local playerVoc = getPlayerVocation(cid)
local reqTries = getPlayerRequiredSkillTries
local skillStor = 56364
local gotSkills = getPlayerStorageValue(cid, 56364)


if playerVoc == 5 and gotSkills == -1 then
	doPlayerAddMagLevel(cid, 55)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 6 and gotSkills == -1 then
	doPlayerAddMagLevel(cid, 55)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 7 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 70))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))
	doPlayerAddMagLevel(cid, 18)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 8 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 70))
doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 70))
doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 70))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))
	doPlayerAddMagLevel(cid, 12)
setPlayerStorageValue(cid, skillStor, 1)

end
return TRUE
end

Thanks.
DukeeH,
 
Last edited:
You tried the creaturescript I posted (>>1215705)?

EDIT:
Everything seems fine but somehow when I log-in TFS enters in infinite loop mode.

EDIT 2:
If it doesn't works for you try it as a MOD...
firstskills.xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Skills" version="1.0" author="Ratser" contact="otland.net/members/ratser/" enabled="yes">
	<config name="firstskills_config"><![CDATA[
		firstSkills = {
			[5] = {
				{amount = 55}
			},
			[6] = {
				{amount = 55}
			},
			[7] = {
				{skillid = SKILL_DISTANCE, skillLevel = 70},
				{skillid = SKILL_SHIELD, skillLevel = 70},
				{amount = 70}
			},
			[8] = {
				{skillid = SKILL_CLUB, skillLevel = 70},
				{skillid = SKILL_SWORD, skillLevel = 70},
				{skillid = SKILL_AXE, skillLevel = 70},
				{skillid = SKILL_SHIELD, skillLevel = 70},
				{amount = 70}
			}
		}
	]]></config>
	<event type="login" name="FirstSkills" event="script"><![CDATA[
		domodlib('firstskills_config')
 
		function onLogin(cid)
			local playerVoc = firstSkills[getPlayerVocation(cid)]
			if(not playerVoc) then
				return true
			end
 
			local skillStor = 56364
			if(getCreatureStorage(cid, skillStor) == -1) then
				for i = 1, #playerVoc do
					if(playerVoc[i].skillid) then
						doPlayerAddSkillTry(cid, playerVoc[i].skillid, getPlayerRequiredSkillTries(cid, playerVoc[i].skillid, playerVoc[i].skillLevel))
					end

					if(playerVoc[i].amount) then
						doPlayerAddMagLevel(cid, playerVoc[i].amount)
					end
				end
 
				doCreatureSetStorage(cid, skillStor, 1)
			end
 
			return true
		end
	]]></event>
</mod>
 
Last edited:
>"connecting to the game world"
>That's what I'm talking about. I don't know why it happens.

Try the MOD I posted. I used the almost the same "strategy" as the First Items MOD, if it doesn't works then it's a bug.
 
Ok I'm gonna check it gimme a moment.

EDIT:
I think it was because 'SKILL__MAGLEVEL'.

EDIT 2:
Yeah that was the problem. Fixing...

EDIT 3:
MOD updated. >>1216420
 
Last edited:
Whoops I forgot you only wanted it for vocations 5 to 8. Edited.
Only the magic levels? It's configured so that only vocations 7 and 8 get other skills than just magic level.
 
Try it again. Now it's really a simplified version of your script (used the same functions, etc.). If it doesn't works as a MOD try it as a creaturescript.
 
Last edited:
first knight login = debug.
second login = all skills (correct)
paladin not tested, druid working.

Help.
 
Back
Top