function onUse(cid, item, frompos, item2, topos)
if(getPlayerItemCount(cid, item2.itemid) >= 1) then
return false
end
if(exhaustion.get(cid, etudao)) then
doPlayerSendCancel(cid, "Please wait a few seconds before using order again!")
return true
end
if(isMonster(item2.uid) and item2.uid ~= getCreatureSummons(cid)[1] and item2.uid ~= cid) then
if(#getCreatureSummons(cid) == 0) then
doPlayerSendCancel(cid, "You need a pokemon to use order.")
return true
end
if(exhaustion.get(cid, mind)) then
doPlayerSendCancel(cid, "Your pokemon is too exhausted from the last mind control, this ability requires a cooldown of 2 minutes.")
return true
end
if(isPlayer(getCreatureMaster(item2.uid))) then
doPlayerSendCancel(cid, "You can't control the mind of someone's else pokemon.")
return true
end
if(not isInArray({"Alakazam", "Tentacruel", "Haunter", "Gengar"}, getCreatureName(getCreatureSummons(cid)[1]))) then
doPlayerSendCancel(cid, "This pokemon can't control minds.")
return true
end
if(isInArray({"Mewtwo", "Mew"}, getCreatureName(item2.uid))) then
doPlayerSendCancel(cid, "This pokemon can't be controled.")
return true
end
exhaustion.set(cid, mind, 240)
doCreatureSay(getCreatureSummons(cid)[1], "CONTROL MIND!", TALKTYPE_MONSTER)
doSendDistanceShoot(getThingPos(getCreatureSummons(cid)[1]), getThingPos(item2.uid), 39)
registerCreatureEvent(item2.uid, "Controled")
doSendMagicEffect(getThingPos(item2.uid), 136)
doSendMagicEffect(getThingPos(item2.uid), 134)
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 133)
setPlayerStorageValue(cid, 61209, getCreatureMaxHealth(getCreatureSummons(cid)[1]))
setPlayerStorageValue(cid, 61210, getCreatureHealth(getCreatureSummons(cid)[1]))
doConvinceCreature(cid, item2.uid)
if(getCreatureSpeed(item2.uid) == 0) then
doChangeSpeed(item2.uid, 180)
end
doCreatureSay(cid, ""..getCreatureName(getCreatureSummons(cid)[1])..", control "..string.lower(getCreatureName(item2.uid)).."'s mind!", 1)
local cmed = item2.uid
local cmname = getCreatureName(getCreatureSummons(cid)[1])
local cmpos = getThingPos(getCreatureSummons(cid)[1])
doRemoveCreature(getCreatureSummons(cid)[1])
local cmzao = doSummonCreature(""..cmname.." cm", cmpos)
doConvinceCreature(cid, cmzao)
setPlayerStorageValue(cid, 888, 1)
local function check(params)
if(isCreature(params.cid)) then
if(getPlayerStorageValue(params.cid, 888) <= 0) then
return true
end
if(not isCreature(cmed)) then
local pkcmpos = getThingPos(getCreatureSummons(cid)[1])
doRemoveCreature(getCreatureSummons(cid)[1])
local item = getPlayerSlotItem(cid, 8)
local pk = doSummonCreature(getItemAttribute(item.uid, "poke"):match("This is (.-)'s pokeball."), pkcmpos)
doConvinceCreature(cid, pk)
doCreatureSetLookDir(getCreatureSummons(cid)[1], 2)
registerCreatureEvent(pk, "DiePoke")
registerCreatureEvent(pk, "Exp")
registerCreatureEvent(cid, "PlayerPokeDeath")
setCreatureMaxHealth(pk, (getPlayerStorageValue(cid, 61209)))
doCreatureAddHealth(pk, (getPlayerStorageValue(cid, 61209)))
doCreatureAddHealth(pk, (getPlayerStorageValue(cid, 61210))-(getPlayerStorageValue(cid, 61209)))
setPlayerStorageValue(cid, 888, 0)
end
if(params.rod == 20) then
local lifecmed = getCreatureMaxHealth(cmed) - getCreatureHealth(cmed)
local poscmed = getThingPos(cmed)
local cmeddir = getCreatureLookDir(cmed)
local namecmed = getCreatureName(cmed)
doRemoveCreature(getCreatureSummons(cid)[1])
local back = doSummonCreature(""..namecmed.." s", poscmed)
if(getCreatureSpeed(back) == 0) then
doChangeSpeed(back, 180)
end
doCreatureSetLookDir(back, cmeddir)
doCreatureAddHealth(back, -lifecmed)
local item = getPlayerSlotItem(cid, 8)
local mynewpos = getThingPos(getCreatureSummons(cid)[1])
doRemoveCreature(getCreatureSummons(cid)[1])
pk = doSummonCreature(getItemAttribute(item.uid, "poke"):match("This is (.-)'s pokeball."), mynewpos)
doConvinceCreature(cid, pk)
doCreatureSetLookDir(getCreatureSummons(cid)[1], 2)
registerCreatureEvent(pk, "DiePoke")
registerCreatureEvent(pk, "Exp")
registerCreatureEvent(cid, "PlayerPokeDeath")
setCreatureMaxHealth(pk, (getPlayerStorageValue(cid, 61209)))
doCreatureAddHealth(pk, (getPlayerStorageValue(cid, 61209)))
doCreatureAddHealth(pk, (getPlayerStorageValue(cid, 61210))-(getPlayerStorageValue(cid, 61209)))
setPlayerStorageValue(cid, 888, 0)
else
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), 220)
end
end
end
for rod = 1, 20 do
addEvent(check, rod*500, {cid = cid, rod = rod})
end
return true
end
if(item2.uid == cid) then
if(getPlayerStorageValue(cid, 888) >= 1) then
doPlayerSendCancel(cid, "You cant fly neither ride pokemons being controled.")
return true
end
if(#getCreatureSummons(cid) == 0 and getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0) then
doPlayerSendCancel(cid, "You need a pokemon to use order.")
return true
end
if(getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0 and not isInArray(ridefly, getCreatureName(getCreatureSummons(cid)[1]))) then
doPlayerSendCancel(cid, "You can't ride this pokemon nor fly with it.")
return true
end
if(getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0 and getCreatureSpeed(getCreatureSummons(cid)[1]) == 0) then
return true
end