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

[Request Talkaction] /addpremium"nick,days

Status
Not open for further replies.
PHP:
local idgroup = 3   --Min Group Access

function onSay(cid, words, param)
  if getPlayerGroupId(cid) < idgroup then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
  elseif param ~= "" then
    if string.find(param, ',') ~= nil then
      local sep1 = string.find(param, ',')
      local param1 = string.sub(param, 1, sep1-1)
      local param2 = string.sub(param,sep1+1,string.len(param))
      local target = getPlayerByName(param1)
      
      if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
      elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
      elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type amount of days.")
      elseif isNumber(param2) == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
      elseif words == "/addpremium" then
        player = getCreatureName(target)
        days = param2
        if days ~= 0 then
        doPlayerAddPremiumDays(target, days)
        else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0")
        end
      end
 return TRUE
end

No idea if this will work :(
 
I will test

Thx for help me, after i edit ;)

#edit

Code:
Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/premi
um.lua
data/talkactions/scripts/premium.lua:29: 'end' expected (to close 'if' at line 2
) near '<eof>'

Fix this plz ;)

On use /addpremium"nick,15

i receive this msg error

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/premium.lua:onSay

data/talkactions/scripts/premium.lua:2: attempt to compare number with nil
 
Last edited:
function onSay(cid, words, param)
local idgroup = 3 --Min Group Access

if getPlayerGroupId(cid) < idgroup then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
elseif param ~= "" then
if string.find(param, ',') ~= nil then
local sep1 = string.find(param, ',')
local param1 = string.sub(param, 1, sep1-1)
local param2 = string.sub(param,sep1+1,string.len(param))
local target = getPlayerByName(param1)

if target == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
elseif param1 == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
elseif (param2 == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type amount of days.")
elseif isNumber(param2) == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
elseif words == "/addpremium" then
player = getCreatureName(target)
days = param2
if days ~= 0 then
doPlayerAddPremiumDays(target, days)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0")
end
return TRUE
end
try this
<short>
 
That one won't work either, too few ends

Code:
function onSay(cid, words, param)


local idgroup = 3 --Min Group Access

        if getPlayerGroupId(cid) < idgroup then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
        elseif param ~= "" then
            if string.find(param, ',') ~= nil then
        
        
        local sep1 = string.find(param, ',')
        local param1 = string.sub(param, 1, sep1-1)
        local param2 = string.sub(param,sep1+1,string.len(param))
        local target = getPlayerByName(param1)

    if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
    elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
    elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type amount of days.")
    elseif isNumber(param2) == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
    elseif words == "/addpremium" then
        player = getCreatureName(target)
        days = param2
        if days ~= 0 then
            doPlayerAddPremiumDays(target, days)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0")
        end
            end
        end
    end
return TRUE
end
Try that one.
 
PHP:
function onSay(cid, words, param)


local idgroup = 3 --Min Group Access

        if getPlayerGroupId(cid) < idgroup then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
        elseif param ~= "" then
            if string.find(param, ',') ~= nil then
        
        
        local sep1 = string.find(param, ',')
        local param1 = string.sub(param, 1, sep1-1)
        local param2 = string.sub(param,sep1+1,string.len(param))
        local target = getPlayerByName(param1)

    if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
    elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
    elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type amount of days.")
    elseif isNumber(param2) == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
    elseif words == "/addpremium" then
        player = getCreatureName(target)
        days = param2
        if days ~= 0 then
            doPlayerAddPremiumDays(target, days)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added '..days..' of premium to '..player..'.")
            doPlayerSendTextMessage(player, MESSAGE_STATUS_DEFAULT, "You have been given '..days..' of premium account.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0")
        end
            end
        end
    end
return TRUE
end

if is not working set player to target.
 
Tabbet correctly, and a text bug fixed :p
PHP:
function onSay(cid, words, param)
	local idgroup = 3 --Min Group Access
	if getPlayerGroupId(cid) < idgroup then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
	elseif param ~= "" then
		if string.find(param, ',') ~= nil then
			local sep1 = string.find(param, ',')
			local param1 = string.sub(param, 1, sep1-1)
			local param2 = string.sub(param,sep1+1,string.len(param))
			local target = getPlayerByName(param1)
			if target == FALSE then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
			elseif param1 == "" then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
			elseif (param2 == "") then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type amount of days.")
			elseif isNumber(param2) == FALSE then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
			elseif words == "/addpremium" then
				local player = getCreatureName(target)
				local days = param2
				if days ~= 0 then
					doPlayerAddPremiumDays(target, days)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." of premium to "..player..".")
					doPlayerSendTextMessage(player, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." of premium account.")
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0")
				end
			end
		end
	end
	return TRUE
end
 
PHP:
function onSay(cid, words, param)
    local idgroup = 3 --Min Group Access
    if getPlayerGroupId(cid) < idgroup then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
    elseif param ~= "" then
        if string.find(param, ',') ~= nil then
            local sep1 = string.find(param, ',')
            local param1 = string.sub(param, 1, sep1-1)
            local param2 = string.sub(param,sep1+1,string.len(param))
            local target = getPlayerByName(param1)
            if target == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online.")
            elseif param1 == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
            elseif (param2 == "") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type an amount of days.")
            elseif isNumber(param2) == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
            elseif words == "/addpremium" then
                local player = getCreatureName(target)
                local days = param2
                if days ~= 0 then
                    doPlayerAddPremiumDays(target, days)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." days of premium to "..player..".")
                    doPlayerSendTextMessage(player, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." days of premium account.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0.")
                end
            end
        end
    end
    return TRUE
