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

script help

TriamerA

The Mystic One.
Joined
Nov 16, 2008
Messages
1,256
Reaction score
17
Location
Poland
hello I have script which is removing 1 soul point from a player after 1 minute if he is at special sqm.
Code:
function onStepIn(cid, item, pos)



    if item.actionid == 17199 then
	if getPlayerSoul(cid) > 5  then
        addEvent(doPlayerAddSoul, 60 * 1000, cid, -1) 
else
		doPlayerSendTextMessage(cid,22, "You don't have enought soul points.")
          doTeleportThing(cid, {x = 1071, y = 1084, z = 7}) 
end
end

    return TRUE
end

But after player enter on that sqm it only happens once, and I want it to remove soul points untill player is at that sqm
 
Youll need to make another function, which calls on itself, every 60 seconds.
he's somewhat right, but the event can't be looped because if player logs out you'll get a lot of errors(where is the damn player?!)

try:

data/creaturescripts/scripts/soulless.lua
Lua:
function onThink(cid, interval)
    if getThingFromPos(getCreaturePosition(cid)).actionid == 17199 and getPlayerIdleTime(cid) == 60 * 1000 then
        doPlayerAddSoul(cid, -1)
    end
return true
end

data/creaturescripts/creaturescripts.xml
Lua:
<event type="think" name="SoulLess" event="script" value="soulless.lua"/>

add to: data/creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, "SoulLess")
 
Last edited:
Code:
function onStepIn(cid, item, fromPosition, toPosition)
    local soul = -1
    local time = 30 -- Seconds
    if(getPlayerSoul(cid) > 5) then
        addEvent(doPlayerAddSoul(cid, soul), time * 1000)
    else
        doPlayerSendCancel(cid, "You dont have enough soul points.")
    end
    return true
end
 
Code:
function onStepIn(cid, item, fromPosition, toPosition)
    local soul = -1
    local time = 30 -- Seconds
    if(getPlayerSoul(cid) > 5) then
        addEvent(doPlayerAddSoul(cid, soul), time * 1000)
    else
        doPlayerSendCancel(cid, "You dont have enough soul points.")
    end
    return true
end
that'll happen only once
 
It is not working, doesn't show any error but it doesnt take any soul points, any way botters are not idle so it wouldn't work ;/
 
Ok I've got it almost ready I think, but I still need your help to finish it. It's a kind of anti 24/7 botting at Training Monks
This is the script
Code:
function onStepIn(cid, item, pos)



    if (item.actionid == 18691) then
if getPlayerSoul(cid) > 5 then
		--player can enter
		addEvent(checking, 5 * 60 * 1000)
		else
		doPlayerSendCancel(cid, "You have not enough soul points.")
		--player can't enter
end
end



    return TRUE
end  

	local name = getCreatureName
	
	function checking
	if isOnline(name) then
	if (getPlayerSoul(cid) > 5) then
		doPlayerAddSoul(cid, -5)
		addEvent(checking, 5 * 60 * 1000)
	else
	end
	else
	doTeleportThing(cid, {x = xxxx, y = xxxx, z = xxxx})
	doPlayerSendCancel(cid, "You have not enough soul points, go hunt to get them.")
	end
	


return true
end

And I would forget, this is function which is in functions.lua in lib folder. This is checking if player is online

Code:
function isOnline(player)
	local rows = db.getResult("SELECT `online` FROM `players` WHERE `name` = " .. player .. ";")
	local on = rows:getDataInt("online")
	if on ~= 0 then
		return TRUE
	else
		return FALSE
	end
end

Rep++++++++ If someone will help me with making it work ;D
 
Lua:
function onThink(cid, interval)
	for _, pid in ipairs(getPlayersOnline()) do 
		if getThingFromPos(getCreaturePosition(pid)).actionid == 17199 and getPlayerIdleTime(pid) == 60 * 1000 then
			doPlayerAddSoul(pid, -1)
		end
    end
return true
end
 
It can't be done by idle time, because when players are using bot's they're not idle.

Code:
function onStepIn(cid, item, pos)



    if (item.actionid == 18888) then
if getPlayerSoul(cid) > 5 then
		--player can enter
		doPlayerSendCancel(cid, "Happy Training.")
		addEvent(checking, 3 * 1000)
		else
		doPlayerSendCancel(cid, "You have not enough soul points.")
		--player can't enter
