Ir para conteúdo

Alguns Scripts Em Lua


soulblaster

Posts Recomendados

Hiho!

 

Pessoal,

Observo que esta seçao ja esta meiu falida, e toda vez que estiver assim, estarei aqui sempre postando coisas novas a voces =] Primeiramente, esse sao alguns scripts que eu vi em outro site, postado pelo "Inspiro", eu realmente num sei quem foi a pessoa que criou esse codes, se foi o inspiro, xikez ou outra pessoa.

 

Notas-

Eu não testei nenhuma das seguintes actions, mas pelo que vi, esta funcionando perfeitamente =]

Chega de tanta conversa e vamos as talkactions =D

 

--------------------------------------------------------

!down e !up por Talkactions

quando voce diz !up, vai para cima/ e quando diz !down vai pra baixo

 

teleport.lua

function onSay(cid, words, param)
-- Made By Xikez

local pos = getPlayerPosition(cid)
local newpos = pos
local access = getPlayerAccess(cid)
if access >= 3 then
 if words == "!down" then
	 newpos.z = newpos.z + 1
 elseif words == "!up" then
	 newpos.z = newpos.z - 1	
 end  
doPlayerSendTextMessage(cid, 25, words)
doTeleportThing(cid, newpos)
doSendMagicEffect(newpos,10)
return 0
end
return 1	
end

 

talkactions.xml

<talkaction words="!down" script="teleport.lua" />
<talkaction words="!up" script="teleport.lua" />

 

--------------------------------------------------------

!exp por TalkActions

Exemplo: 19:38 Level 8 requires 4200 experience to achieve.

 

expcalculator.lua

function onSay(cid, words, param)
-- Made by Xikez
local futurelevel = getPlayerLevel(cid) + 1
local lv = getPlayerLevel(cid)

if lv > 1 then
 equation = (50 * (lv) * (lv) * (lv) - 150 * (lv) * (lv) + 400 * (lv)) / 3
 msg = "Level ".. futurelevel .." requires ".. equation .." experience to achieve."
else
 msg = "Level 2 requires 100 experience to achieve."
end
doPlayerSendTextMessage(cid, 24, msg)
doPlayerSendTextMessage(cid, 25, words)
return 0	
end

 

talkactions.xml

<talkaction words="!exp" script="expcalculator.lua" />

 

--------------------------------------------------------

!pos por TalkActions

Exemplo: 19:38 X: [260] Y: [643] Z: [7]

 

getpos.lua

function onSay(cid, words, param)
-- Made By Xikez

local pos = getPlayerPosition(cid)
local access = getPlayerAccess(cid)
if access >= 3 then
 doPlayerSendTextMessage(cid, 24, "X: [".. pos.x .."] Y: [".. pos.y .."] Z: [".. pos.z .."]")
 doPlayerSendTextMessage(cid, 25, words)
 doTeleportThing(cid, newpos)
 return 0
end
return 1
end

 

talkactions.xml

<talkaction words="!pos" script="getpos.lua" />

 

--------------------------------------------------------

!online

Exemplo: 
19:38 There is currently 38 players online.
19:38 There is currently 2618 creatures spawned.
19:38 There is currently 68 NPCs online.
19:38 Overall, There is only 2724 creatures, npcs, and players online

 

getonline.lua

function onSay(cid, words, param)

local players = getWorldCreatures(0)
local creatures = getWorldCreatures(1)
local npcs = getWorldCreatures(2) 
local all = getWorldCreatures(3)

if players > 1 then
 playersmsg = "There is currently ".. players .." players online."
else
 playersmsg = "You are the only player online."	
end
if creatures > 1 then
 creaturesmsg = "There is currently ".. creatures .." creatures spawned."
elseif creatures == 1 then
 creaturesmsg = "There is currently 1 creature spawned."
else
 creaturesmsg = "There are no creatures spawned."
end
if npcs > 1 then
 npcsmsg = "There is currently ".. npcs .." NPCs online."
elseif npcs == 1 then
 npcsmsg = "There is currently only 1 NPC online."
else
 npcsmsg = "There is no NPCs online."
end
if all > 1 then
 allmsg = "Overall, There is only ".. all .." creatures, npcs, and players online."
