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

simple isWeapon : )

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
function checks if the item is a weapon! :)
returns TRUE or FALSE : )

PHP:
function isWeapon(item)
	if item ~= nil and item.itemid ~= nil then
		if getItemAttack(item.uid) > 0 then
			return TRUE
		else
			return FALSE
		end
	end
end

example:

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	if isWeapon(item) then
		if itemEx.uid == 666 then
			if math.random(1,10) == 1 then
				doRemoveItem(itemEx.uid, 1)
				doSendMagicEffect(30, toPosition)
			else
				doSendMagicEffect(2, toPosition)
			end
		end
	else
		doPlayerSendCancel(cid, 'You must use a weapon to remove this stone.')
	end
end

:) )
 
at wand's don't working because wands don't have psychical attack and isn't weapon, only magician wands like spell. : )
 
I think it would be more useful if you can make a function that check if isClub, isSword, isWand, isAxe. It might require C++, if those functions can be done it would be very useful in coding. :D
 
it can be made in lua easily, just make an table with all the ids of the swords and then check if the thing in the players hand is the same as one of the things in the table...


UPDATE:

Code:
function isWand(item)
local wands = {2190,2191,2188,8921,2189,2187,8920,8922}
	if wands[item] then
		return TRUE
	else
		return FALSE
	end
end

function isRod(item)
local rods = {2185,8911,2181,2183,8912,8910,2186,2182}
	if rods[item] then
		return TRUE
	else
		return FALSE
	end
end

function isClub(item)
local clubs = {put the itemids in here}
	if clubs[item] then
		return TRUE
	else
		return FALSE
	end
end

function isSword(item)
local swords = {put the itemids in here}
	if swords[item] then
		return TRUE
	else
		return FALSE
	end
end

function isAxe(item)
local axes = {put the itemids in here}
	if axes[item] then
		return TRUE
	else
		return FALSE
	end
end

function isDistance(item)
local distances = {put the itemids in here}
	if distances[item] then
		return TRUE
	else
		return FALSE
	end
end

there you go...

kind regards, Evil Hero
 
