TalkAction !save(Saves character)

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Best answers
0
Reaction score
6
Location
London, Ontario
Forgot to add instructions. :p

Step 1 -
Go to talkactions.
Step 2 -
Open talkactions.xml
Step 3 -
Go to your players section and add:
Code:
<talkaction words="!save" event="script" value="savecharacter.lua"/>
Step 4 -
Go to talkaction scripts.
Step 5 -
Create savecharacter.lua
Step 6 -
Finally add this code:
Lua:
local waittime = 30 --Default (30 seconds)
local storage = 5560

function onSay(cid, words, param, channel) 
	if exhaustion.get(cid, storage) == FALSE then
		doPlayerSave(cid)
		exhaustion.set(cid, storage, waittime)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have successfully saved your character.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. exhaustion.get(cid, storage) .. " seconds.")
	end	
	return TRUE 
end
Step 7 -
Go to your lib folder, and at the end of data.lua
Add:
Lua:
dofile(getDataDir() .. "lib/exhaustion.lua")
Step 8 -
Save and your done.

Basically what this does is it saves the player without them having to logout, and I also added in a delay so it can't be spammed.

Useful if the player gets a Donation item and doesn't want to relog, or has PZ.

Default delay is 30 seconds.

Newest script (updated at last edit) - Will now tell you how many more seconds you need to wait, and uses a storage value as the exhaust. (Thanks again Slawkens and Zonet for the bit of codes)

Credits:
Me(Script)
Sizaro(Idea)
JDB and chris77(Fixing a bit)
Zonet(Idea/Fixing a bit)
Slawkens(exhaustion)
 
Last edited:
Joined
Apr 17, 2008
Messages
1,922
Best answers
0
Reaction score
181
Location
Venezuela
Lua:
local waittime = 30 --Default (30 seconds)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (1000 * waittime))

function onSay(cid, words, param, channel) 
	if hasCondition(cid, CONDITION_EXHAUST) == FALSE then
		doPlayerSave(cid)
		doAddCondition(cid, exhaust)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait 30 seconds between each save."
	end	
	return TRUE 
end
Basically what this does is it saves the player without them having to logout, and I also added in a delay so it can't be spammed.

Useful if the player gets a Donation item and doesn't want to relog, or has PZ.

Default delay is 30 seconds.

Credits:
Me(Script)
Sizaro(Idea)
Bad bad bad.. "doPlayerSave(cid)" doesn't exist.
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Forget this~
 
Last edited:

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
doPlayerSave(cid) exist...at least in 0.3.5 xD
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Forget this~
 
Last edited:
OP
D

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Best answers
0
Reaction score
6
Location
London, Ontario
Uhm... it does exist in Crying Damson 0.3.4... I just went into my sources and checked the LuaScript, and it's there... ._.

It also works like it's meant to... I gave my character an item, typed !save, then crashed my server, and he still had the item after I brought it back up. So, besides the misunderstandings, what do ya guys think of the script?
 

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
Well if the function actually works, Nice :p
 

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
Can anyone confirm this? Is this working? Then what of those scripts in this thread is working for 0.3.4 crying domson :p
 
OP
D

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Best answers
0
Reaction score
6
Location
London, Ontario
Can anyone confirm this? Is this working? Then what of those scripts in this thread is working for 0.3.4 crying domson :p
My script is 100% working on 0.3.4. I even showed proof that the function exists.

:)
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
It must work, im surprised. :cool:
 

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
It work, but use better use storages (exhaustion.set & exhaustion.get) or your character may be frozen with spells (But I'm not sure)
 

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
Cannot load script (data/talkactions/scripts/savecharacter.lua
data/talkactions/scripts/savecharacter.lua:11: ')' expected (to close '(' at line 10) near 'end'
short
 

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
The kid forgot a bracket ;p...

Code:
local waittime = 30 --Default (30 seconds)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (1000 * waittime))

function onSay(cid, words, param, channel) 
        if hasCondition(cid, CONDITION_EXHAUST) == FALSE then
                doPlayerSave(cid)
                doAddCondition(cid, exhaust)
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait 30 seconds between each save.")
        end     
        return TRUE 
end
 
OP
D

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Best answers
0
Reaction score
6
Location
London, Ontario
The kid forgot a bracket ;p...

Code:
local waittime = 30 --Default (30 seconds)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (1000 * waittime))

function onSay(cid, words, param, channel) 
        if hasCondition(cid, CONDITION_EXHAUST) == FALSE then
                doPlayerSave(cid)
                doAddCondition(cid, exhaust)
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait 30 seconds between each save.")
        end     
        return TRUE 
end
Lol, thanks. --1st post updated.--
 

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
Can anyone fix so it says when you say !save

You saved your character.
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Lua:
local waittime = 30 --Default (30 seconds)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (1000 * waittime))

function onSay(cid, words, param, channel) 
        if hasCondition(cid, CONDITION_EXHAUST) == FALSE then
                doPlayerSave(cid)
                doAddCondition(cid, exhaust)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have successfully saved your character.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait 30 seconds between each save.")
        end     
        return TRUE 
end
 
Top