else
 allmsg = "Overall, You are the only player online. No creatures, NPCs or any other players."
end

doPlayerSendTextMessage(cid, 24, playersmsg)
doPlayerSendTextMessage(cid, 24, creaturesmsg)
doPlayerSendTextMessage(cid, 24, npcsmsg)
doPlayerSendTextMessage(cid, 24, allmsg)
doPlayerSendTextMessage(cid, 25, words)
return 0	
end

 

talkactions.xml

<talkaction words="!online" script="getonline.lua" />

 

--------------------------------------------------------

!uptime

Exemplo: The server has been online for 1 month, 4 days, 21 hours, 32 minutes, and 5 seconds.

 

uptime.lua

function onSay(cid, words, param)
-- Made By Xikez

local uptime = getWorldUpTime()
local second = 0
local minute = 0
local hour = 0
local day = 0
local month = 0
local monthstarted = 0
local daystarted = 0
local hourstarted = 0
local minutestarted = 0
local monthmsg = ""
local daymsg = ""
local hourmsg = ""
local minutemsg = ""
local secondmsg = ""

--- Count Time
 while uptime >= 2592000 do
	 month = month + 1
	 uptime = uptime - 2592000
 end
 while uptime >= 86400 do
	 day = day + 1
	 uptime = uptime - 86400
 end
 while uptime >= 3600 do
	 hour = hour + 1
	 uptime = uptime - 3600
 end
 while uptime >= 60 do
	 minute = minute + 1
	 uptime = uptime - 60
 end
 while uptime >= 1 do
	 second = second + 1
	 uptime = uptime - 1
 end
-- Stop Counting.
-- Create Msg.
 if month ~= 0 then
	 if month > 1 then
   monthmsg = "".. month .." months"
	 elseif month == 1 then
   monthmsg = "1 month"
	 end
	 if month ~= 1 then
   monthmsg = "".. monthmsg .. "s"
	 end	
	 monthstarted = 1
 end	

 if day ~= 0 then	
	 if monthstarted > 0 then
   daymsg = ", ".. day .." day"
	 else
   daymsg = "".. day .." day"
	 end	
	 if day ~= 1 then
   daymsg = "".. daymsg .. "s"
	 end	
	 daystarted = 1  
 end

 if hour ~= 0 then
	 if daystarted > 0 or monthstarted > 0 then
   hourmsg = ", ".. hour .." hour"
	 else
   hourmsg = "".. hour .." hour"  
	 end  
	 if hour ~= 1 then
   hourmsg = "".. hourmsg .. "s"
	 end	
	 hourstarted = 1
 end

 if minute ~= 0 then
	 if hourstarted > 0 or daystarted > 0 or monthstarted > 0 then
   minutemsg = ", ".. minute .." minute"  
	 else
   minutemsg = "".. minute .." minute"
	 end
	 if minute ~= 1 then
   minutemsg = "".. minutemsg .. "s"
	 end	
	 minutestarted = 1  
 end

 if second > 1 then
	 if minutestarted > 0 or hourstarted > 0 or daystarted > 0 or monthstarted > 0 then
   secondmsg = ", and ".. second .." second"
	 else
   secondmsg = "".. second .." second"
	 end	
	 if second ~= 1 then
   secondmsg = "".. secondmsg .. "s"
	 end	
 end
-- Send msg to player.
doPlayerSendTextMessage(cid, 24, "This server has been online for ".. monthmsg .."".. daymsg .."".. hourmsg .."".. minutemsg .."".. secondmsg ..".")
-- send !uptime to player so it seems as if its a command
doPlayerSendTextMessage(cid, 25, words)
return uptime
end

 

talkactions.xml

<talkaction words="!uptime" script="uptime.lua" />

 

--------------------------------------------------------

!pvp

Exemplo: World-Type is currently set to PVP-Enforced.

 

getworldtype.lua

function onSay(cid, words, param)
-- Made By Xikez
local worldtype = getWorldType()
local pvpmsg = ""

if worldtype == 1 then
 pvpmsg = "Non-PVP"
elseif worldtype == 2 then
 pvpmsg = "PVP"
elseif worldtype == 3 then
 pvpmsg = "PVP-Enforced"
else
 return 1
end

