• 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 [Talkaction] Premium Points to accname

Shackal

Alien Project
Joined
Feb 7, 2009
Messages
211
Reaction score
17
Location
Brazil
Hello peoples!!

I'm trying to make this script give premium points by account name, not by Player name and deliver points the same is offline..
actually this script work like:
/addpoints PLAYERNAME, POINTS
i want:
/addpoints ACCNAME, POINTS
Code:
function onSay(cid, words, param)

    local t = string.explode(param, ",")
  
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing params.")
        return true
    end
  
    local player, balance, pid = getPlayerByName(t[1]), t[2], getPlayerByNameWildcard(t[1])
  
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That players doesnt exist or is offline.")
        return true
    end
  
    if t[2] == null then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing ammount of points.")
        return true
    end
  
    local accountName = getPlayerAccount(player)
    local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. accountName .. "' LIMIT 1;")
    local points = tonumber(accountPoints:getDataInt("premium_points"))
    local name = getPlayerName(cid)
  
    if(words == "/addpoints") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added "..balance.." premium points to "..t[1].." account.")
        doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, "You got "..balance.." premium points from "..name..".")
        points = (points+balance)
        db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")
    elseif (words == "/removepoints") then
        points = (points-balance)
        if points < 0 then
            doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..name.." removed all your premium points.")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed all "..t[1].." account premium points.")
            db.query("UPDATE `accounts` SET `premium_points` = '0' WHERE `name`='" .. accountName .. "' LIMIT 1;")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed "..balance.." premium points to "..t[1].." account.")
            db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")  
            doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..name.." removed "..balance.." premium points from your account.")
        end
    end
  
    return true
end

thank you in advance and sorry my bad english!!

i try with function getAccountName but not work, can u help me please.
 
Last edited by a moderator:
Atm it has this.
~~
local player, balance, pid = getPlayerByName(t[1]), t[2], getPlayerByNameWildcard(t[1])
~~
So player gets the creaureid based on player name.
Under that it checks if the player is offline/exists, so you can remove that.
Then there is this.
Code:
local accountName = getPlayerAccount(player)
This gets the account based on creatureid, since player was the creatureid of the name used in the command.
You can see that t[1] stands for the first word you use in the command, the name of the player in this case.
So you can just change getPlayerAccount(player) to t[1] and remove the textmessages with player.
 
don't work bro

Code:
function onSay(cid, words, param)

    local t = string.explode(param, ",")
 
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing params.")
        return true
    end
 
    local balance, pid = getPlayerByName(t[1]), t[2], getPlayerByNameWildcard(t[1])
 
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That players doesnt exist or is offline.")
        return true
    end
 
    if t[2] == null then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing ammount of points.")
        return true
    end
 
    local accountName = t[1]
    local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. accountName .. "' LIMIT 1;")
    local points = tonumber(accountPoints:getDataInt("premium_points"))
    local name = getPlayerName(cid)
 
    if(words == "/addpoints") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added "..balance.." premium points to "..t[1].." account.")
        points = (points+balance)
        db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")
    elseif (words == "/removepoints") then
        points = (points-balance)
        if points < 0 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed all "..t[1].." account premium points.")
            db.query("UPDATE `accounts` SET `premium_points` = '0' WHERE `name`='" .. accountName .. "' LIMIT 1;")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed "..balance.." premium points to "..t[1].." account.")
            db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;") 
        end
    end
 
    return true
end
 
Last edited:
I got so:

Thank you so much for tips Limos!!!

Code:
function onSay(cid, words, param)
    local t = string.explode(param, ",")
   
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing params.")
        return true
    end 
   
    if t[2] == null then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing ammount of points.")
        return true
    end
   
    local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. t[1] .. "' LIMIT 1;")
    local points = tonumber(accountPoints:getDataInt("premium_points"))
   
    if(words == "/addpoints") then
        local balance1 = points + t[2]
        db.query("UPDATE `accounts` SET `premium_points` = " .. balance1 .. " WHERE `name`='" .. t[1] .. "' LIMIT 1;")   
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added "..t[2].." premium points to "..t[1].." account.")
    elseif (words == "/removepoints") then
        local balance2 = points - t[2]
        db.query("UPDATE `accounts` SET `premium_points` = " .. balance2 .. " WHERE `name`='" .. t[1] .. "' LIMIT 1;")   
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You remove "..t[2].." premium points to "..t[1].." account.")
    end
    return true
end
 
Last edited:
Back
Top