end

Message fix(es).
 
Ok..
Thx Colandus and Marcinek

I will go teste

#edit

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/premium.lua:eek:nSay

luaDoPlayerSendTextMessage(). Player not found


Other problem

in use command he no dispair..

example you use !save"5

you no see the msg "!save"5" on use
 
Last edited:
It probably didnt dissapear because of error.

PHP:
function onSay(cid, words, param)
    local idgroup = 3 --Min Group Access
    if getPlayerGroupId(cid) < idgroup then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
    elseif param ~= "" then
        if string.find(param, ',') ~= nil then
            local sep1 = string.find(param, ',')
            local param1 = string.sub(param, 1, sep1-1)
            local param2 = string.sub(param,sep1+1,string.len(param))
            local target = getPlayerByName(param1)
            if target == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online.")
            elseif param1 == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
            elseif (param2 == "") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type an amount of days.")
            elseif isNumber(param2) == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
            elseif words == "/addpremium" then
                local player = getCreatureName(target)
                local days = param2
                if days ~= 0 then
                    doPlayerAddPremiumDays(target, days)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." days of premium to "..target..".")
                    doPlayerSendTextMessage(target, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." days of premium account.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0.")
                end
            end
        end
    end
    return TRUE
end

Try with this one.
 
msg error no found, but..

Code:
11:05 ADM Storm [2]: /premium"ADM Storm,10
11:06 You have added 10 days of premium to 268438868.

o_O
 
PHP:
function onSay(cid, words, param)
    local idgroup = 3 --Min Group Access
    if getPlayerGroupId(cid) < idgroup then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
    elseif param ~= "" then
        if string.find(param, ',') ~= nil then
            local sep1 = string.find(param, ',')
            local param1 = string.sub(param, 1, sep1-1)
            local param2 = string.sub(param,sep1+1,string.len(param))
            local target = getPlayerByName(param1)
            if target == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online.")
            elseif param1 == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
            elseif (param2 == "") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type an amount of days.")
            elseif isNumber(param2) == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
            elseif words == "/addpremium" then
                local player = getCreatureName(target)
                local days = param2
                if days ~= 0 then
                    doPlayerAddPremiumDays(target, days)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." days of premium to "..player..".")
                    doPlayerSendTextMessage(target, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." days of premium account.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0.")
                end
            end
        end

In talkactions.xml the words have to be "/addpremium".
 
OK. THXXXXXXXXXXXX

PHP:
function onSay(cid, words, param)
    local idgroup = 3 --Min Group Access
    if getPlayerGroupId(cid) < idgroup then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.")
    elseif param ~= "" then
        if string.find(param, ',') ~= nil then
            local sep1 = string.find(param, ',')
            local param1 = string.sub(param, 1, sep1-1)
            local param2 = string.sub(param,sep1+1,string.len(param))
            local target = getPlayerByName(param1)
            if target == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online.")
            elseif param1 == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.")
            elseif (param2 == "") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type an amount of days.")
            elseif isNumber(param2) == FALSE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.")
            elseif words == "/premium" then
                local player = getCreatureName(target)
                local days = param2
                if days ~= 0 then
                    doPlayerAddPremiumDays(target, days)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." days of premium to "..player..".")
                    doPlayerSendTextMessage(target, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." days of premium account.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0.")
                end
            end
        end
	end  
end

Code:
<talkaction words="/premium" script="premium.lua"/>

On Use

Code:
/premium"nick,days

Very Thanks Marcinek ;D
 
Last edited:
If player has been given 1 day of premium it will now say he has been giving 1 day instead of 1 days, vice versa with the gm's txt message.

Code:
function onSay(cid, words, param) 
    local idgroup = 3 --Min Group Access 
    if getPlayerGroupId(cid) < idgroup then 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You can not use this command.") 
    elseif param ~= "" then 
        if string.find(param, ',') ~= nil then 
            local sep1 = string.find(param, ',') 
            local param1 = string.sub(param, 1, sep1-1) 
            local param2 = string.sub(param,sep1+1,string.len(param)) 
            local target = getPlayerByName(param1) 
            if target == FALSE then 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online.") 
            elseif param1 == "" then 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player.") 
            elseif (param2 == "") then 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type an amount of days.") 
            elseif isNumber(param2) == FALSE then 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be a number.") 
            elseif words == "/premium" then 
                local player = getCreatureName(target) 
                local days = param2 
                if days ~= 0 or days == 1 then 
                    doPlayerAddPremiumDays(target, days) 
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." day of premium to "..player..".") 
                    doPlayerSendTextMessage(target, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." day of premium account.") 
                elseif days ~= 0 or days > 1 then 
                    doPlayerAddPremiumDays(target, days) 
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have added "..days.." days of premium to "..player..".") 
                    doPlayerSendTextMessage(target, MESSAGE_STATUS_DEFAULT, "You have been given "..days.." days of premium account.") 
                else 
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Days have to be higher than 0.") 
                   end 
               end 
           end 
       end   
   end 
end
 
Status
Not open for further replies.
Back
Top