local file = io.open(".data\logs\"..player:getName()..".lua")
file:write("\n"..os.time().." "..player:getName()..": "..words.." "..param)
file:close()
local file = io.open(".data\logs\"..player:getName()..".lua")
file:write("\n"..os.time().." "..player:getName()..": "..words.." "..param)
file:close()
So i tried adding i to create_item like thistest it to make sure it works, then yes
local file = io.open(".data\logs\"..player:getName()..".lua")
file:write("\n"..os.time().." "..player:getName()..": "..words.." "..param)
file:close()
function onSay(cid, words, param)
local player = Player(cid)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end
local split = param:split(",")
local itemType = ItemType(split[1])
if itemType:getId() == 0 then
itemType = ItemType(tonumber(split[1]))
if itemType:getId() == 0 then
player:sendCancelMessage("There is no item with that id or name.")
return false
end
end
local count = tonumber(split[2])
if count ~= nil then
if itemType:isStackable() then
count = math.min(10000, math.max(1, count))
elseif not itemType:hasSubType() then
count = math.min(100, math.max(1, count))
else
count = math.max(1, count)
end
else
count = 1
end
local result = player:addItem(itemType:getId(), count)
if result ~= nil then
if not itemType:isStackable() then
if type(result) == "table" then
for _, item in ipairs(result) do
item:decay()
end
else
result:decay()
end
end
if(not isPlayerGhost(cid)) then
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
end
end
return false
end
[Warning - Event::checkScript] Can not load script: scripts/create_item.lua data/talkactions/scripts/create_item.lua:1: invalid escape sequence near '".data'
Ok i got that, is it the same for this? Lets say i wanna do (/t player name) to teleport him to temple, but /t only works to teleport the character that uses itand change onSay(cid, ...) to onSay(player, ...) since its 1.2 and userdata and not cid..
and remove local player = Player(cid) and add
if not isPlayer(player) then
return false
end
function onSay(cid, words, param)
local player = Player(cid)
if not player:getGroup():getAccess() then
return true
end
local town = Town(param)
if town == nil then
player:sendCancelMessage("Town not found.")
return false
end
player:teleportTo(town:getTemplePosition())
return false
end
function onSay(player, words, param)
local target = Player(param)
if not player:getGroup():getAccess() then
return true
end
if target == nil then
player:sendCancelMessage("Player not found.")
return false
end
target:teleportTo(target:getTown():getTemplePosition())
return false
end
@God Mythera no you will get player from param not town. e.g
it still does not work if you don't difine it string split parameter, which in this case is an " " (space) so do it in talkactions.xml with separator=" "Code:function onSay(cid, words, param) local target = Player(param) if not player:getGroup():getAccess() then return true end if target == nil then player:sendCancelMessage("Player not found.") return false end target:teleportTo(target:getTown():getTemplePosition()) return false end
<talkaction words="/t" separator=" " script="teleport_home.lua" />
function onSay(cid, words, param)
local target = Player(param)
if not player:getGroup():getAccess() then
return true
end
if target == nil then
player:sendCancelMessage("Player not found.")
return false
end
target:teleportTo(target:getTown():getTemplePosition())
return false
end
It wont let me teleport players to temple for example [/t player name] :s@God Mythera what? did this doesnt worked?
As long as the parameter which represents cid/player or any others for that matter are used appropriately it doesn't matter what the value is labeled as. For public distribution of scripts you would want to use the familiar labels however for your own scripts you don't need to conform to such standards here is an example of what I mean.@God Mythera stop using cid for player userdata please, but somehow you prefer to use it call methods to cid instead player, e.g
cid:getGroup():getAccess() then
cid:sendCancelMessage("Player not found.")
i just copied and pasted your code, i didnt noticed that you changed default player parameter to cid, so thats because doesnt let you teleport, server couldn't get your userdata because it was suppose to be player not cid, as i said if you want to keep using cid then call methods to CID: not PLAYER:.
function onSay(c, w, p)
local t = Player(p)
local c = type(c) == 'userdata' and c or Player(c)
if c:getGroup():getAccess() < ACCOUNT_TYPE_GOD then
return true
end
if t == nil then
c:sendCancelMessage("Player not found.")
return false
end
t:teleportTo(t:getTown():getTemplePosition())
return false
end
i know that,As long as the parameter which represents cid/player or any others for that matter are used appropriately it doesn't matter what the value is labeled as. For public distribution of scripts you would want to use the familiar labels however for your own scripts you don't need to conform to such standards here is an example of what I mean.
and this is useless, you don't need to tell it since parameter you call is the same to methods, would be needed if for example:local t = Player(p) local c = type(c) == 'userdata' and c or Player(c)
function onSay(a, b, c)
local t = Player(c)
local c = type(a) == 'userdata' and a or Player(c)
if c:getGroup():getAccess() < ACCOUNT_TYPE_GOD then
return true
end