Action Knowledge parchment

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
This is basicly what it does:

*Checks if the player level is less then 80, if it is you can't use it.
*Adds experience to the playe

PHP:
local EXP = 2000000 -- Amount of EXP to get 
local MESSAGE = "Earned: 2 000 000 Experience points because of reading this very interresting text." -- The Message to get 
local ID = 1948 -- Parchment 
local CMESSAGE = "Sorry, minimum level 80 to understand what the inscription says" -- The cancel message to get 
local PDAYS = 3 -- The amount of days to add to the premium account

function onUse(cid, item, frompos, item2, topos) -- The Function 
if getPlayerLevel(cid) < 80 then -- If the player is less than 80 then do 
doPlayerSendTextMessage(cid, 23, CMESSAGE) -- Send a cancel message that it didn't work 
else   
if item.itemid == ID then -- If the ItemID equals to correct ID then continue 
doPlayerAddExp(cid, EXP) -- Add the Experience to the player 
doPlayerSendTextMessage(cid, 23, MESSAGE) -- Send a text message that everything went well 
doPlayerAddPremiumDays(cid, PDAYS) -- Adds premium account days to the account
doRemoveItem(item.uid, 1) -- Remove the item so you can't use it over and over again 
end 
return TRUE 
end 
end
This should be in actions.xml

PHP:
<action itemid="1948" script="other/knowledgeparchment.lua"/>