end
end



    return TRUE
end  

	
	function checking(cid)
	 if (isPlayer(cid) == true) then         //checking if player is online
	if getPlayerSoul(cid) > 5 then
		doPlayerAddSoul(cid, -5)
		doPlayerSendCancel(cid, "Removed 5 soul Points.")
		addEvent(checking,  3 * 1000)
	else
	end
	else
	doTeleportThing(cid, {x = xxxx, y = xxxx, z = xxxx})
	doPlayerSendCancel(cid, "You have not enough soul points, go hunt to get them.")
	end
	


return true
end

And I'm getting

Code:
[Error - MoveEvents Interface] 
In a timer event called from: 
data/movements/scripts/soulless.lua:onStepIn
Description: 
(luaDoPlayerSendCancel) Player not found
 
It can't be done by idle time, because when players are using bot's they're not idle.

Code:
function onStepIn(cid, item, pos)



    if (item.actionid == 18888) then
if getPlayerSoul(cid) > 5 then
		--player can enter
		doPlayerSendCancel(cid, "Happy Training.")
		addEvent(checking, 3 * 1000)
		else
		doPlayerSendCancel(cid, "You have not enough soul points.")
		--player can't enter
end
end



    return TRUE
end  

	
	function checking(cid)
	 if (isPlayer(cid) == true) then         //checking if player is online
	if getPlayerSoul(cid) > 5 then
		doPlayerAddSoul(cid, -5)
		doPlayerSendCancel(cid, "Removed 5 soul Points.")
		addEvent(checking,  3 * 1000)
	else
	end
	else
	doTeleportThing(cid, {x = xxxx, y = xxxx, z = xxxx})
	doPlayerSendCancel(cid, "You have not enough soul points, go hunt to get them.")
	end
	


return true
end

And I'm getting

Code:
[Error - MoveEvents Interface] 
In a timer event called from: 
data/movements/scripts/soulless.lua:onStepIn
Description: 
(luaDoPlayerSendCancel) Player not found

Remove the idle time then

Lua:
function onThink(cid, interval)
	for _, pid in ipairs(getPlayersOnline()) do 
		if getThingFromPos(getCreaturePosition(pid)).actionid == 17199 then
			doPlayerAddSoul(pid, -1)
		end
    end
return true
end

EDIT: I guess you want the player to be teleported out of the room when he has below 5 soul points, then just do something like this:
Lua:
function onThink(cid, interval)
local tileAction == 1111  -- Action id on the tiles
	for _, pid in ipairs(getPlayersOnline()) do
		if getCreaturePosition(pid).actionid == tileAction then
			if getPlayerSoul(pid) > 5 then
				doPlayerAddSoul(pid, -1)
			else
				doTeleportThing(pid, getTownPosition(getPlayerTown(pid)))
			end
		end
	end
return true
end
 
Last edited:
Ehh your script will only make it happen one time. Anyway thanks for trying.
Just please, try to help me with fixing my script.
 
Please read my posts.
Your script will remove 1 soul points each time the player enter on a special tile.

I think it must be done the way which I'm making it.
But I'm getting error which I don't know how to fix dude.


Edit: I must also add a check if player is still standing on that tile in function 'checking'
 
... Global Event = checks every second if you want it to.
<globalevent name="check" interval="1" event="script" value="check.lua"/>

So if you set action id on the tiles he loses 1 soul every second...
 
Code:
[Error - LuaScriptInterface::loadFile] data/globalevents/scripts/check.lua:2: unexpected symbol near '=='
[Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/check.lua)
data/globalevents/scripts/check.lua:2: unexpected symbol near '=='
 
Lua:
function onThink(cid, interval)
local tileAction = 1111  -- Action id on the tiles
	for _, pid in ipairs(getPlayersOnline()) do
		if getCreaturePosition(pid).actionid == tileAction then
			if getPlayerSoul(pid) > 5 then
				doPlayerAddSoul(pid, -1)
			else
				doTeleportThing(pid, getTownPosition(getPlayerTown(pid)))
			end
		end
	end
return true
end

^^
 
And you have the same action id in the script as on the tiles?
In that case, I guess getCreaturePosition(pid).actionid doesn't work so you would need to set coordinates to the tiles instead.
 
Back
Top