ConAn Edujawa
Member
- Joined
- Feb 23, 2015
- Messages
- 457
- Reaction score
- 17
how i can make if player have premium get 200 soul if no premium 100 soul ?
tfs 0.4
tfs 0.4
int32_t LuaInterface::luaDoPlayerSetMaxSoul(lua_State* L)
{
//doPlayerSetMaxSoul(cid, maxSoul)
uint32_t maxSoul = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)));
{
player->soulMax = std::min((uint32_t)200, maxSoul);
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
int32_t LuaInterface::luaGetPlayerMaxSoul(lua_State* L)
{
//getPlayerMaxSoul(cid)
ScriptEnviroment* env = getEnv();
const Player* player = env->getPlayerByUID(popNumber(L));
if (player) {
lua_pushnumber(L, player->soulMax))...
i set all in vocation.xml soul=100 but how i can add max soul 200 in loging ?Promoted vocations have more soul by default, and require premium by default. Is that good enough? If not, you can always check the players premium status onLogin (creature event) and set their max soul accordingly.
so there no script make when player get premium max soul change to 200 and when back free max soul back to 100 ?Just checked the github and it doesn't seem there is a way to set max soul. You will have to add it yourself I suppose.
int32_t LuaInterface::luaDoPlayerSetMaxSoul(lua_State* L)
{
//doPlayerSetMaxSoul(cid, maxSoul)
uint32_t maxSoul = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)));
{
player->soulMax = std::min((uint32_t)200, maxSoul);
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
int32_t LuaInterface::luaGetPlayerMaxSoul(lua_State* L)
{
//getPlayerMaxSoul(cid)
ScriptEnviroment* env = getEnv();
const Player* player = env->getPlayerByUID(popNumber(L));
if (player) {
lua_pushnumber(L, player->soulMax));
}
else {
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
if getPlayerPremiumDays(cid) ~= 0 then
if getPlayerMaxSoul(cid) ~= 200 then
doPlayerSetMaxSoul(cid, 200)
doPlayerAddSoul(cid, getPlayerSoul(cid) + 100)
end
else
if getPlayerMaxSoul(cid) ~= 100 then
doPlayerSetMaxSoul(cid, 100)
doPlayerAddSoul(cid, -math.min(0, -(getPlayerSoul(cid) - 100)))
end
end
Haven't tested:
C++:int32_t LuaInterface::luaDoPlayerSetMaxSoul(lua_State* L) { //doPlayerSetMaxSoul(cid, maxSoul) uint32_t maxSoul = popNumber(L); ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) { player->soulMax = std::min((uint32_t)200, maxSoul); lua_pushboolean(L, true); } else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; }
C++:int32_t LuaInterface::luaGetPlayerMaxSoul(lua_State* L) { //getPlayerMaxSoul(cid) ScriptEnviroment* env = getEnv(); const Player* player = env->getPlayerByUID(popNumber(L)) if (player) { lua_pushnumber(L, player->soulMax)); } else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; }
Then you can add in login script:
LUA:if getPlayerPremiumDays(cid) ~= 0 then if getPlayerMaxSoul(cid) ~= 200 then doPlayerSetMaxSoul(cid, 200) doPlayerAddSoul(cid, getPlayerSoul(cid) + 100) end else if getPlayerMaxSoul(cid) ~= 100 then doPlayerSetMaxSoul(cid, 100) doPlayerAddSoul(cid, -math.min(0, -(getPlayerSoul(cid) - 100))) end end
int32_t LuaInterface::luaGetPlayerMaxSoul(lua_State* L)
{
//getPlayerMaxSoul(cid)
ScriptEnviroment* env = getEnv();
if(const Player* player = env->getPlayerByUID(popNumber(L)))
lua_pushnumber(L, player->soulMax);
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}