The code is basicly self explaining (I've written some also)


Rate it , I've been doing LUA for 3 days :D


And Yes, I did everything by myself just reading a little tutorial about how to use "onUse".

I also used this:

Code:
//get*
	getCreatureHealth(cid)
	getCreatureMaxHealth(cid)
	getCreatureMana(cid)
	getCreatureMaxMana(cid)
	getCreatureMaster(cid)
	getCreatureSummons(cid)
	getCreatureOutfit(cid)
	getCreaturePosition(cid)
	getCreatureName(cid)
	getCreatureSpeed(cid)
	getCreatureBaseSpeed(cid)
	getCreatureTarget(cid)
	getCreatureByName(name)
	getCreatureCondition(cid, condition)
	getMonsterTargetList(cid)
	getMonsterFriendList(cid)
	getPlayerLossSkill(cid)
	getPlayerLossPercent(cid, lossType)
	getPlayerGUIDByName(name)
	getPlayerNameByGUID(guid)
	getPlayerFood(cid)
	getPlayerLevel(cid)
	getPlayerExperience(cid)
	getPlayerMagLevel(cid)
	getPlayerSpentMana(cid)
	getPlayerAccess(cid)
	getPlayerSkillLevel(cid, skillid)
	getPlayerSkillTries(cid, skillid)
	getPlayerTown(cid)
	getPlayerVocation(cid)
	getPlayerRequiredMana(cid, magicLevel)
	getPlayerRequiredSkillTries(cid, skillId, skillLevel)
	getPlayerItemCount(cid, itemid)
	getPlayerSoul(cid)
	getPlayerFreeCap(cid)
	getPlayerLight(cid)
	getPlayerSlotItem(cid, slot)
	getPlayerWeapon(cid[, ignoreAmmo])
	getPlayerItemById(cid, deepSearch, itemId[, subType])
	getPlayerDepotItems(cid, depotid)
	getPlayerGuildId(cid)
	getPlayerGuildName(cid)
	getPlayerGuildRank(cid)
	getPlayerGuildNick(cid)
	getPlayerGuildLevel(cid)
	getPlayerSex(cid)
	getPlayerLookDir(cid)
	getPlayerStorageValue(uid, valueid)
	getPlayerGUID(cid)
	getPlayerFlagValue(cid, flag)
	getPlayerCustomFlagValue(cid, flag)
	getPlayerPromotionLevel(cid)
	getPlayerGroupId(cid)
	getPlayerLearnedInstantSpell(cid, name)
	getPlayerInstantSpellCount(cid)
	getPlayerInstantSpellInfo(cid, index)
	getPlayerSex(cid)
	getPlayerBlessing(cid, blessing)
	getPlayerStamina(cid)
	getPlayerNoMove(cid)
	getPlayerExtraExpRate(cid)
	getPlayerPartner(cid)
	getPlayerParty(cid)
	getPlayerPremiumDays(cid)
	getPlayerSkullType(cid)
	getPlayerBalance(cid)
	getPlayersByAccountNumber(accountNumber)
	getPlayersByIP(ip[, mask = 0xFFFFFFFF])
	getInstantSpellInfoByName(cid, name)
	getInstantSpellWords(name)
	getPartyMembers(lid)
	getAccountNumberByName(name)
	getIPByName(name)
	getHouseOwner(houseid)
	getHouseName(houseid)
	getHouseEntry(houseid)
	getHouseRent(houseid)
	getHousePrice(houseid)
	getHouseTown(houseid)
	getHouseAccessList(houseid, listid)
	getHouseByPlayerGUID(playerGUID)
	getHouseTilesSize(houseid)
	getItemRWInfo(uid)
	getItemDescriptionsById(itemid)
	getItemNameById(itemid)
	getItemPluralNameById(itemid)
	getItemIdArticleById(itemid)
	getItemWeightById(itemid, count[, precise])
	getItemDescriptions(uid)
	getItemName(uid)
	getItemPluralName(uid)
	getItemIdArticle(uid)
	getItemAttack(uid)
	getItemExtraAttack(uid)
	getItemDefense(uid)
	getItemExtraDefense(uid)
	getItemArmor(uid)
	getItemAttackSpeed(uid)
	getItemHitChance(uid)
	getItemIdByName(name)
	getContainerSize(uid)
	getContainerCap(uid)
	getContainerCapById(itemid)
	getContainerItem(uid, slot)
	getDepotId(uid)
	getTileItemById(pos, itemId[, subType])
	getTileItemByType(pos, type)
	getTileThingByPos(pos)
	getTilePzInfo(pos)
	getTileHouseInfo(pos)
	getClosestFreeTile(cid, targetpos)
	getThingfromPos(pos)
	getThing(uid)
	getThingPos(uid)
	getTemplePositionByName(townName)
	getTemplePositionById(townId)
	getTownName(townId)
	getWorldType()
	getWorldTime()
	getWorldLight()
	getWorldCreatures(type) //0 players, 1 monsters, 2 npcs, 3 all
	getWorldUpTime()
	getOnlinePlayers()
	getGlobalStorageValue(valueid)
	getSpectators(centerPos, rangex, rangey, multifloor)
	getTopCreature(pos)
	getVocationInfo(id)
	getGuildId(guildName)
	getFluidSourceType(type)
	getConfigFile()

	//set*
	setCreatureMaxHealth(cid, health)
	setCreatureMaxMana(cid, mana)
	setPlayerStorageValue(uid, valueid, newvalue)
	setPlayerGroupId(cid, newGroupId)
	setPlayerPromotionLevel(cid, level)
	setPlayerStamina(cid, minutes)
	setPlayerExtraExpRate(cid, value)
	setPlayerPartner(cid, guid)
	setHouseOwner(houseid, ownerGUID)
	setHouseAccessList(houseid, listid, listtext)
	setItemName(uid)
	setItemPluralName(uid)
	setItemIdArticle(uid)
	setItemAttack(uid, attack)
	setItemExtraAttack(uid, extraattack)
	setItemDefense(uid, defense)
	setItemArmor(uid, armor)
	setItemExtraDefense(uid, extradefense)
	setItemAttackSpeed(uid, attackspeed)
	setItemHitChance(uid, hitChance)
	setCombatArea(combat, area)
	setCombatCondition(combat, condition)
	setCombatParam(combat, key, value)
	setConditionParam(condition, key, value)
	setCombatCallBack(combat, key, function_name)
	setCombatFormula(combat, type, mina, minb, maxa, maxb)
	setConditionFormula(combat, mina, minb, maxa, maxb)
	setGlobalStorageValue(valueid, newvalue)
	setWorldType(type)

	//do*
	doCreatureAddHealth(cid, health)
	doCreatureAddMana(cid, mana)
	doCreatureSetDropLoot(cid, doDrop)
	doCreatureChangeOutfit(cid, outfit)
	doCreatureSay(cid, text, type)
	doSetCreatureLight(cid, lightLevel, lightColor, time)
	doSetCreatureOutfit(cid, outfit, time)
	doRemoveCreature(cid)
	doMoveCreature(cid, direction)
	doSummonCreature(name, pos)
	doConvinceCreature(cid, target)
	doChallengeCreature(cid, target)
	doChangeSpeed(cid, delta)
	doMonsterChangeTarget(cid)
	doSetMonsterTarget(cid, target)
	doSetMonsterOutfit(cid, name, time)
	doPlayerBroadcastMessage(cid, message[, type])
	doPlayerSetSex(cid, newSex)
	doPlayerSetTown(cid, townid)
	doPlayerSetVocation(cid,voc)
	doPlayerRemoveItem(cid, itemid, count[, subtype])
	doPlayerAddExp(cid, exp)
	doPlayerSetGuildId(cid, id)
	doPlayerSetGuildRank(cid, rank)
	doPlayerSetGuildNick(cid, nick)
	doPlayerAddOutfit(cid,looktype, addons)
	doPlayerRemoveOutfit(cid,looktype, addons)
	doPlayerSetLossPercent(cid, lossType, newPercent)
	doPlayerSetLossSkill(cid, doLose)
	doPlayerAddSkillTry(cid, skillid, n)
	doPlayerAddSpentMana(cid, amount)
	doPlayerAddSoul(cid, soul)
	doPlayerAddItem(uid, itemid[, count/subtype[, canDropOnMap]])
	doPlayerAddItemEx(cid, uid[, canDropOnMap])
	doPlayerSendTextMessage(cid, MessageClasses, message)
	doPlayerAddMoney(cid, money)
	doPlayerRemoveMoney(cid, money)
	doPlayerWithdrawMoney(cid, money)
	doPlayerDepositMoney(cid, money)
	doPlayerTransferMoneyTo(cid, target, money)
	doPlayerPopupFYI(cid, message)
	doPlayerSendTutorial(cid, id)
	doPlayerAddMapMark(cid, pos, type[, description])
	doPlayerAddPremiumDays(cid, days)
	doPlayerAddBlessing(cid, blessing)
	doPlayerAddStamina(cid, minutes)
	doPlayerSetNoMove(cid, cannotMove)
	doPlayerResetIdleTime(cid)
	doPlayerLearnInstantSpell(cid, name)
	doPlayerFeed(cid, food)
	doPlayerSendCancel(cid, text)
	doPlayerSendDefaultCancel(cid, ReturnValue)
	doCreateItem(itemid, type/count, pos)
	doCreateItemEx(itemid[, count/subtype])
	doAddContainerItemEx(uid, virtuid)
	doAddContainerItem(uid, itemid[, count/subtype])
	doChangeTypeItem(uid, newtype)
	doDecayItem(uid)
	doRemoveItem(uid[, n])
	doTransformItem(uid, toitemid[, count/subtype])
	doSetItemActionId(uid, actionid)
	doSetItemText(uid, text)
	doSetItemSpecialDescription(uid, desc)
	doSetItemOutfit(cid, item, time)
	doTileAddItemEx(pos, uid)
	doAddCondition(cid, condition)
	doRemoveCondition(cid, type)
	doAreaCombatHealth(cid, type, pos, area, min, max, effect)
	doTargetCombatHealth(cid, target, type, min, max, effect)
	doAreaCombatMana(cid, pos, area, min, max, effect)
	doTargetCombatMana(cid, target, min, max, effect)
	doAreaCombatCondition(cid, pos, area, condition, effect)
	doTargetCombatCondition(cid, target, condition, effect)
	doAreaCombatDispel(cid, pos, area, type, effect)
	doTargetCombatDispel(cid, target, type, effect)
	doCombat(cid, combat, param)
	doTeleportThing(cid, newpos[, pushmove])
	doCreateTeleport(itemid, topos, createpos)
	doSendMagicEffect(pos, type[, player])
	doSendDistanceShoot(frompos, topos, type)
	doSendAnimatedText(pos, text, color)
	doShowTextDialog(cid, itemid, text)
	doRelocate(pos, posTo)
	doBroadcastMessage(message, type)

	//is*
	isCreature(cid)
	isPlayer(cid)
	isPlayerPzLocked(cid)
	isPlayerGhost(cid)
	isItemStackable(itemid)
	isItemRune(itemid)
	isItemDoor(itemid)
	isItemLevelDoor(itemid)
	isItemContainer(itemid)
	isItemFluidContainer(itemid)
	isItemMovable(itemid)
	isContainer(uid)
	isCorpse(uid)
	isMovable(uid)
	isSightClear(fromPos, toPos, floorCheck)
	isInArray({array}, value)

	//others
	registerCreatureEvent(uid, eventName)
	createCombatArea({area}[, {exArea}])
	createConditionObject(type)
	addDamageCondition(condition, rounds, time, value)
	addOutfitCondition(condition, lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet)
	createCombatObject()
	numberToVariant(number)
	stringToVariant(string)
	positionToVariant(pos)
	targetPositionToVariant(pos)
	variantToNumber(var)
	variantToString(var)
	variantToPosition(var)
	canPlayerLearnInstantSpell(cid, name)
	queryTileAddThing(uid, pos[, flags])
	canPlayerWearOutfit(cid, looktype, addons)
	executeRaid(name)
	saveServer()
	cleanMap()
	shutdown()
	addEvent(callback, delay, ...)
	stopEvent(eventid)
	debugPrint(text)
	hasProperty(uid)

	//db table
	db.executeQuery(query)
	db.storeQuery(query)
	db.escapeString(str)
	db.escapeBlob(s, length)
	db.stringComparisonOperator()

	//result table
	result.getDataInt(resId, s)
	result.getDataLong(resId, s)
	result.getDataString(resId, s)
	result.getDataStream(resId, s, length)
	result.next(resId)
	result.free(resId)

	//bit table
	#bit.cast
	bit.bnot(n)
	bit.band(type, n)
	bit.bor(type, n)
	bit.bxor(type, n)
	bit.lshift(type, n)
	bit.rshift(type, n)
	#bit.arshift
	#bit.ucast
	bit.ubnot(n)
	bit.uband(type, n)
	bit.ubor(type, n)
	bit.ubxor(type, n)
	bit.ulshift(type, n)
	bit.urshift(type, n)
	#bit.uarshift


^ Taken from http://otland.net/f139/beginner-tutorial-15400/
 
Last edited:

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,833
Best answers
0
Reaction score
184
It does not add manaSpent, also, please learn how to tab :O
 
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
What do you mean with Tab?

Like this:
Code:
onSay(cid, word, param)
      doPlayerAddExp(cid, 2500)
end
?

Yea, I edited the script so it doesn't add mana spent and forgot to delete it from the text :p
 

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,833
Best answers
0
Reaction score
184
What do you mean with Tab?

Like this:
Code:
onSay(cid, word, param)
      doPlayerAddExp(cid, 2500)
end
?

Yea, I edited the script so it doesn't add mana spent and forgot to delete it from the text :p
Yea, is easier to track errors and it looks more nice ;p
 
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
@Old Marceinek :)
what do you mean?

