Ratser
Retired // Making time for yoloswagmod
- Joined
- Feb 11, 2009
- Messages
- 482
- Reaction score
- 36
I have 1 problem and 1 request...
- 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
- 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: