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

why is it not working?

Bowstons

New Member
Joined
Nov 15, 2020
Messages
10
Solutions
1
Reaction score
0
hello, why my creaturescript not working? im registered it in login.lua
Lua:
registerCreatureEvent(cid, "name")
creaturescripts.xml
Code:
<event type="login" name="name" event="script" value="name.lua"/>
and the code is
Code:
function onStatsChange(cid, attacker, type, combat, value)
        if type == STATSCHANGE_HEALTHGAIN and isPlayer(cid) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "something")
        end
return true
end

what else I have to do to make it work? im using 0.3.6 tfs

when i a
 
@Bowstons It's because you registered login type and using onStatsChange function. You should call function onLogin(cid) instead.

Lua:
function onLogin(cid)
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "something")
  return true
end
 
ok bro. I want to send a message to player when Im attacked someone.

Lua:
<event type="statschange" name="name" event="script" value="name.lua"/>
Code:
function onStatsChange(cid, attacker, type, combat, value)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "something")
doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "something1")
return true
end

and it doesnt work
 
creaturescripts.xml
Code:
<event type="statschange" name="name" event="script" value="name.lua"/>
name.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "something")
    end
    if isPlayer(attacker) then
        doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "something1")
    end
return true
end
 
To be clear, you still need to register this script in login.lua, otherwise it won't initialize on the player.

login.lua [near the bottom with the other registered events]
Lua:
registerCreatureEvent(cid, "test_script_1")
creaturescripts.xml
XML:
<event type="statschange" name="test_script_1" event="script" value="test_script_1.lua"/>
test_script_1.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)

	-- confirm that health is being reduced
	if type == STATSCHANGE_HEALTHLOSS then
	
		-- send message to player receiving damage
		if isPlayer(cid) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "something")
		end
		
		-- send message to player dealing damage
		if isPlayer(attacker) then
			doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "something1")
		end
		
	end
	
	-- confirm that damage will go through to the player
	return true
end
 
Back
Top