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

[0.3.6] Easy scripts.

Dymczas

New Member
Joined
Mar 8, 2009
Messages
105
Reaction score
0
Hello!
I need scripts

First:
When player clicks on item 9948 he gets xxx storage value ,appears message "XXX" and he lose 1000 HP.
He is able to do it only one time.
Second:
When player stands on tile with uid 'xxx', it's checked if he has storage value "xxx".
If he has storage value, he is teleported to XYZ
If he hasn't storage valute, appers message "XXX"
This is very similar to POI script.

Thanks for help :thumbup: :wub:
 
First
Code:
local config = {
	storage = 100, -- storage
	message = 'TEXT', -- message on succeed
	failmessage = 'You can\'t use this item twice.', -- message on fail
	hp = -1000 -- HP loss amount (must be negative '-')
	}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = getThingPos(cid)
	if getPlayerStorageValue(cid,config.storage) <= 0 then
		doPlayerSendTextMessage(cid,20,message)
		setPlayerStorageValue(cid,config.storage,1)
		doCreatureAddHealth(cid, config.hp)
		doSendMagicEffect(v,12)
	else
		doPlayerSendTextMessage(cid,20,failmessage)
		doSendMagicEffect(v,12)
	end
	return true
end

second.
Code:
local config = {
	storage = 101, -- storage
	message = '', -- message if succeed
	failmessage = '', -- message on fail
	pos = {x=1,y=1,z=1} -- pos to tp to
	}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if getPlayerStorageValue(cid,config.storage) <= 0 then
		doTeleportThing(cid,pos)
		doSendMagicEffect(pos,10)
		setPlayerStorageValue(cid,config.storage,1)
		doPlayerSendTextMessage(cid,20,message)
	else
		doPlayerSendTextMessage(cid,20,failmessage)
		doSendMagicEffect(cid,2)
		doTeleportThing(cid,fromPosition)
	end
	return true
end
 
@ thread
if the two scripts for any reason fail change:
This:
Code:
if getPlayerStorageValue(cid,config.storage) <= 0 then
For this:
Code:
if getPlayerStorageValue(cid,config.storage) == -1 then
 
Failed to see the things he was missing, and about the storage value thing,
I said that because I used to have problems getting storage values that were
not pre-specified(that were not set to the character before hand), and that's
the same code I used to use 'if getPlayerStorageValue(cid,config.storage) <= 0 then'
and it never worked for me! I don't know if it's my server but
that's how I do them in my server and it works, so my bad if I said
something wrong, I was just saying from my previous experience.
Anyways like I said earlier, I didn't even noticed that he didn't put
config.pos and other stuff.
 
Here I changed they things that Naruhto pointed out about the script,
here is the changes:
Code:
local config = {
	storage = 100, -- storage
	message = 'TEXT', -- message on succeed
	failmessage = 'You can\'t use this item twice.', -- message on fail
	hp = -1000 -- HP loss amount (must be negative '-')
	}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = getThingPos(cid)
	if getPlayerStorageValue(cid,config.storage) <= 0 then
		doPlayerSendTextMessage(cid,20,config.message)
		setPlayerStorageValue(cid,config.storage,1)
		doCreatureAddHealth(cid, config.hp)
		doSendMagicEffect(v,12)
	else
		doPlayerSendTextMessage(cid,20,config.failmessage)
		doSendMagicEffect(v,12)
	end
	return true
end
 
here is the other one:
Code:
local config = {
	storage = 101, -- storage
	message = '', -- message if succeed
	failmessage = '', -- message on fail
	pos = {x=1,y=1,z=1} -- pos to tp to
	}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if getPlayerStorageValue(cid,config.storage) <= 0 then
		doTeleportThing(cid,config.pos)
		doSendMagicEffect(config.pos,10)
		setPlayerStorageValue(cid,config.storage,1)
		doPlayerSendTextMessage(cid,20,config.message)
	else
		doPlayerSendTextMessage(cid,20,config.failmessage)
		doSendMagicEffect(getCreaturePosition(cid),2)
		doTeleportThing(cid,fromPosition)
	end
	return true
end
 
Failed to see the things he was missing, and about the storage value thing,
I said that because I used to have problems getting storage values that were
not pre-specified(that were not set to the character before hand), and that's
the same code I used to use 'if getPlayerStorageValue(cid,config.storage) <= 0 then'
and it never worked for me! I don't know if it's my server but
that's how I do them in my server and it works, so my bad if I said
something wrong, I was just saying from my previous experience.
Anyways like I said earlier, I didn't even noticed that he didn't put
config.pos and other stuff.

<= 0 ---> 0, -1, -2, -3, -4, -5, -6 ..... so == -1 its included :x
 
Back
Top