Last edited:
There are all weapons :) (Including Wands, rods, bows, crossbows, ammo. New 8.4 weapons aren't included)

Code:
function isWeapon(item)
local weapons = {7404, 7403, 7406, 7416, 2450, 2407, 2413, 2395, 2404, 7385, 7449, 2379, 7382, 2451, 7402, 7747, 7748, 7765, 7764, 7763, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 7774, 7775, 7776, 7777, 7769, 7768, 7767, 7766, 7765, 7764, 7763, 7758, 7757, 7756, 7755, 7754, 7753, 7752, 7751, 7750, 7749, 7748, 7747, 7746, 7745, 7744, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869, 7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 2392, 2393, 7407, 2442, 2396, 8602, 2412, 2566, 2397, 2390, 7405, 2400, 7386, 7384, 7418, 2446, 2411, 2384, 7383, 6101, 7417, 2385, 2419, 2409, 2406, 2402, 2383, 2376, 3963, 7391, 6528, 7390, 2377, 2408, 7408, 7436, 2386, 2429, 2378, 3962, 7412, 2440, 2387, 2414, 7419, 2435, 7453, 2418, 2415, 2427, 2381, 2380, 2388, 7380, 8924, 7389, 2430, 2426, 2456, 2425, 2428, 7411, 2443, 7420, 3964, 7434, 6553, 2405, 8925, 8601, 2431, 7413, 2447, 7388, 2454, 7414, 7426, 2453, 3966, 2417, 7429, 2449, 7428, 7379, 7427, 2423, 2382, 7415, 2416, 2455, 2439, 8927, 7431, 7387, 2434, 7430, 2433, 7432, 2321, 2437, 2444, 2452, 4846, 7422, 3961, 7424, 2398, 7381, 2394, 8928, 7392, 7410, 7437, 2550, 7451, 2424, 2436, 7452, 2401, 2448, 7425, 8929, 2421, 2391, 5803, 7368, 2456, 8855, 2455, 8858, 7438, 7367, 3965, 8849, 8851, 7378, 8857, 5907, 1294, 2111, 2389, 8852, 8853, 2399, 2410, 7366, 8854, 2544, 2546, 7850, 7840, 7838, 7365, 2545, 7839, 7364, 2183, 2186, 8911, 2182, 8912, 8910, 2189, 2188, 8921, 2191, 2187, 8920, 8922, 2190}

	if weapons[item] then
		return TRUE
	else
		return FALSE
	end
end

Here are wands, rods, bows, crossbows, etc...

Code:
local swordWeapons = {7404, 7403, 7406, 7416, 2450, 2407, 2413, 2395, 2404, 7385, 7449, 2379, 7382, 2451, 7402, 7747, 7748, 7765, 7764, 7763, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 7774, 7775, 7776, 7777, 7769, 7768, 7767, 7766, 7765, 7764, 7763, 7758, 7757, 7756, 7755, 7754, 7753, 7752, 7751, 7750, 7749, 7748, 7747, 7746, 7745, 7744, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869, 7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 2392, 2393, 7407, 2442, 2396, 8602, 2412, 2566, 2397, 2390, 7405, 2400, 7386, 7384, 7418, 2446, 2411, 2384, 7383, 6101, 7417, 2385, 2419, 2409, 2406, 2402, 2383, 2376, 3963, 7391, 6528, 7390, 2377, 2408, 7408}
local axeWeapons = {7436, 2386, 2429, 2378, 3962, 7412, 2440, 2387, 2414, 7419, 2435, 7453, 2418, 2415, 2427, 2381, 2380, 2388, 7380, 8924, 7389, 2430, 2426, 2456, 2425, 2428, 7411, 2443, 7420, 3964, 7434, 6553, 2405, 8925, 8601, 2431, 7413, 2447, 7388, 2454}
local clubWeapons = {7414, 7426, 2453, 3966, 2417, 7429, 2449, 7428, 7379, 7427, 2423, 2382, 7415, 2416, 2455, 2439, 8927, 7431, 7387, 2434, 7430, 2433, 7432, 2321, 2437, 2444, 2452, 4846, 7422, 3961, 7424, 2398, 7381, 2394, 8928, 7392, 7410, 7437, 2550, 7451, 2424, 2436, 7452, 2401, 2448, 7425, 8929, 2421, 2391}
local distanceWeapons = {5803, 7368, 2456, 8855, 2455, 8858, 7438, 7367, 3965, 8849, 8851, 7378, 8857, 5907, 1294, 2111, 2389, 8852, 8853, 2399, 2410, 7366, 8854}
local ammunitions = {2544, 2546, 7850, 7840, 7838, 7365, 2545, 7839, 7364}
local rods = {2183, 2186, 8911, 2182, 8912, 8910}
local wands = {2189, 2188, 8921, 2191, 2187, 8920, 8922, 2190}

local allWeapons = {7404, 7403, 7406, 7416, 2450, 2407, 2413, 2395, 2404, 7385, 7449, 2379, 7382, 2451, 7402, 7747, 7748, 7765, 7764, 7763, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 7774, 7775, 7776, 7777, 7769, 7768, 7767, 7766, 7765, 7764, 7763, 7758, 7757, 7756, 7755, 7754, 7753, 7752, 7751, 7750, 7749, 7748, 7747, 7746, 7745, 7744, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869, 7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 2392, 2393, 7407, 2442, 2396, 8602, 2412, 2566, 2397, 2390, 7405, 2400, 7386, 7384, 7418, 2446, 2411, 2384, 7383, 6101, 7417, 2385, 2419, 2409, 2406, 2402, 2383, 2376, 3963, 7391, 6528, 7390, 2377, 2408, 7408, 7436, 2386, 2429, 2378, 3962, 7412, 2440, 2387, 2414, 7419, 2435, 7453, 2418, 2415, 2427, 2381, 2380, 2388, 7380, 8924, 7389, 2430, 2426, 2456, 2425, 2428, 7411, 2443, 7420, 3964, 7434, 6553, 2405, 8925, 8601, 2431, 7413, 2447, 7388, 2454, 7414, 7426, 2453, 3966, 2417, 7429, 2449, 7428, 7379, 7427, 2423, 2382, 7415, 2416, 2455, 2439, 8927, 7431, 7387, 2434, 7430, 2433, 7432, 2321, 2437, 2444, 2452, 4846, 7422, 3961, 7424, 2398, 7381, 2394, 8928, 7392, 7410, 7437, 2550, 7451, 2424, 2436, 7452, 2401, 2448, 7425, 8929, 2421, 2391, 5803, 7368, 2456, 8855, 2455, 8858, 7438, 7367, 3965, 8849, 8851, 7378, 8857, 5907, 1294, 2111, 2389, 8852, 8853, 2399, 2410, 7366, 8854, 2544, 2546, 7850, 7840, 7838, 7365, 2545, 7839, 7364, 2183, 2186, 8911, 2182, 8912, 8910, 2189, 2188, 8921, 2191, 2187, 8920, 8922, 2190}
 
It has been already made he he he ok.

PHP:
WEAPONTYPE_CLUB = 1
WEAPONTYPE_SWORD = 2
WEAPONTYPE_AXE = 3
WEAPONTYPE_DISTANCE = 4
WEAPONTYPE_WAND = 5
WEAPONTYPE_ROD = 6

WEAPON_CLUB = {
           2321, 2382, 2391, 2394, 2398, 2401, 2416, 2417, 2421, 2422, 2423, 2424, 2433, 2434, 2436, 2437, 2439, 2444, 2445, 2448, 2449, 2452, 2453, 3961, 3966, 4846, 7379, 7381, 7387, 7392, 7410, 7414, 7415, 7424, 7425, 7426, 7427, 7429, 7430, 7431, 7432, 7437, 7451, 7452
          }
WEAPON_SWORD = {
            2376, 2377, 2379, 2383, 2384, 2385, 2390, 2392, 2393, 2395, 2396, 2397, 2400, 2402, 2403, 2404, 2406, 2407, 2408, 2409, 2411, 2412, 2413, 2419, 2420, 2438, 2442, 2446, 2450, 2451, 3963, 6101, 6528, 7382, 7383, 7384, 7385, 7386, 7390, 7402, 7404, 7405, 7406, 7407, 7408, 7416, 7449
           }
WEAPON_AXE = {
          2378, 2380, 2381, 2386, 2387, 2388, 2405, 2414, 2415, 2418, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2435, 2440, 2441, 2443, 2447, 2454, 2550, 2559, 3962, 3964, 6553, 7380, 7388, 7389, 7412, 7413, 7419, 7434
         }
WEAPON_WAND = {
           2187, 2188, 2189, 2190, 2191
          }
WEAPON_ROD = {
          2181, 2182, 2183, 2185, 2186
         }

WEAPON_DISTANCE = {
                   1294, 2111, 2389, 2399, 2410, 2455, 2456, 3965, 5803, 7366, 7367, 7368, 7378, 7438
                   }

function isWeapon(itemId)
    if(getWeaponType(itemId) ~= FALSE) then
        return TRUE
    else
        return FALSE
    end
end

function getWeaponType(itemId)
    if isInArray(WEAPON_CLUB, itemId) then
        return WEAPONTYPE_CLUB
    elseif isInArray(WEAPON_AXE, itemId) then
        return WEAPONTYPE_AXE
    elseif isInArray(WEAPON_SWORD, itemId) then
        return WEAPONTYPE_SWORD
    elseif isInArray(WEAPON_WAND, itemId) then
        return WEAPONTYPE_WAND
    elseif isInArray(WEAPON_ROD, itemId) then
        return WEAPONTYPE_ROD
    elseif isInArray(WEAPON_DISTANCE, itemId) then
        return WEAPONTYPE_DISTANCE
    else
        return FALSE
    end
end
 
Back
Top