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

Compiling Help with this own function!

Exedion

Active Member
Joined
Jun 11, 2007
Messages
629
Reaction score
30
i tried to make the function "doSendCooldown" but that give me this console error:

Code:
[17:24:26.495] [Error - CreatureScript Interface]
[17:24:26.497] data/creaturescripts/scripts/login.lua:onLogin
[17:24:26.498] Description:
[17:24:26.499] attempt to index a number value
[17:24:26.500] stack traceback:
[17:24:26.500]  [C]: in function 'doSendCooldown'
[17:24:26.501]  data/creaturescripts/scripts/login.lua:46: in function <data/cre
aturescripts/scripts/login.lua:6>

this are the line what i'm using:
LUA:
	doSendCooldown(cid, 20, 1000, false)

this is the code i made:

[cpp]
int32_t LuaInterface::luaDoSendCooldown(lua_State* L)
{
//doSendCooldown(cid, icon, cooldown[, isGroup])
bool isGroup = false;
uint16_t icon = popNumber(L);
uint32_t cooldown = popNumber(L);

ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->sendSpellCooldown(icon, cooldown, isGroup);
lua_pushboolean(L, true);
}
else{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}
[/cpp]

and this are the lua function with parameters:

LUA:
doSendCooldown(cid, icon, cooldown[, isGroup])
 
try this:
Code:
int32_t LuaInterface::luaDoSendCooldown(lua_State* L)
{
	//doSendCooldown(cid, icon, cooldown[, isGroup])
	bool isGroup = false;
	uint16_t icon = popNumber(L);
	uint32_t cooldown = popNumber(L);
 
	ScriptEnviroment* env = getEnv();
	if (lua_gettop(L) > 3)
		isGroup = popBoolean(L);

	if(Player* player = env->getPlayerByUID(popNumber(L)))
	{
		player->sendSpellCooldown(icon, cooldown, isGroup);
		lua_pushboolean(L, true);
	}
	else
	{       
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	} 
 
	return 1;
}
 
Still getting the same error

Code:
[17:54:40.481] [Error - CreatureScript Interface]
[17:54:40.482] data/creaturescripts/scripts/login.lua:onLogin
[17:54:40.482] Description:
[17:54:40.483] attempt to index a number value
[17:54:40.484] stack traceback:
[17:54:40.492]  [C]: in function 'doSendCooldown'
[17:54:40.493]  data/creaturescripts/scripts/login.lua:46: in function <data/cre
aturescripts/scripts/login.lua:6>
 
try this...
[cpp]int32_t LuaInterface::luaDoSendCooldown(lua_State* L)
{
//doSendCooldown(cid, icon, cooldown[, isGroup])
uint32_t cid = popNumber(L);
uint16_t icon = popNumber(L);
uint32_t cooldown = popNumber(L);
bool isGroup = false;
ScriptEnviroment* env = getEnv();
if (lua_gettop(L) > 3)
isGroup = popBoolean(L);

if(Player* player = env->getPlayerByUID(cid))
{
player->sendSpellCooldown(icon, cooldown, isGroup);
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}[/cpp]
 
Still the same error... take a look to the cooldown function please

[cpp]
void ProtocolGame::sendSpellCooldown(uint16_t spellId, uint32_t cooldown, bool isGroup)
{
if(!spellId)
return;
NetworkMessage_ptr msg = getOutputBuffer();
if(msg)
{
TRACK_MESSAGE(msg);
msg->put<char>((isGroup)?0xA5:0xA4);
msg->put<char>(spellId);
msg->put<uint32_t>(cooldown);
}
}
[/cpp]

bump
 
Last edited by a moderator:
Ok i tried to make the function without "groupCooldowns" and i don't get any error but nothing happens!

someone see this please

[cpp]
int32_t LuaInterface::luaDoSendCooldown(lua_State* L)
{
//doSendCooldown(cid, icon, cooldown)

uint16_t icon = popNumber(L);
uint32_t cooldown = popNumber(L);

ScriptEnviroment* env = getEnv();

if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->sendSpellCooldown(Spells_t(icon), cooldown, false);
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}
[/cpp]
 
Maybe it is because parameters are wrong.

If you pop "icon" first it is the last parameter not the second.. like this: doSendCooldown(cid, cooldown, icon)
So basically try to call the function as it was like "doSendCooldown(cid, cooldown, icon)" or switch the lines where icon and cooldown is popped
[cpp]
//doSendCooldown(cid, icon, cooldown)
uint16_t icon = popNumber(L);
uint32_t cooldown = popNumber(L);
[/cpp]
 
Maybe it is because parameters are wrong.

If you pop "icon" first it is the last parameter not the second.. like this: doSendCooldown(cid, cooldown, icon)
So basically try to call the function as it was like "doSendCooldown(cid, cooldown, icon)" or switch the lines where icon and cooldown is popped
[cpp]
//doSendCooldown(cid, icon, cooldown)
uint16_t icon = popNumber(L);
uint32_t cooldown = popNumber(L);
[/cpp]

take a look to the function
[cpp]
void ProtocolGame::sendSpellCooldown(uint16_t spellId, uint32_t cooldown, bool isGroup)
[/cpp]

i posted, icon is first
 
I don't know, maybe Stian can help you. Try to contact him.

But maybe you should google "FIFO" if you call the function:
doSendCooldown(cid, icon, cooldown)
You have COOLDOWN|ICON|CID
if you popNumber it will take COOLDOWN first since it was put in as the last (parameters of lua function), the next pop will take ICON and then third will take CID so you need to swap cooldown and icon..
 
I don't know, maybe Stian can help you. Try to contact him.

But maybe you should google "FIFO" if you call the function:
doSendCooldown(cid, icon, cooldown)
You have COOLDOWN|ICON|CID
if you popNumber it will take COOLDOWN first since it was put in as the last (parameters of lua function), the next pop will take ICON and then third will take CID so you need to swap cooldown and icon..

i try that already and... nothing... bump!
 
Back
Top