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

Cast Open (experience)

Kownikuzyt

Member
Joined
Feb 11, 2020
Messages
170
Solutions
1
Reaction score
8
Hello, I searched the forum for a script on !Cast + 20% exp.

I noticed the topic: experience cast open (https://otland.net/threads/experience-cast-open.261391/)

I got 55 exp from a monster and with this script I get 5 exp.

Code: data/talkactions/scripts/cast.lua



Lua:
 storage = 17754

function onSay(player, words, param)
    
if param == 'on' then
        if player:startLiveCast() then
            player:setStorageValue(storage, 1)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay.")
        else
            player:sendCancelMessage("You're already casting your gameplay.")
        end
    elseif param == 'off' then
        if player:stopLiveCast() then
            player:setStorageValue(storage, 0)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay.")
        else
            player:sendCancelMessage("You're not casting your gameplay.")
        end
    end
    
    return false
end

Code: /home/ots/data/events/scripts/player.lua



Lua:
function Player:onGainExperience(source, exp, rawExp)
     if not source or source:isPlayer() then
         return exp
     end
    
    local multiplier = 1.2
    if player:getStorageValue(17754) == 1 then
        exp = exp * multiplier
    end
 
Solution
@Evil Puncker

Sorry, I misunderstood :(

Code: /home/ots/data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    if print(self:getStorageValue(17754)) == 1 then
        print(exp) = exp * multiplier
    end



Console:

[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:3: unexpected symbol near '='
Something more like this, so you are printing useful information and know exactly what's happening.
Lua:
local multiplier = 1.3

if self:getStorageValue(17754) == 1 then
    print("have storage")
    exp = exp * multiplier
    print("exp is:" .. exp)
else
    print("dont have storage")
end
and what was the code you had correct behavior with? Because theoretically, this should work.
Is there any console error when you receive exp?
 
and what was the code you had correct behavior with? Because theoretically, this should work.
Is there any console error when you receive exp?
@4Nathu4

There is an error on the console !Cast in the console:


Lua Script Error: [Event Interface]
data/events/scripts/player.lua: player@onGainExperience
data/events/scripts/player.lua:7: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/events/scripts/player.lua:7: in function <data/events/scripts/player.lua:1>
 
Last edited:
add some prints everywhere to see if the code is being executed and to see what values they are returning

print("hello world") is the way to go when you don't know where your problem is :D
 
add some prints everywhere to see if the code is being executed and to see what values they are returning

print("hello world") is the way to go when you don't know where your problem is :D
@Evil Puncker

Console:

Borry has logged in.
hello world
hello world
hello world
hello world
Borry has logged out.

Code: /home/ots/data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    print("hello world")
    if self:getStorageValue(17754) == 1 then
    print("hello world")
        exp = exp * multiplier
        print("hello world")
    end



I do not understand, it does not display errors :(
Maybe too little exp?

multiplier = 1.3
 
you were supposed to write different messages in each print so you know the ones being executed and the ones that failed 😅

you can also use them to display values, like:

print(self:getStorageValue(17754))
and
print(exp)
 
you were supposed to write different messages in each print so you know the ones being executed and the ones that failed 😅

you can also use them to display values, like:

print(self:getStorageValue(17754))
and
print(exp)
@Evil Puncker

Sorry, I misunderstood :(

Code: /home/ots/data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    if print(self:getStorageValue(17754)) == 1 then
        print(exp) = exp * multiplier
    end



Console:

[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:3: unexpected symbol near '='
 
Last edited:
@Evil Puncker

Sorry, I misunderstood :(

Code: /home/ots/data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    if print(self:getStorageValue(17754)) == 1 then
        print(exp) = exp * multiplier
    end



Console:

[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:3: unexpected symbol near '='
Something more like this, so you are printing useful information and know exactly what's happening.
Lua:
local multiplier = 1.3

if self:getStorageValue(17754) == 1 then
    print("have storage")
    exp = exp * multiplier
    print("exp is:" .. exp)
else
    print("dont have storage")
end
 
Solution
Something more like this, so you are printing useful information and know exactly what's happening.
Lua:
local multiplier = 1.3

if self:getStorageValue(17754) == 1 then
    print("have storage")
    exp = exp * multiplier
    print("exp is:" .. exp)
else
    print("dont have storage")
end
@Silba

Code: /home/ots/data/events/scripts/player.lua




Lua:
local multiplier = 1.3


if self:getStorageValue(17754) == 1 then
    print("have storage")
    exp = exp * multiplier
    print("exp is:" .. exp)
else
    print("dont have storage")
end

Console:

Borry has logged in.
dont have storage
dont have storage
Borry has logged out.
 
@Silba

Code: /home/ots/data/events/scripts/player.lua






Console:

Borry has logged in.
dont have storage
dont have storage
Borry has logged out.
So the storage either isn't being applied or you're not checking for it correctly. Sorry I can't help with the rest of the script, but now you've identified a problem it's easier for those able to help. Good luck.
 
So the storage either isn't being applied or you're not checking for it correctly. Sorry I can't help with the rest of the script, but now you've identified a problem it's easier for those able to help. Good luck.
@Silba

Thanks for your willingness to help, I'm still messing around and rewriting the script, maybe it will discover a new bug that will help solve this mystery.
 
I solved the problem:

@Silba

Code: data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    if self:getStorageValue(17754) == 1 then
        exp = exp * multiplier
    end

Code: data/talkactions/scripts/cast.lua



Lua:
local storage = 17754 -- exp storage


function onSay(player, words, param)
    
    if param == "on" then param = nil end
        if player:startLiveCast(param) then
            player:setStorageValue(storage, 1)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay. Commands: !spectators")
        else
            player:sendCancelMessage("You're already casting your gameplay.")
        end
    if param == "off" then
            if player:stopLiveCast(param) then
            player:setStorageValue(storage, 0)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay.")
        else
            player:sendCancelMessage("You're not casting your gameplay.")
        end
    end
    
    return false
end
 
I solved the problem:

@Silba

Code: data/events/scripts/player.lua



Lua:
local multiplier = 1.3
    if self:getStorageValue(17754) == 1 then
        exp = exp * multiplier
    end

Code: data/talkactions/scripts/cast.lua



Lua:
local storage = 17754 -- exp storage


function onSay(player, words, param)
   
    if param == "on" then param = nil end
        if player:startLiveCast(param) then
            player:setStorageValue(storage, 1)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay. Commands: !spectators")
        else
            player:sendCancelMessage("You're already casting your gameplay.")
        end
    if param == "off" then
            if player:stopLiveCast(param) then
            player:setStorageValue(storage, 0)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay.")
        else
            player:sendCancelMessage("You're not casting your gameplay.")
        end
    end
   
    return false
end
awesome, glad you got it figured out :)
 
@Kownikuzyt
Remember to reset storage in some on-login script. Players may start cast, relog (which close cast) and it will still give them bonus for casting.
@Gesior.pl

Even though the script works fine, sometimes I have a problem and don't know how to solve it :(.

"Remember to reset the memory in some login script."
I haven't done it yet, could that be the reason?
How do I restart my memory?

cas.png


The problem is that the Cast system has crashed and shows incorrectly in Lobby Cast. Instead of one person, she shows two. Sometimes I get an error and crashes the client (not always, but it does).
 
Common problem with cast systems is that, they are not cleaning 'cast' state on server shutdown/startup. After server restart, there are values 'cast = 1' in database, so it shows them on 'casts list'. Some of them also not cleaning database when player dies while casting. There should be scripts that update table players (set cast = 0 for given player or all players) on server start, on player death and on player logout.

I don't know what cast system you are using. If it's based on 'djarek cast system', it will debug client on login (join cast) sometimes.
Client debug occurs, when there are many players/monsters on screen and they are running when you join cast.
 
Guys, I know it's not the subject of the topic, but it has the cast system, I don't understand anything about database. My game is currently online. How can I correctly change my database so I don't even have a problem?


[Error - mysql_real_query] Query: SELECT name, level, spectators FROM players LEFT JOIN players_online on players.id = players_online.player_id WHERE broadcasting = 1
Message: Unknown column 'spectators' in 'field list'
[Error - mysql_store_result] Query: SELECT name, level, spectators FROM players LEFT JOIN players_online on players.id = players_online.player_id WHERE broadcasting = 1
Message: Unknown column 'spectators' in 'field list'
[Error - mysql_real_query] Query: SELECT index FROM player_containers WHERE player_id = 114 ORDER BY index DESC
Message: Table 'database.player_containers' doesn't exist
[Error - mysql_store_result] Query: SELECT index FROM player_containers WHERE player_id = 114 ORDER BY index DESC
Message: Table 'database.player_containers' doesn't exist
Dodger has logged in.
[Error - mysql_real_query] Query: INSERT INTO players_online (player_id, broadcasting, password, description, spectators) VALUES (114, 0, '', '', 0)
Message: Unknown column 'broadcasting' in 'field list'
[Error - mysql_real_query] Query: DELETE FROM player_containers WHERE player_id = 114
Message: Table 'database.player_containers' doesn't exist

 
Guys, I know it's not the subject of the topic, but it has the cast system, I don't understand anything about database. My game is currently online. How can I correctly change my database so I don't even have a problem?





@APTGET


[Error - mysql_real_query] Query: SELECT name, level, spectators FROM players LEFT JOIN players_online on players.id = players_online.player_id WHERE broadcasting = 1
Message: Unknown column 'spectators' in 'field list'

There are no spectators columns in the 'players' tab.

Adding a column:
ALTER TABLE players ADD COLUMN` spectators` x x x x 'x';

x - values of the 'spectators' column.



[Error - mysql_real_query] Query: SELECT index FROM player_containers WHERE player_id = 114 ORDER BY index DESC
Message: Table 'database.player_containers' doesn't exist

There are no spectators columns in the 'players' tab.

Adding a column:
ALTER TABLE player_containers ADD COLUMN player_containers x x x x 'x';

x - values of the 'player_containers' column.



[Error - mysql_real_query] Query: INSERT INTO players_online (player_id, broadcasting, password, description, spectators) VALUES (114, 0, '', '', 0)
Message: Unknown column 'broadcasting' in 'field list'

There are no spectators columns in the 'players' tab.

Adding a column:
ALTER TABLE players_online ADD COLUMN broadcasting x x x x 'x';

x - values of the 'broadcasting' column.



[Error - mysql_store_result] Query: SELECT * FROM z_ots_communication;
Message: Table 'cast.z_ots_communication' doesn't exist

CREATE TABLE IF NOT EXISTS z_ots_comunication (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
type varchar(255) NOT NULL,
action varchar(255) NOT NULL,
param1 varchar(255) NOT NULL,
param2 varchar(255) NOT NULL,
param3 varchar(255) NOT NULL,
param4 varchar(255) NOT NULL,
param5 varchar(255) NOT NULL,
param6 varchar(255) NOT NULL,
param7 varchar(255) NOT NULL,
delete_it int(2) NOT NULL DEFAULT '1',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=230 ;
 
Back
Top