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

TFS 1.0 Cast System small bug

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,051
Solutions
2
Reaction score
260
Location
United States
When i use this cast system when i put item on ground by the caster a veiwer can pick up the item into his inventory.

these are the scripts

Code:
<talkactionwords="!cast;/cast"event="script"value="castSys.lua"/>

Code:
--[[PerfectCastSystem1.0byRoksas]]--

function onSay(cid, words, param)local player = getPlayerByName(param)

ifnot isInArray({"list","exit","off","on"}, param)andnot param or param ==""then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Enter the name of the player, which you want to cast in parameters.")returntrueend

if param =="on"thenif getPlayerStorageValue(cid,10359)>=1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Your Cast System is already running ONLINE!")returntrueend

castOn(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You have activated your Cast System, now others can cast you, to disable this feature, use the parameter '!cast off'.")returntrueend

if param =="off"thenif getPlayerStorageValue(cid,10359)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Your Cast System is already OFFLINE!")returntrueend

castOff(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You have disabled your Cast System, from now on no one can watch you, unless you turn on the Cast, using the parameter '!cast on'.")returntrueend

if param =="exit"thenif getPlayerStorageValue(cid,12269)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"You no are casting players.")returntrueend

cancelCast(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You stopped casting, use the parameter '!cast list' to see who can be casted.")returntrueend

if param =="list"then

if#whoCasted() < 1 then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"At this time, no player can be casted, try again later.")returntrueend

doPlayerSendTextMessage(cid,20,"Players can be casteds:\n\n")for k, v in ipairs(whoCasted())do
doPlayerSendTextMessage(cid,20," - "..getCreatureName(v).."")end

returntrueend

ifnot isPlayer(player)then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"This player is offline or does not exist. Use the parameter '!cast list' to see who can be casted.")returntrueend

if getPlayerStorageValue(player,10359)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"You can only cast one person with the Cast System is activated, use the parameter '!cast list' to see who can be assisted.")returntrueend

if getPlayerStorageValue(cid,10359)>=1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"To cast a player, you must first disable your Cast System using the parameter '!cast off'.")returntrueend

ifnot getTileInfo(getThingPos(cid)).protection thenreturn doPlayerSendTextMessage(cid,20,"You need enter in Protection Zone to use the Cast System.")andtrueend

setPlayerStorageValue(cid,12269,1)
castPlayer(cid, player)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You are casting the player "..getCreatureName(player)..", to exit just use the command '!cast exit'.")
doPlayerSendTextMessage(player,20,"You are casted by "..getCreatureName(cid).." player to disable your Cast, simply use the parameter '!cast off'.")returntrueend

function cancelCast(uid)

mayNotMove(uid,false)
doCreatureSetHideHealth(uid,false)
setPlayerStorageValue(uid,12269,-1)
doRemoveCondition(uid, CONDITION_OUTFIT)return doTeleportThing(uid, getTownTemplePosition(getPlayerTown(uid)))or doTeleportThing(uid, getPlayerMasterPos(uid))andtrueend

function castOn(uid)return setPlayerStorageValue(uid,10359,1)andtrueend

function castOff(uid)return setPlayerStorageValue(uid,10359,-1)andtrueend

function castPlayer(uid, player)ifnot isPlayer(player)then
cancelCast(uid)returntrueend

if getPlayerStorageValue(player,10359)<1then
cancelCast(uid)returntrueend

if getPlayerStorageValue(uid,12269)<1then
cancelCast(uid)returntrueend

mayNotMove(uid,true)
doSetItemOutfit(uid,1934,-1)
doCreatureSetHideHealth(uid,true)
doTeleportThing(uid, getThingPos(player))return addEvent(castPlayer,1*1000, uid, player)andtrueend

function whoCasted()local casteds ={}

for _, pid in ipairs(getPlayersOnline())doif getPlayerStorageValue(pid,10359)>=1then
table.insert(casteds, pid)endend

return#casteds > 0 and casteds or {}end

Code:
<eventtype="attack"name="castAttack"event="script"value="castSys.lua"/><eventtype="statschange"name="castHits"event="script"value="castSys.lua"/><eventtype="logout"name="castLogout"event="script"value="castSys.lua"/>

Code:
function onLogout(cid)

if getPlayerStorageValue(cid,12269)>0then
doPlayerSendCancel(cid,"To logout, you need to exit the Cast System first. Use the parameter '!cast exit'.")returnfalseend

setPlayerStorageValue(cid,10359,-1)returntrueend

function onStatsChange(cid, attacker, type, combat, value)

ifnot isCreature(cid)thenreturntrueend

if getPlayerStorageValue(cid,12269)>=1and isMonster(attacker)or isPlayer(attacker)thenreturnfalseend

returntrueend

function onAttack(cid, target)

ifnot isPlayer(cid)ornot isPlayer(target)thenreturntrueend

if getPlayerStorageValue(cid,12269)>0then
doRemoveCondition(cid, CONDITION_INFIGHT)returnfalseend

returntrueend

Code:
registerCreatureEvent(cid,"castAttack")
registerCreatureEvent(cid,"castHits")
registerCreatureEvent(cid,"castLogout")
 
