Jump to content
Sign in to follow this  
Julio

lua_isplayer

Recommended Posts

 

I'm facing some problem I can not see error in my script so it's something overloaded on cha_timer has anyone had this problem?

lua expand function [lua_isplayer] parameter number or type error!

 

Share this post


Link to post
Share on other sites

Hello, @Julio!

 

You can see this function in GameServer.exe source code:

inline int lua_IsPlayer(lua_State *L)
{T_B

	BOOL bValid = (lua_gettop (L)==1 && lua_islightuserdata(L, 1));
	if(!bValid) 
	{
		PARAM_ERROR
		return 0;
	}

	CCharacter *pCha = (CCharacter*)lua_touserdata(L, 1);
	if(pCha->GetPlayer())
	{
		lua_pushnumber(L, 1);
	}
	else
	{
		lua_pushnumber(L, 0);
	}
	return 1;
T_E}

Lua code:

local is_player = IsPlayer(role)
if (is_player == 1) then
  ...
else
  ...
end

Where role is character descriptor (type is userdata). Check if you pass a valid role to the function.

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Julio said:

 

I'm facing some problem I can not see error in my script so it's something overloaded on cha_timer has anyone had this problem?


lua expand function [lua_isplayer] parameter number or type error!

 

its better if you give the function and what it do(where you collecting the role data from)

  • Like 1

Share this post


Link to post
Share on other sites

The error was on the cloak. I modified it.

function cloak.getCloakLv(item)
	local getLv = GetItemAttr(item, 55);
	if(getLv ~= nil) then
		return getLv;
	elseif(IsPlayer(role) == 1) then
		if getLv > nil then
			return 0;
		end
		if getLv > 0 then
			return getLv;
		end
		return 0;
	end
end

 

for:
 

cloak.getCloakLv = function(item)
	local getLv = GetItemAttr(item, 55);
	if(getLv ~= nil) then
		return getLv;			
	end
end	

 

Share this post


Link to post
Share on other sites
2 hours ago, Julio said:

The error was on the cloak. I modified it.


function cloak.getCloakLv(item)
	local getLv = GetItemAttr(item, 55);
	if(getLv ~= nil) then
		return getLv;
	elseif(IsPlayer(role) == 1) then
		if getLv > nil then
			return 0;
		end
		if getLv > 0 then
			return getLv;
		end
		return 0;
	end
end

 

for:
 


cloak.getCloakLv = function(item)
	local getLv = GetItemAttr(item, 55);
	if(getLv ~= nil) then
		return getLv;			
	end
end	

 

you are calling for player role while the [role] is not defined try to see where the code is called from and add the role to the function it should fix it :))

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...