@script
this
PHP:
doRemoveItem(item.uid, 1)
can be changed to
PHP:
doRemoveItem(item.uid)
Oh, how come it can be changed to nothing? Does nothing equal to one?
 

Zoriath

New Member
Joined
Mar 26, 2008
Messages
1,496
Best answers
0
Reaction score
3
Code:
local EXP = 2000000 -- Amount of EXP to get  
local MESSAGE = "Earned: 2 000 000 Experience points because of reading this very interresting text." -- The Message to get  
local ID = 1948 -- Parchment  
local CMESSAGE = "Sorry, minimum level 80 to understand what the inscription says" -- The cancel message to get  
local PDAYS = 3 -- The amount of days to add to the premium account 

function onUse(cid, item, fromPosition, itemEx, toPosition) -- The Function  
	if getPlayerLevel(cid) < 80 then -- If the player is less than 80 then do  
		doPlayerSendTextMessage(cid, 23, CMESSAGE) -- Send a cancel message that it didn't work  
	elseif item.itemid == ID then -- If the ItemID equals to correct ID then continue  
		doPlayerAddExp(cid, EXP) -- Add the Experience to the player  
		doPlayerSendTextMessage(cid, 23, MESSAGE) -- Send a text message that everything went well  
		doPlayerAddPremiumDays(cid, PDAYS) -- Adds premium account days to the account 
		doRemoveItem(item.uid, 1) -- Remove the item so you can't use it over and over again  
	end  
	return TRUE 
