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

Lua Function doPlayerCastSpell

kuzara

New Member
Joined
Jan 13, 2010
Messages
209
Reaction score
1
Maybe someone need it? :w00t:
Code:
int32_t LuaScriptInterface::luaDoPlayerCastSpell(lua_State* L)
{
    //doPlayerCastSpell(uid, spellname)
    uint32_t uid = 0;
    std::string text = popString(L);
    uid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	Player* player = env->getPlayerByUID(uid);
	if(!player)
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}
	
	InstantSpell* instantSpell = g_spells->getInstantSpell(text);
	if(!instantSpell)	
    {
        errorEx(getError(LUA_ERROR_SPELL_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }
    
    return g_spells->onPlayerSay(player, text);
}
And...
Code:
	//doPlayerCastSpell(uid, spellname)
	lua_register(m_luaState, "doPlayerCastSpell", LuaScriptInterface::luaDoPlayerCastSpell);

For an example:
Code:
function onUse(cid)
doPlayerCastSpell(cid, "Exevo Gran Mas Vis") //when player use item of actionid then automatically cast spell
end
:p
 
Ohh i didnt seen this function before. Maybe because i search "doPlayerSaySpell".
In my version: if you put wrong words ("Exevo Gran Mas") then console print "(luaDoPlayerSaySpell) Spell not found"
Code:
	InstantSpell* instantSpell = g_spells->getInstantSpell(text);
	if(!instantSpell)	
    {
        errorEx(getError(LUA_ERROR_SPELL_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }
 
Back
Top