- Joined
- Jul 7, 2007
- Messages
- 4,049
- Reaction score
- 238
Hey =)
I was bored today, so I've decided to do some small functions, some might be useful, other might be less useful, nevertheless, here they are =)
All tested on The Forgotten Server, version 0.3.5 (Crying Damson)
sendCancelMessage(cid,message,effect)
Dont you find it boring that whenever you want to send a cancel message with the poff effect having to time those 2 lines all the time? Now you can do it with only one and I've even added some extra customization =)
cid = Player that will recieve the message
message = Either the text the player recieves or the number of a default cancel message
effect = The number of the effect you want to use
Note: message and effect can be ignored or left at ""(check examples below)
With this function, you can use these in multiple ways:
sendCancelMessage(cid) - Will send the effect poff(white smoke) and the message "Sorry, not possible."
sendCancelMessage(cid,"Text") - Will send the effect poff(white smoke) and the message "Text"
sendCancelMessage(cid,41) - Will send the effect poff(white smoke) and the message "This action is not permitted on in a protection zone."
sendCancelMessage(cid,"",21) - Will send the yellow music effect and the message "Sorry, not possible."
sendCancelMessage(cid,"Text",21) - Will send the yellow music effect and the message "Text"
sendCancelMessage(cid,3,22) - Will send the purple music effect and the message "There is not enough room."
I think I did all the possible chances
getLevelbyExp(EXP)
This is a simple function, it'll return the level corresponding to the given Exp
(Formula for Level->Exp taken from TibiaWiki and reversed to give the Exp->Level with Wolfram(check Solutions for the variable x))
getLevelbyExp(102) - Would return 2
getLevelbyExp(8000) - Would return 8
isWalkable(cid,pos)
Just a quick function to see if it is possible to step on the specified tile =)
It returns the distance effect based on the given weapon =)
getWeaponDistanceEffect(getPlayerWeapon(cid).uid) will return the effect based on the weapon the player is carrying =)
That's it for today people =)
Suggestions or Comments? Oh and dont forget to Rep++
I was bored today, so I've decided to do some small functions, some might be useful, other might be less useful, nevertheless, here they are =)
All tested on The Forgotten Server, version 0.3.5 (Crying Damson)
sendCancelMessage(cid,message,effect)
Dont you find it boring that whenever you want to send a cancel message with the poff effect having to time those 2 lines all the time? Now you can do it with only one and I've even added some extra customization =)
cid = Player that will recieve the message
message = Either the text the player recieves or the number of a default cancel message
effect = The number of the effect you want to use
Note: message and effect can be ignored or left at ""(check examples below)
Lua:
function sendCancelMessage(cid, message, effect)
message = message or RETURNVALUE_NOTPOSSIBLE
if(tonumber(message)) then
doPlayerSendDefaultCancel(cid, math.max(1, math.min(63, tonumber(message))))
elseif(#message > 0) then
doPlayerSendCancel(cid, message)
end
doSendMagicEffect(getCreaturePosition(cid), math.max(1, math.min(75, effect or CONST_ME_POFF))))
return true
end
sendCancelMessage(cid) - Will send the effect poff(white smoke) and the message "Sorry, not possible."
sendCancelMessage(cid,"Text") - Will send the effect poff(white smoke) and the message "Text"
sendCancelMessage(cid,41) - Will send the effect poff(white smoke) and the message "This action is not permitted on in a protection zone."
sendCancelMessage(cid,"",21) - Will send the yellow music effect and the message "Sorry, not possible."
sendCancelMessage(cid,"Text",21) - Will send the yellow music effect and the message "Text"
sendCancelMessage(cid,3,22) - Will send the purple music effect and the message "There is not enough room."
I think I did all the possible chances
getLevelbyExp(EXP)
This is a simple function, it'll return the level corresponding to the given Exp
Lua:
function getLevelbyExp(EXP)
return math.floor((math.sqrt(3) * math.sqrt(243*(EXP+1)^2-48600*(EXP+1)+3680000)+27 * (EXP+1)-2700)^(1/3)/30^(2/3)-(5*10^(2/3))/(3^(1/3)*(math.sqrt(3)*math.sqrt(243*(EXP+1)^2-48600*(EXP+1)+3680000)+27*(EXP+1)-2700)^(1/3))+2)
end
getLevelbyExp(102) - Would return 2
getLevelbyExp(8000) - Would return 8
isWalkable(cid,pos)
Just a quick function to see if it is possible to step on the specified tile =)
Lua:
function isWalkable(cid,pos)
pos.stackpos = 253
if doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(pos).uid) == FALSE then
return TRUE
end
return FALSE
end
getWeaponDistanceEffect(getPlayerWeapon(cid).uid) will return the effect based on the weapon the player is carrying =)
That's it for today people =)
Suggestions or Comments? Oh and dont forget to Rep++
Last edited: