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

Talkaction !save [SOLVED]

Xapuur

New Member
Joined
Sep 15, 2009
Messages
157
Reaction score
0
Location
Chile
Hello. In TFS 9.31 the talkaction is:

Code:
local savingEvent = 0

function onSay(cid, words, param)
	if getPlayerAccess(cid) ~= 0 then
		if isNumber(param) == TRUE then
			stopEvent(savingEvent)
			save(tonumber(param) * 60 * 1000)
		else
			saveData()
		end
	end
end

function save(delay)
	saveData()
	if delay > 0 then
		savingEvent = addEvent(save, delay, delay)
	end
end

But when i write "!save", I doesn't know if really is save the character, because isn't appears a text message in the chat channel of the char and in the console doesn't appears nothing

Regards
 
Last edited:
Change for this:
Code:
local savingEvent = 0

function onSay(cid, words, param)
	if getPlayerAccess(cid) ~= 0 then
		if isNumber(param) == TRUE then
			stopEvent(savingEvent)
			save(tonumber(param) * 60 * 1000)
		else
			saveData()
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
		end
	end
end

function save(delay)
	saveData()
	if delay > 0 then
		savingEvent = addEvent(save, delay, delay)
	end
end
 
Take xd!!
local savingEvent = 0

function onSay(cid, words, param, channel)
if(isNumber(param)) then
stopEvent(savingEvent)
save(tonumber(param) * 60 * 1000)
else
doSaveServer()
end
return true
end

function save(delay)
doSaveServer()
if(delay > 0) then
savingEvent = addEvent(save, delay, delay)
end
end
 
@Dantarrix: Doesn't works. In console don't appears any error.

@xvidyx: When i do !save in console appears:
Code:
[03/01/2012 22:31:53] Lua Script Error: [TalkAction Interface] 
[03/01/2012 22:31:53] data/talkactions/scripts/savecharacter.lua:onSay
[03/01/2012 22:31:53] data/talkactions/scripts/savecharacter.lua:8: attempt to call global 'doSaveServer' (a nil value)
[03/01/2012 22:31:53] stack traceback:
[03/01/2012 22:31:53] 	[C]: in function 'doSaveServer'
[03/01/2012 22:31:53] 	data/talkactions/scripts/savecharacter.lua:8: in function <data/talkactions/scripts/savecharacter.lua:3>

Regards
 
@doubleup: Lol? What have you changed?
1. He wants to save character, not server ;)
2. The problem he has, is that he doesnt know if the character is saved after the talkaction... Nothing more... ;)

@Xapuur: can you post talkactions.xml? Thank you ;)
 
mmm!
<talkaction log="yes" words="/save" access="3" event="script" value="save.lua"/>
<globalevent name="save" interval="2200" event="script" value="save.lua"/>
791.png
 
talkaction.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<talkactions>
	<!-- player talkactions -->
	<talkaction words="!buypremium" script="buyprem.lua"/>
	<talkaction words="!leavehouse" script="leavehouse.lua"/>
	<talkaction words="!save" script="savecharacter.lua"/>
	<talkaction words="!changesex" script="changesex.lua"/>
	<talkaction words="!uptime" script="uptime.lua"/>
	<talkaction words="!deathlist" script="deathlist.lua"/>

	<!-- test talkactions -->
	<talkaction words="!z" script="magiceffect.lua"/>
	<talkaction words="!x" script="animationeffect.lua"/>
	
	<talkaction words="!makepoll" script="poll.lua" />
	<talkaction words="!vote" script="poll.lua" />
	<talkaction words="!endpoll" script="poll.lua" />
</talkactions>

And yes, i wanna save a normal char, not the server. I use mysql.

@xvidyx:
Code:
<talkaction log="yes" words="/save" access="3" event="script" value="save.lua"/>
<globalevent name="save" interval="2200" event="script" value="save.lua"/>
What is this? :S

Thanks for answer !
 
Try this, if doesnt work, dont know what is fuc* happening...
Code:
local savingEvent = 0

function onSay(cid, words, param)
	if getPlayerAccess(cid) ~= 0 then
		if isNumber(param) == TRUE then
			stopEvent(savingEvent)
			save(tonumber(param) * 60 * 1000)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
		else
			saveData()
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
		end
	end
end

function save(delay)
	saveData()
	if delay > 0 then
		savingEvent = addEvent(save, delay, delay)
	end
end
 
@Dantarrix: I change
Code:
	if getPlayerAccess(cid) ~= 0 then

to

Code:
	if getPlayerAccess(cid) ~= 1 then

And it works ! But.. how i can put exhausted?
 
Lol! Sorry, use this:
Code:
local savingEvent = 0
local storage = 7764
local time = 10
function onSay(cid, words, param)
	if exhaustion.get(cid, storage) <= 0 then
		if isNumber(param) == TRUE then
			stopEvent(savingEvent)
			save(tonumber(param) * 60 * 1000)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
                        exhaustion.set(cid, storage, time * 1000)
		else
			saveData()
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
                        exhaustion.set(cid, storage, time * 1000)
		end
        else
        doPlayerSendCancel(cid, "You are exhausted.")
	end
end

function save(delay)
	saveData()
	if delay > 0 then
		savingEvent = addEvent(save, delay, delay)
	end
end
Try with that... In local storage = 7764 write the number of storage used for exhaustion and in local time = 10 write how much seconds of exhaustion will player have ;)

If doesnt work, please report... I have some doubts with exhaustion, so try it with 10 seconds, and if it dont work, tell it to me ;)
 
The save works, not the exhausted:
Code:
[04/01/2012 23:21:08] Lua Script Error: [TalkAction Interface] 
[04/01/2012 23:21:08] data/talkactions/scripts/savecharacter.lua:onSay
[04/01/2012 23:21:08] data/talkactions/scripts/savecharacter.lua:5: attempt to index global 'exhaustion' (a nil value)
[04/01/2012 23:21:08] stack traceback:
[04/01/2012 23:21:08] 	[C]: in function '__index'
[04/01/2012 23:21:08] 	data/talkactions/scripts/savecharacter.lua:5: in function <data/talkactions/scripts/savecharacter.lua:4>

Kind Regards
 
Lol... Sorry, I didnt read that you are using TFS 9.31...
Code:
local savingEvent = 0
local storage = 7764
local time = 10
function onSay(cid, words, param)
	if getPlayerStorageValue(cid, storage) <= os.time() then
		if isNumber(param) == TRUE then
			stopEvent(savingEvent)
			save(tonumber(param) * 60 * 1000)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
                        setPlayerStorageValue(cid, storage, (os.time() + (time * 1000)))
		else
			saveData()
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your character has been saved.")
                        setPlayerStorageValue(cid, storage, (os.time() + (time * 1000)))
		end
        else
        doPlayerSendCancel(cid, "You are exhausted.")
	end
end
 
Back
Top