doPlayerSendTextMessage(cid, 24, "World-Type is currently set to ".. pvpmsg ..".")
doPlayerSendTextMessage(cid, 25, words)
return 0	
end

 

talkactions.xml

<talkaction words="!pvp" script="getworldtype.lua" />

 

--------------------------------------------------------

!buyhouse

Nota: O preço da casa é igual para todos, esse comando não checa o tamanho da casa.

 

buyhouse.lua

function onSay(cid, words, param)
-- Made By Xikez


--/////////         Things to Edit             //////////
local numberOfHouse = 91 -- How many houses does your server have? Tip: You can use the map editor for this.
local money = 50000 -- Cost of 1 house.
local canOwnHouse = 2 -- How many houses can a  player buy?
--/////////////////////////////////////////

local pos = getPlayerPosition(cid)
local hasCheckedLeft = 0
local hasCheckedRight = 0
local hasCheckedUp = 0
local hasCheckedDown = 0
local msgto = ""
local houseId = 0
local hasHouse = getPlayerPosition(cid)
local checkedHowMany = 0
local ownsHouse = 0
local housePosFirst = 0
local newOwner = getPlayerGUID(cid)

housePosFirst = {x=getPlayerPosition(cid).x-1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
if getTileHouseInfo(housePosFirst) ~= 0 then
hasCheckedLeft = getTileHouseInfo(housePosFirst)
end
housePosFirst = {x=getPlayerPosition(cid).x+1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
if getTileHouseInfo(housePosFirst) ~= 0 then
hasCheckedRight = getTileHouseInfo(housePosFirst)
end
housePosFirst = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y+1, z=getPlayerPosition(cid).z}
if getTileHouseInfo(housePosFirst) ~= 0 then
hasCheckedDown = getTileHouseInfo(housePosFirst)
end
housePosFirst = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y-1, z=getPlayerPosition(cid).z}
if getTileHouseInfo(housePosFirst) ~= 0 then
hasCheckedUp = getTileHouseInfo(housePosFirst)
end

if hasCheckedUp ~= 0 or hasCheckedDown ~= 0 or hasCheckedRight ~= 0 or hasCheckedLeft ~= 0 then
 if hasCheckedUp ~= 0 then
	 houseId = hasCheckedUp
 elseif hasCheckedDown ~= 0 then
	 houseId = hasCheckedDown
 elseif hasCheckedRight ~= 0 then
	 houseId = hasCheckedRight	
 elseif hasCheckedLeft ~= 0 then
	 houseId = hasCheckedLeft
 end
 if getHouseOwner(houseId) ~= 0 then
	 if getHouseOwner(houseId) == newOwner then
   msgto = "You already own this house."
	 else
   msgto = "The house already has a owner."
	 end
 else
 
 while checkedHowMany < numberOfHouse do
	 checkedHowMany = checkedHowMany + 1
	 if getHouseOwner(checkedHowMany) == newOwner then
   ownsHouse = ownsHouse + 1
	 end
 end	
 if ownsHouse < canOwnHouse then
 --TODO: Count how much money to be paid, it cannot be accurate though.
	 if doPlayerRemoveMoney(cid, money) == 1 then
   setHouseOwner(houseId, newOwner)
   msgto = "Congratz! You are now the owner of the house."
	 else
   msgto = "You don\'t have enough money"
	 end	
 else
	 msgto = "You can\'t buy more houses."
 end	
 --
 end	
else
 msgto = "There is no house around you. Make sure you are facing the house door."
end


doPlayerSendTextMessage(cid, 24, msgto)
doPlayerSendTextMessage(cid, 25, words)
return 0	
end

 

talkactions.xml

<talkaction words="!buyhouse" script="buyhouse.lua" />

 

--------------------------------------------------------

!leavehouse

 

leavehouse.lua