end
Tabbed and changed

Code:
else
if item.itemid == ID then -- If the ItemID equals to correct ID then continue
to

Code:
elseif item.itemid == ID then -- If the ItemID equals to correct ID then continue
it has no reason to double it.
 
Last edited:
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
Ok, thanks everyone. I really appreciate that you keep teaching me new stuff :D
 

Zoriath

New Member
Joined
Mar 26, 2008
Messages
1,496
Best answers
0
Reaction score
3
By the way, Jesper, for the newer servers you dont need 'frompos', 'item2' and 'topos' but 'fromPosition', 'itemEx' and 'toPosition'.

Edited my post.
 

Master-m

Need help? Just ask!
Joined
May 28, 2007
Messages
4,339
Best answers
0
Reaction score
15
Location
The Netherlands
a Jesper is a noobak got pwnd by me=D

Hi Jesper=D!

good that you are learning and releasing luascripts! continue that way! rep++ from me =D
 
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
Oh thanks man. But now I really need to know what to do next..

I don't know what kind of script to create.. Maybe if you walk on a spot and then something happens :p ?
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
By the way, Jesper, for the newer servers you dont need 'frompos', 'item2' and 'topos' but 'fromPosition', 'itemEx' and 'toPosition'.
How do you mean 'you don't need'?
Both of these work the same way:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

