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

[?] Special Description (solved) | Jail with timer (solve it...if you dare)

Ratser

Retired // Making time for yoloswagmod
Joined
Feb 11, 2009
Messages
482
Reaction score
36
I have 1 problem and 1 request...
  1. Exactly like the Abacus...I tried to make a script that gives an item a "special description" based on what it's written on it. Also, I wanted to make players only see this description if they stand 2 SQMs from the item or closer....but it didnt work.
    Code:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    
    	if getDistanceBetween(fromPosition, toPosition) <= 2 then
    		doSetItemSpecialDescription(toPosition, "getCreatureName(cid) wrote on 
    
    getItemDate(item.uid): getItemText(item.uid)")
    	end
    
    	return true
    end
  2. I made a jail script with timer (based on another one...I don't remember it's creator) but if a player disconnects while in jail then the timer "stops" and the player is permanently jailed until somebody unjails him. I want the timer to continue only if the player is logged in.
    Code:
    function onSay (cid, words, param)
    
    	-- The permission you need to jail someone --
    	grouprequired = 4
    	
    	-- StorageValue that the player gets --
    	jailedstoragevalue_time = 1338
    	jailedstoragevalue_bool = 1339
    
    	-- Set the position of the jail: --
    	jailpos = { x = 128, y = 72, z = 7 }
    	
    	-- Set the position once unjailed: --
    	unjailpos = { x = 160, y = 51, z = 7 }
    
    	local t = string.explode(param, ",")
    
    	if(param == "") then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    		return TRUE
    	end
    	
    	local sp_id = getPlayerGUIDByName(t[1])
    	if sp_id == nil then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player doesn't exists.")		
    		return TRUE
    	end
    
    	local pid = getPlayerByNameWildcard(t[1])
    	if(not pid) then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"This player is currently not here.")
    		return TRUE
    	end
    
    	local name = getPlayerName(pid)
    	local a = {cid=cid, pid=pid, name=name, jailpos=jailpos, unjailpos=unjailpos, jailedstoragevalue_time=jailedstoragevalue_time, jailedstoragevalue_bool=jailedstoragevalue_bool}
    
    	if getPlayerGroupId(cid) < grouprequired then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough privileges.")
    		return TRUE
    	end
    
    	if getPlayerGroupId(cid) < getPlayerGroupId(pid) then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough privileges.")
    		return TRUE
    	end
    
    	if words == '/jail' then
    		time = tonumber(t[2])
    		if tonumber(t[2]) then
    			doBroadcastMessage("" .. getPlayerName(cid) .. " has jailed " .. getPlayerName(pid) .. " for " .. time .. " minutes.", MESSAGE_STATUS_WARNING)
    			doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "You have been jailed by " .. getPlayerName(cid) .. " for " .. time .. " minutes.")
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You just jailed " .. getPlayerName(pid) .. " for " .. time .. " minutes.")
    			addEvent(onTime,t[2]*60*1000,a)
    			setPlayerStorageValue(pid, jailedstoragevalue_time, 1)
    			setPlayerStorageValue(pid, jailedstoragevalue_bool, 1)
    			doTeleportThing(pid, jailpos, true)
    
    		elseif (not t[2]) then
    			doBroadcastMessage("" .. getPlayerName(cid) .. " has jailed " .. getPlayerName(pid) .. " indefinitely.", MESSAGE_STATUS_WARNING)
    			doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "You have been jailed by " .. getPlayerName(cid) .. " indefinitely.")
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You just jailed " .. getPlayerName(pid) .. " indefinitely.")
    			setPlayerStorageValue(pid, jailedstoragevalue_bool, 1)
    			doTeleportThing(pid, jailpos, true)
    
    		elseif getPlayerStorageValue(pid, jailedstoragevalue_bool) == 1 then
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is already jailed.")
    		end
    		return TRUE
    	end
    
    	if words == '/unjail' then
    		if (not t[2]) and getPlayerStorageValue(pid, jailedstoragevalue_bool) == 1 then
    			doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "You have been unjailed by " .. getPlayerName(cid) .. ".")
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"You just unjailed " .. getPlayerName(pid) .. ".")
    			setPlayerStorageValue(pid, jailedstoragevalue_bool, 0)
    			doTeleportThing(pid, unjailpos, true)
    
    		elseif (not t[2]) and getPlayerStorageValue(pid, jailedstoragevalue_time) == 1 then
    			doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "You have been unjailed by " .. getPlayerName(cid) .. ".")
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"You just unjailed " .. getPlayerName(pid) .. ".")
    			setPlayerStorageValue(pid, jailedstoragevalue_time, 0)
    			setPlayerStorageValue(pid, jailedstoragevalue_bool, 0)
    			doTeleportThing(pid, unjailpos, true)
    
    		elseif (not t[2]) and getPlayerStorageValue(pid, jailedstoragevalue_bool) == 0 then
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is currently not jailed.")
    
    		elseif tonumber(t[2]) then
    			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"No extra values are needed.")
    		end
    		return TRUE
    	end
    	return TRUE
    end
    
    function onTime(a)
    	if (not getCreatureByName(a.name)) then
    	return FALSE
    end
    
    	if getPlayerStorageValue(a.pid, a.jailedstoragevalue_time) == 1 then
    		setPlayerStorageValue(a.pid, a.jailedstoragevalue_time, 0)
    		setPlayerStorageValue(a.pid, a.jailedstoragevalue_bool, 0)
    		doPlayerSendTextMessage(a.pid, MESSAGE_INFO_DESCR, "You are now free to go. Behave yourself!")
    		doTeleportThing(a.pid,a.unjailpos,TRUE)
    	end
    	return TRUE
    end
 
