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

Solved Get value amount of storage value- Avesta

Merry Christmas!
Do you happen to know why the script is using this:
Code:
local points = math.max(0,getPlayerStorageValue(cid, 7035))
For this application, surely the following would be fine...and may even solve all your problems.
Code:
local points = getPlayerStorageValue(cid, 7035)

Full script here ->
Code:
local points = getPlayerStorageValue(cid, 7035)
 
function onStepIn(cid, item, position, fromPosition)
 
	if item.uid == 4000 then
	doSendMagicEffect(position, 13)
		if getPlayerStorageValue(cid, 7035) >= 1 then
			doPlayerSendTextMessage(cid, 17, "You have " ..points.. " points.")
		else
			doPlayerSendTextMessage(cid, 17, "You have zero points! Donate today to get more points.")
		end
	end
	return true
end

I have got no idea what math.max does, but I cannot see any point for it here regardless!
 
I used getPlayerStorageValue(cid, 7035) in the first place.... It returns this value -1. Yet, it will say "You have -1 points."

Heres my source for getPlayerStorageValue
Code:
int LuaScriptInterface::luaGetPlayerStorageValue(lua_State *L)
{
	//getPlayerStorageValue(cid, valueid)
	uint32_t key = popNumber(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();

	const Player* player = env->getPlayerByUID(cid);
	if(player){
		int32_t value;
		if(player->getStorageValue(key, value)){
			lua_pushnumber(L, value);
			lua_pushboolean(L, true);
		}
		else{
			lua_pushnumber(L, -1);
			lua_pushboolean(L, false);
		}
	}
	else{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushnumber(L, -1);
		lua_pushboolean(L, false);
	}
	return 2;
}
 
perhaps this shitty hack will help:

LUA:
doPlayerSendTextMessage(cid, 17, "You have " ..(points+1).. " points.")
 
Naw. I don't need it to + 1. Don't worry i solved it. Broke down and coded a function in source xD. CLOSE THREAD.
 
Back
Top