function onSay(cid, words, param)
-- Made By Xikez
--setHouseOwner
local pos = getPlayerPosition(cid)
local claimsOwner = getPlayerGUID(cid)
local isHouse = getTileHouseInfo(pos)
local houseOwner = 0
local msgto = ""
local none = 0
local moneyRewarded = 10000
local itemsToDepot = "If you had any items in your house, they have been sent to depot."

 if isHouse ~= 0 then
	 houseOwner = getHouseOwner(isHouse)
	 if houseOwner == claimsOwner then
   setHouseOwner(isHouse, none)
   msgto = "You have left your house."
   doPlayerSendTextMessage(cid, 24, itemsToDepot)
   addMoney(cid, moneyRewarded)
	 else
   msgto = "You are not the owner."
	 end  
 else
	 msgto = "You are not inside a house."
 end
 
 doPlayerSendTextMessage(cid, 24, msgto)
 doPlayerSendTextMessage(cid, 25, words)
 
return 0	
end

function addMoney(cid, money)
-- Made by Ispiro
local gpsrewarded = money
local crystalcoins = 0
local platinumcoins = 0
local goldcoins = 0	

 while gpsrewarded >= 10000 do -- Count how many crystal coins should be rewarded
 crystalcoins = crystalcoins + 1 -- Set the number of crystal coins to be rewarded
 gpsrewarded = gpsrewarded - 10000 -- lower the number of gps left to be rewarded.
 end
 while gpsrewarded >= 100 do -- Count how many platinum coins should be rewarded
 platinumcoins = platinumcoins + 1 -- Set the number of platinum coins to be rewarded
 gpsrewarded = gpsrewarded - 100 -- lower the number of gps left to be rewarded.
 end
 while gpsrewarded >= 1 do -- Count how many gold coins should be rewarded
 goldcoins = goldcoins + 1 -- Set the number of gold coins to be rewarded
 gpsrewarded = gpsrewarded - 1 -- lower the number of gps left to be rewarded.
 end
 
 doPlayerAddItem(cid, 2148, goldcoins) -- give the player the gold coins
 doPlayerAddItem(cid, 2152, platinumcoins) -- give the player the platinum coins
 doPlayerAddItem(cid, 2160, crystalcoins) -- give the player the crystal coins
end

 

talkactions.xml

<talkaction words="!leavehouse" script="leavehouse.lua" />

 

 

Espero que gostem das actions, realmente algumas sao inuteis por ja terem commando em c++ =P + de qualquer maneira, pode ajudar as pessoas nos 'estudos' delas ;]

 

Comentem =P

Cya... :hi:

Link para o comentário
Compartilhar em outros sites

o0.. Muito bom as TalkActions.. =)

Vlws Soulblaster por postar elas aqui ;D

Tenho certeza que vai ajudar muita gente, pois existem muitos ots que não tem esses comandos nas sources,

ai basta elas adicionarem por talkactions (é bem mais facil porque muita gente não sabe compilar =))

 

Vou usar o !uptime :D

 

Obrigado,

Zorzin

Link para o comentário
Compartilhar em outros sites

soulblaster só queria perguntar se o script " !pvp " fica igual como está ai ou é preciso alterar alguma coisa ?

 

eu acrescentei o tag tal igual está aqui e o script tambem mas nao está funcionando :confused:

 

eu adicionei em talkactions

 

------------------edited------------------

 

eskeci de falar que as talkactions estão muito boas :smile:

Link para o comentário
Compartilhar em outros sites

Hiho!

 

@epos

vc tem razao =x num esta funcionando, mais eu vou ver se consigo arrumar e ja edito aqui =]

 

Cya... :hi:

 

---------------------------------------edited

 

achei o erro =x

na nova svn num tem a funçao getWorldType() e é apenas por essa razao q num esta funcionando =0

vou tentar achar essa funçao e editar novamente aqui XD

Link para o comentário
Compartilhar em outros sites

Hiho! poderia dize quem começo essa historia de hiho? vc ou o frerity(sei lah como escreve)

 

bom,

voce realmente tava sem o que fazer

suhahsauhshuahusa

o tipico

panguando

hehheheheh

mais essas talks sao de muita utilidade....

e ajudao de mais!

Mto bom

sem mais,

//Bacchi

Link para o comentário
Compartilhar em outros sites

Hiho!

 

@victor bacchi

eu num sei quem começou essa historia de 'hiho' + eu sempre falava isso quando jogava tibia real ^^ e num é frerity e sim frerety.

eu estava sem oq faser? pq vc esta afirmando isso? o.O'

 

@all

vlw pelos elogios =P

mais lembrando que num fui eu q fiz esses commandos ;P

 

cya... :hi:

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...