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

Lua [TFS 1.2] Report System

gui56

New Member
Joined
Feb 4, 2009
Messages
19
Reaction score
0
Goodnight guys, I was trying to convert a script by Znote, from old TFS to TFS 1.2 but it just don't work, can anyone help me to fix it?

old talkaction script:

Code:
-- Coded by Dark ShaoOz
function onSay(cid, words, param, channel)
    local storage = 6708 -- (You can change the storage if its already in use)
    local delaytime = 30 -- (Exhaust In Seconds.)
    local x = getPlayerPosition(cid).x -- (Do not edit this.)
    local y = getPlayerPosition(cid).y -- (Do not edit this.)
    local z =  getPlayerPosition(cid).z -- (Do not edit this.)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command param required.")
        return true
    end
    if (getPlayerStorageValue(cid, storage) <= os.time()) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your report has been received successfully!")
        db.query("INSERT INTO  `znote_player_reports` (`id` ,`name` ,`posx` ,`posy` ,`posz` ,`report_description` ,`date`)VALUES (NULL ,  '" .. getPlayerName(cid) .. "',  '" .. x .. "',  '" .. y .. "',  '" .. z .. "',  " .. db.escapeString(param) .. ",  '" .. os.time() .. "')")
        setPlayerStorageValue(cid,storage,os.time()+delaytime)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have to wait "..getPlayerStorageValue(cid, storage) - os.time().." seconds to report again.")
    end
    return TRUE
end

script with my changes:

Code:
-- Coded by Dark ShaoOz
function onSay(cid, words, param, channel)
    local player = Player(cid)
    local storage = 6708 -- (You can change the storage if its already in use)
    local delaytime = 30 -- (Exhaust In Seconds.)
    local x = creature:getPosition(cid).x -- (Do not edit this.)
    local y = creature:getPosition(cid).y -- (Do not edit this.)
    local z =  creature:getPosition(cid).z -- (Do not edit this.)
    if(param == '') then
        player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command param required.")
        return true
    end
    if (player:getStorageValue(cid, storage) <= os.time()) then
        player:sendTextMessage(cid, MESSAGE_INFO_DESCR, "Your report has been received successfully!")
        db.query("INSERT INTO  `znote_player_reports` (`id` ,`name` ,`posx` ,`posy` ,`posz` ,`report_description` ,`date`)VALUES (NULL ,  '" .. creature:getName(cid) .. "',  '" .. x .. "',  '" .. y .. "',  '" .. z .. "',  " .. db.escapeString(param) .. ",  '" .. os.time() .. "')")
        player:setStorageValue(cid,storage,os.time()+delaytime)
    else
        player:sendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have to wait "..player:getStorageValue(cid, storage) - os.time().." seconds to report again.")
    end
    return TRUE
end
 
This one works...

Code:
-- Coded by Dark ShaoOz
function onSay(player, words, param)
    local storage = 67081 -- (You can change the storage if its already in use)
    local delaytime = 30 -- (Exhaust In Seconds.)
    local x = player:getPosition().x -- (Do not edit this.)
    local y = player:getPosition().y -- (Do not edit this.)
    local z =  player:getPosition().z -- (Do not edit this.)
    if (param == '') then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Command param required.")
        return false
    end
    if player:getStorageValue(storage) <= os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report has been received successfully!")
        db.query("INSERT INTO  `znote_player_reports` (`id` ,`name` ,`posx` ,`posy` ,`posz` ,`report_description` ,`date`)VALUES (NULL ,  '" .. player:getName() .. "',  '" .. x .. "',  '" .. y .. "',  '" .. z .. "',  " .. db.escapeString(param) .. ",  '" .. os.time() .. "')")
        player:setStorageValue(storage,os.time()+delaytime)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to wait ".. player:getStorageValue(storage) - os.time().." seconds to report again.")
    end
    return false
end
 
Back
Top