• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved doPlayerSetRate

Slafesko

New Member
Joined
Jan 6, 2016
Messages
101
Reaction score
2
Simply i was trying to do doPlayerSetRate(cid, type, value) function to change exp
Code:
    function onLogin(cid)
local reb = getPlayerStorageValue(cid,85987)
local n = getPlayerVipDays(cid)
if reb > 0 and n < 1 then
doPlayerSetRate(cid, SKILL__LEVEL, 0.5)
end
if n > 0 and reb < 1 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
end
if reb > 0 and n > 0 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 0.75)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've got 50% extra exp.")
end
return true
end
Code:
function onLogin(cid)
local reb = getPlayerStorageValue(cid,85987)
local n = getPlayerVipDays(cid)
if reb > 0 and n < 1 then
doPlayerSetRate(cid, SKILL__LEVEL, 0.5)
elseif n > 0 and reb < 1 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
elseif reb > 0 and n > 0 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 0.75)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've got 50% extra exp.")
end
return true
end
So i tried it with 2 ways and none of them has worked, what i need to do is when someone get rebirth 1+ his exp downgrade to half
Code:
if reb > 0 and n < 1 then
doPlayerSetRate(cid, SKILL__LEVEL, 0.5)
and if this player have rebirth 1+ and Vip his exp change to 0.75
Code:
elseif reb > 0 and n > 0 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 0.75)
And if player is normal without rebirths and with VIP get
Code:
elseif n > 0 and reb < 1 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. n .." vip days left.")
doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
i hope so you understand me :S
 
data/creaturescripts/creaturescripts.xml
Code:
<event type="login" name="Change_Experience_Rate" event="script" value="change_experience_rate.lua"/>
data/creaturescripts/scripts/login.lua [somewhere near the bottom with the other registered events]
Code:
registerCreatureEvent(cid, "Change_Experience_Rate")
data/creaturescripts/scripts/change_experience_rate.lua
Code:
local rebirth = getPlayerStorageValue(cid, 85987)
local vip = getPlayerVipDays(cid)

function onLogin(cid)
     
     -- if player has rebirth
     if rebirth > 0 then
     
         -- if player does not have vip
         if vip < 1  then
             doPlayerSetRate(cid, SKILL__LEVEL, 0.5)
         
         -- if player does have vip
         else
             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. vip .." vip days left.")
             doPlayerSetRate(cid, SKILL__LEVEL, 0.75)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
         end
         return true
     
     -- if player does not have rebirth
     elseif rebirth < 0 then
     
         -- player does not have vip
         if vip < 1 then
             doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
         
           -- if player does have vip
         else
             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. vip .." vip days left.")
             doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
         end
         return true
     
     -- if something is wrong
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Something done fucked up. Contact administrator about experience.")
         doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
     end
     
     return true
end
 
data/creaturescripts/creaturescripts.xml
Code:
<event type="login" name="Change_Experience_Rate" event="script" value="change_experience_rate.lua"/>
data/creaturescripts/scripts/login.lua [somewhere near the bottom with the other registered events]
Code:
registerCreatureEvent(cid, "Change_Experience_Rate")
data/creaturescripts/scripts/change_experience_rate.lua
Code:
local rebirth = getPlayerStorageValue(cid, 85987)
local vip = getPlayerVipDays(cid)

function onLogin(cid)
    
     -- if player has rebirth
     if rebirth > 0 then
    
         -- if player does not have vip
         if vip < 1  then
             doPlayerSetRate(cid, SKILL__LEVEL, 0.5)
        
         -- if player does have vip
         else
             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. vip .." vip days left.")
             doPlayerSetRate(cid, SKILL__LEVEL, 0.75)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
         end
         return true
    
     -- if player does not have rebirth
     elseif rebirth < 0 then
    
         -- player does not have vip
         if vip < 1 then
             doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
        
           -- if player does have vip
         else
             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have ".. vip .." vip days left.")
             doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have got 50% extra exp.")
         end
         return true
    
     -- if something is wrong
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Something done fucked up. Contact administrator about experience.")
         doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
     end
    
     return true
end
Well thanks, i will try it and thanks cuz of your tutorial :P i've learned from your script.
 
2nbzpsk.jpg

050-Function.lua line 22
Code:
function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days= Info:getDataInt("vipdays")
Info:free()
return days
end
return LUA_ERROR
end

function doAddVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doRemoveVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = "
that's what i found.
 
Back
Top