Last edited:
Lua:
function onLook(cid, thing, position, lookDistance)

	if thing.itemid == 8984 then
		local text = getItemAttribute(thing.uid, "text")
		if text then
			doItemSetAttribute(thing.uid, "description", lookDistance <= 2 and getItemAttribute(thing.uid, "writer") .. ' wrote on ' .. getItemAttribute(thing.uid, "date") .. ': ' .. text or '')
		end
	end

	return true
end
 
  1. It works, but the date that shows up is incorrect

    I modified it a bit:
    Code:
    local ITEMS = {5785, 5798, 8978, 8979, 8980, 8983, 10124, 10125, 10126, 10127, 10128, 10129, 10130, 10131, 10132, 10455, 10530}
    
    function onLook(cid, thing, position, lookDistance)
    	if(isInArray(ITEMS, thing.itemid)) then
    		if(getItemAttribute(thing.uid, "text")) then
    			doItemSetAttribute(thing.uid, "description", lookDistance <= 2 and getItemAttribute(thing.uid, "writer") .. ' wrote on ' .. getItemAttribute(thing.uid, "date") .. ': ' .. getItemAttribute(thing.uid, "text") or '')
    		end
    	end
    
    	return true
    end
  2. What about the jail script?

BTW..
I'm still using TFS 0.3.6pl1
and...where do you find those functions? I've searched everywhere (including LUA_FUNCTIONS [although elf told me that it's not updated]) and haven't found them.
 
Last edited:
make the jail non log out zone!?

But what if I need to restart the server inmediatly and there are still players in jail who aren't close to finish their jail time?

omg...triple doubles >>993322

OP said:
tehking.jpg
+
zenoclashrimatcut.png
=
avatar4232_11.gif


Any questions?
 
Last edited:
  • Globalevent? I was thinking it was more like a Creaturescript.
  • I'll try to do it...but as I already told some ppl: I just began university and there's a lot of work I have to do.
 
Globalevent? I was thinking it was more like a Creaturescript.
It's same, in globalevent you loop all players, while in creaturescript you use onThink which is executed for all players every 500[?] ms.
This would mean that you can use less CPU cycles with globalevents, though. :p
 
globalevent + check area -> get time -> compare -> if expires teleport out, not hard.
It's same, in globalevent you loop all players, while in creaturescript you use onThink which is executed for all players every 500[?] ms.
This would mean that you can use less CPU cycles with globalevents, though. :p
Ok..I THINK it can be done if I use onTimer, playerStorage and it's value as the time left...getPlayerStorageValue(cid, value) == timer
 
Oh btw!...where I can see all the functions (onUse, onStepIn, onStepOut, onEquip...)?
 
[doc > scripsystem_help]
Code:
		Functions:
			onLogin(cid)
			onLogout(cid)
			onAdvance(cid, skill, oldLevel, newLevel)
			onStatsChange(cid, attacker, type, combat, value)
			onDirection(cid, old, current)
			onOutfit(cid, old, current)
			onSendMail(cid, receiver, item, openBox)
			onReceiveMail(cid, sender, item, openBox)
			onTradeRequest(cid, target, item)
			onTradeAccept(cid, target, item, targetItem)
			onJoinChannel(cid, channel, users)
			onLeaveChannel (cid, channel, users)
			onLook(cid, thing, position, lookDistance)
			onThink(cid, interval)
			onTextEdit(cid, item, newText)
			onReportBug(cid, comment)
			onAreaCombat(cid, tileItem, tilePosition, isAggressive)
			onPush(cid, target)
			onTarget(cid, target)
			onFollow(cid, target)
			onCombat(cid, target)
			onAttack(cid, target)
			onCast(cid, target)
			onKill(cid, target, lastHit)
			onDeath(cid, corpse, deathList)
			onPrepareDeath(cid, deathList)
:thumbup:
 
Back
Top