Where did you get this? Is there a special group id for the viewer? incase there's a special group for the viewer you have to set it a the flag "Can not pick up items", to calculate the flags visit this page: http://ranisalt.github.io/flags-calculator/
where do i put this? apparently the flag is 4398046527488 also if this is for groups.xml this wont work cause when you turn on cast for example !cast on and someone joins your cast they can still pick up items... =\ it has nothing to do with groups...
 
Then you have to create a group called "viewer" with the flags it needs, also you will have to call a function to setGroup when someone joins the cast.
 
You also have to call the function setPlayerGroupId when a player joins then a custom group will be set to the viewer in this case group id 7, so the player can't pick up items. btw make sure you make a function onLogout or onLogin to set the group id of the player to default (1) .
 
You also have to call the function setPlayerGroupId when a player joins then a custom group will be set to the viewer in this case group id 7, so the player can't pick up items. btw make sure you make a function onLogout or onLogin to set the group id of the player to default (1) .
idk how to add this ;S do you got skype? xd
 
1. Create a new group called "viewers" with the properly flags to not to pick up items and set it ID to 7.
2. Use the next script instead of the one you have.
3. Don't forget to register the login script.
Code:
--[[PerfectCastSystem1.0byRoksas]]--

function onSay(cid, words, param)local player = getPlayerByName(param)

ifnot isInArray({"list","exit","off","on"}, param)andnot param or param ==""then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Enter the name of the player, which you want to cast in parameters.")returntrueend

if param =="on"thenif getPlayerStorageValue(cid,10359)>=1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Your Cast System is already running ONLINE!")returntrueend

castOn(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You have activated your Cast System, now others can cast you, to disable this feature, use the parameter '!cast off'.")returntrueend

if param =="off"thenif getPlayerStorageValue(cid,10359)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"Your Cast System is already OFFLINE!")returntrueend

castOff(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You have disabled your Cast System, from now on no one can watch you, unless you turn on the Cast, using the parameter '!cast on'.")returntrueend

if param =="exit"thenif getPlayerStorageValue(cid,12269)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"You no are casting players.")returntrueend

cancelCast(cid)
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You stopped casting, use the parameter '!cast list' to see who can be casted.")returntrueend

if param =="list"then

if#whoCasted() < 1 then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"At this time, no player can be casted, try again later.")returntrueend

doPlayerSendTextMessage(cid,20,"Players can be casteds:\n\n")for k, v in ipairs(whoCasted())do
doPlayerSendTextMessage(cid,20," - "..getCreatureName(v).."")end

returntrueend

ifnot isPlayer(player)then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"This player is offline or does not exist. Use the parameter '!cast list' to see who can be casted.")returntrueend

if getPlayerStorageValue(player,10359)<1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"You can only cast one person with the Cast System is activated, use the parameter '!cast list' to see who can be assisted.")returntrueend

if getPlayerStorageValue(cid,10359)>=1then
doSendMagicEffect(getThingPos(cid),2)
doPlayerSendTextMessage(cid,20,"To cast a player, you must first disable your Cast System using the parameter '!cast off'.")returntrueend

ifnot getTileInfo(getThingPos(cid)).protection thenreturn doPlayerSendTextMessage(cid,20,"You need enter in Protection Zone to use the Cast System.")andtrueend

setPlayerStorageValue(cid,12269,1)
castPlayer(cid, player)
setPlayerGroupId(cid, 7) -- Adding 'viewer' group.
doSendMagicEffect(getThingPos(cid),39)
doPlayerSendTextMessage(cid,20,"You are casting the player "..getCreatureName(player)..", to exit just use the command '!cast exit'.")
doPlayerSendTextMessage(player,20,"You are casted by "..getCreatureName(cid).." player to disable your Cast, simply use the parameter '!cast off'.")returntrueend

function cancelCast(uid)

mayNotMove(uid,false)
doCreatureSetHideHealth(uid,false)
setPlayerStorageValue(uid,12269,-1)
setPlayerGroupId(cid, 1) -- Removing group
doRemoveCondition(uid, CONDITION_OUTFIT)return doTeleportThing(uid, getTownTemplePosition(getPlayerTown(uid)))or doTeleportThing(uid, getPlayerMasterPos(uid))andtrueend

function castOn(uid)return setPlayerStorageValue(uid,10359,1)andtrueend

function castOff(uid)return setPlayerStorageValue(uid,10359,-1)andtrueend

function castPlayer(uid, player)ifnot isPlayer(player)then
cancelCast(uid)returntrueend

if getPlayerStorageValue(player,10359)<1then
cancelCast(uid)returntrueend

if getPlayerStorageValue(uid,12269)<1then
cancelCast(uid)returntrueend

mayNotMove(uid,true)
doSetItemOutfit(uid,1934,-1)
doCreatureSetHideHealth(uid,true)
doTeleportThing(uid, getThingPos(player))return addEvent(castPlayer,1*1000, uid, player)andtrueend

function whoCasted()local casteds ={}

for _, pid in ipairs(getPlayersOnline())doif getPlayerStorageValue(pid,10359)>=1then
table.insert(casteds, pid)endend

return#casteds > 0 and casteds or {}end

Also you will need this incase the viewer logout instead of quit the stream by the command.
Code:
function onLogin(cid)
     if getPlayerGroupId(cid) == 7 then
           setPlayerGroupId(cid, 1)
    return true
end

If you still having issues, pm me your Skype so I can help you though Teamviewer or something.
 
Back
Top