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

A few simply scripts

soul4soul

Intermediate OT User
Joined
Aug 13, 2007
Messages
1,877
Solutions
3
Reaction score
130
Location
USA
These are some scripts i just finished working on so i decided to release them in case anyone wanted to use them. i don't think anyone will need them but who knows. I also want to release them in case there is any errors in them, if someone could tell me what it is or make the code better. All the scripts should work except the last one. I'm working on a PVP-E server in case you wanted to know thats you probably wont need these scripts.

login script: sets eq for new players, blue robes for mages and dsm for knights/pallys it also checks to see if your lower then level 80 if you are you get reset to level 98
Code:
local firstItems =
{
    2382, --torch
    2498, --rh
    2514, --mms
    2050, --club
    2488, --crown legs
    2195  --boh
}
 
 local bagItems = 
{
    2431,
    2421,
    2400,
    2187,
    2183
} 

local exp = getPlayerExp(cid)
local lvlexp = 14753700--exp for lvl 98
local newexp = lvlexp - exp
 
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) == TRUE then
		if getPlayerStorageValue(cid, 30001) == -1 then
			for i = 1, #firstItems do
				doPlayerAddItem(cid, firstItems[i], 1)
			end
			local bag = doPlayerAddItem(cid, 1987, 1)
			for i = 1, #bagItems do
				doAddContainerItem(bag, bagItems[i], 1)
			end
			doPlayerAddItem(cid, (getPlayerVocation(cid) <= 2 and 2656 or 2492))
			setPlayerStorageValue(cid, 30001, 1)
			doPlayerSetTown(cid, 1)
		end
		if getPlayerLevel(cid) <= 80 then
			doPlayerAddExp(cid,newexp)
		end
	end
	return TRUE
end

general items script:the player says !<itemname> to receive to some runes or aols
Code:
local items = {
    ["!backpack"] = {1988, 1},
    ["!aol"] = {2173, 1},
    ["!sd"] = {2268, 100},
    ["!uh"] = {2273, 100},
    ["!xbow"] = {2455, 1},
    ["!hmm"] = {2311, 100},
    ["!gfb"] = {2304, 100},
    ["!expl"] = {2313, 100},
    ["!mana"] = {7589, 1},
    ["!life"] = {7588, 1},
}

local EXHAUST_TIME = 1
local EXHAUST_VALUE = 8008

function onSay(cid, words, param)
	item = items[words]
	if (exhaust(cid, EXHAUST_VALUE, EXHAUST_TIME) == 1) then 
		doPlayerAddItem(cid, item[1], item[2])
		return 1
	else
		doPlayerSendCancel(cid, "You are still exhausted from lasting receiving an item") 
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		return 0
	end
	return 0
end

tools,weapons,eq scripts: all there scripts are pretty much the same just edited to what items i wanted the players to get the difference between this and the script above this is there you only got 1 item at a time in these you get a small group of items
Code:
items = {
	2120,
	2554,
	2553,
	2420
}

local EXHAUST_TIME = 1
local EXHAUST_VALUE = 8008

function onSay(cid, words, param)
	if (exhaust(cid, EXHAUST_VALUE, EXHAUST_TIME) == 1) then 
		for i = 1, #items do
			doPlayerAddItem(cid, items[i], 1)
		end
		return 1
	else
		doPlayerSendCancel(cid, "You are still exhausted from lasting receiving an item") 
		return 0
	end
	return 0
end

this last one was my attempt at making a weapon script that was designed for infernal bolts, randomly when a player shoots an infernal bolt they would also shoot a gfb at the target, otherwise it would just be a normal infernal bolt(note this script doesn't work or maybe does and i just cant figure out how to add it to weapons.xml being it seems the layout was changed, or I'm just not sure what I'm taking about because this is my first attempt at a weapon script)
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 0, 0)

local gfb = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -30, -0.4, 0)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onUseWeapon(cid, var)
	local ret = doCombat(cid, combat, var)
	if(ret ~= LUA_NO_ERROR) then
		return LUA_ERROR
	end
	return doCombat(cid, gfb, var)
end
 
items = {
2120,
2554,
2553,
2420
}

local EXHAUST_TIME = 1
local EXHAUST_VALUE = 8008

function onSay(cid, words, param)
if (exhaust(cid, EXHAUST_VALUE, EXHAUST_TIME) == 1) then
for i = 1, #items do
doPlayerAddItem(cid, items, 1)
end
return 1
else
doPlayerSendCancel(cid, "You are still exhausted from lasting receiving an item")
return 0
end
return 0
end




Where should I put it? what file?
 
local items = {
["!backpack"] = {1988, 1},
["!aol"] = {2173, 1},
["!sd"] = {2268, 100},
["!uh"] = {2273, 100},
["!xbow"] = {2455, 1},
["!hmm"] = {2311, 100},
["!gfb"] = {2304, 100},
["!expl"] = {2313, 100},
["!mana"] = {7589, 1},
["!life"] = {7588, 1},
}

local EXHAUST_TIME = 1
local EXHAUST_VALUE = 8008

function onSay(cid, words, param)
item = items[words]
if (exhaust(cid, EXHAUST_VALUE, EXHAUST_TIME) == 1) then
doPlayerAddItem(cid, item[1], item[2])
return 1
else
doPlayerSendCancel(cid, "You are still exhausted from lasting receiving an item")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return 0
end
return 0
end


Where should I put it? In what file?
 
The weapon doesn't work because AREA_CIRCLE3X3 is defined in data/spells/lib/spells.lua - this should work:

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 0, 0)

local gfb = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -30, -0.4, 0)

local AREA_GFB = {
	{0, 0, 1, 1, 1, 0, 0},
	{0, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1},
	{1, 1, 1, 3, 1, 1, 1},
	{1, 1, 1, 1, 1, 1, 1},
	{0, 1, 1, 1, 1, 1, 0},
	{0, 0, 1, 1, 1, 0, 0}
}
local area = createCombatArea(AREA_GFB)
setCombatArea(combat, area)

function onUseWeapon(cid, var)
	local ret = doCombat(cid, combat, var)
	if(ret ~= LUA_NO_ERROR) then
		return LUA_ERROR
	end
	return doCombat(cid, gfb, var)
end

However, I haven't seen LUA_NO_ERROR or whatever before so I'm not sure if that's something unique to the distro you're using or not :P

Also, repped for sharing your work with the public ^^
 
I do not know where in the script it would randomly shoot GFB, but I think this should work.
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 0, 0)
 
local gfb = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -30, -0.4, 0)
 
local AREA_GFB = {
	{0, 0, 1, 1, 1, 0, 0},
	{0, 1, 1, 1, 1, 1, 0},
	{1, 1, 1, 1, 1, 1, 1},
	{1, 1, 1, 3, 1, 1, 1},
	{1, 1, 1, 1, 1, 1, 1},
	{0, 1, 1, 1, 1, 1, 0},
	{0, 0, 1, 1, 1, 0, 0}
}
local area = createCombatArea(AREA_GFB)
setCombatArea(combat, area)
 
function onUseWeapon(cid, var)
	local c, d = math.random(100), 20
	return doCombat(cid, (c < d and gfb or combat), var)
end
 
Back
Top