function onUse(cid, item, frompos, item2, topos)
The only difference is; if you choose one of these on the beggining of the onUse action script, you won't be able to use 'variables?' of the other one.
There's absolutely no difference in which one do you use, altough the first one is more 'understandable' for newbies, and the second one is a bit.. shorter? :p
 

Master-m

Need help? Just ask!
Joined
May 28, 2007
Messages
4,339
Best answers
0
Reaction score
15
Location
The Netherlands
Oh thanks man. But now I really need to know what to do next..

I don't know what kind of script to create.. Maybe if you walk on a spot and then something happens :p ?
aah just make it if you walk on a tile, a door opens. If you walk off the tile, the door closes again and is locked. Could be funny for a quest, then you need 2 people for it:p
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
aah just make it if you walk on a tile, a door opens. If you walk off the tile, the door closes again and is locked. Could be funny for a quest, then you need 2 people for it:p
hah great idea :p please make something like that ;P
 

krankthefunk

New Member
Joined
Jan 7, 2008
Messages
127
Best answers
0
Reaction score
2
@Old Marceinek :)
what do you mean?

@script
this
PHP:
doRemoveItem(item.uid, 1)
can be changed to
PHP:
doRemoveItem(item.uid)

Bad move, with this script when you have a stack of same scroll say 100, iT would remove all 100

the doRemoveItem(item.uid, 1) will remove only one which is correct.
 
Top