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

Talk Action to add days of premium

bolero

MikeHere
Joined
Apr 13, 2009
Messages
1,146
Reaction score
12
Location
Venezuela
I need talk action to add days of premium account to X player

example: /addpremiumdays player,2

[2]= Days of premium to add.
 
Here is the script I made for my server:

Make a file called "giveprem.lua" in data/talkactions/scripts and put this code inside the file:
Code:
function onSay(cid,words,param)
params = string.explode(param, ",")
playerid = getCreatureByName(params[1])
	if(params[2]) then
		days = params[2]
        else
                days = 0
	end

if days > 0 then
doPlayerAddPremiumDays(playerid, days)
doPlayerPopupFYI(playerid, "You received "..days.." premium days.\nPlease, logout to take effect.")				
doPlayerPopupFYI(cid, "Player "..params[1].." received "..days.." premium days.")				
else
doPlayerPopupFYI(cid, "You didn't stablished how many days to give.")				
end

return TRUE
end

Then, in talkactions.xml add:
Code:
<talkaction words="/prem" access="4" event="script" value="giveprem.lua"/>
And replace "/prem" to whatever you want to cast the script.
Now, in order to cast this u should write this:
Code:
/prem player, days
Where "player" stands for the player name and "days" for the number of premium days u wanna give to the player.

Hope this is what u were asking for x) If not, tell me exactly what were u asking for.

PS. If the script doesn't work, tell me 'cause actually my server is under development and I haven't tested my scripts, yet.
 
Last edited:
[09/01/2010 22:18:32] Lua Script Error: [TalkAction Interface]
[09/01/2010 22:18:32] data/talkactions/scripts/premmy.lua:eek:nSay

[09/01/2010 22:18:32] data/talkactions/scripts/premmy.lua:10: attempt to compare number with string
[09/01/2010 22:18:32] stack traceback:
[09/01/2010 22:18:32] data/talkactions/scripts/premmy.lua:10: in function <data/talkactions/scripts/premmy.lua:1>
 
Uhhm... Try this one:
Code:
local days = 0

function onSay(cid,words,param)
params = string.explode(param, ",")
playerid = getCreatureByName(params[1])
	if(params[2]) then
		days = params[2]
	end

if days > 0 then
doPlayerAddPremiumDays(playerid, days)
doPlayerPopupFYI(playerid, "You received "..days.." premium days.\nPlease, logout to take effect.")				
doPlayerPopupFYI(cid, "Player "..params[1].." received "..days.." premium days.")				
else
doPlayerPopupFYI(cid, "You didn't stablished how many days to give.")				
end

return TRUE
end
 
[09/01/2010 22:49:57] Lua Script Error: [TalkAction Interface]
[09/01/2010 22:49:57] data/talkactions/scripts/premmy.lua:eek:nSay

[09/01/2010 22:49:57] data/talkactions/scripts/premmy.lua:10: attempt to compare number with string
[09/01/2010 22:49:57] stack traceback:
[09/01/2010 22:49:57] data/talkactions/scripts/premmy.lua:10: in function <data/talkactions/scripts/premmy.lua:3>
 
Code:
function onSay(cid, words, param)
	local param, playerid, days = string.explode(param, ","), getCreatureByName(params[1]), tonumber(params[2])

	if(isPlayer(playerid) == TRUE and days) then
		doPlayerAddPremiumDays(playerid, days)
		doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. params[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end

	return TRUE
end
 
Error
[10/01/2010 10:43:15] Lua Script Error: [TalkAction Interface]
[10/01/2010 10:43:15] data/talkactions/scripts/premmy.lua:eek:nSay

[10/01/2010 10:43:15] data/talkactions/scripts/premmy.lua:2: attempt to index global 'params' (a nil value)
[10/01/2010 10:43:15] stack traceback:
[10/01/2010 10:43:15] data/talkactions/scripts/premmy.lua:2: in function <data/talkactions/scripts/premmy.lua:1>
 
Lua:
function onSay(cid, words, param)
	local param, playerid, days = string.explode(param, ","), getPlayerByNameWildcard(param[1]), tonumber(params[2])

	if(isPlayer(playerid) == TRUE and days) then
		doPlayerAddPremiumDays(playerid, days)
		doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. params[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end

	return TRUE
end
 
Error.
[10/01/2010 10:52:03] Lua Script Error: [TalkAction Interface]
[10/01/2010 10:52:03] data/talkactions/scripts/premmy.lua:eek:nSay

[10/01/2010 10:52:03] data/talkactions/scripts/premmy.lua:2: attempt to index global 'params' (a nil value)
[10/01/2010 10:52:03] stack traceback:
[10/01/2010 10:52:03] data/talkactions/scripts/premmy.lua:2: in function <data/talkactions/scripts/premmy.lua:1>
 
Oh lol

This:
Lua:
  function onSay(cid, words, param)
        local param, playerid, days = string.explode(param, ","), getPlayerByNameWildcard(param[1]), tonumber(param[2])

        if(isPlayer(playerid) == TRUE and days) then
                doPlayerAddPremiumDays(playerid, days)
                doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. params[1] .." received ".. days .." premium days.")
        else
                doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
        end

        return TRUE
end

or this one should work:
Lua:
function onSay(cid, words, param)
	local param, playerid, days = string.explode(param, ","), getCreatureByName(param[1]), tonumber(param[2])

	if(isPlayer(playerid) == TRUE and days) then
		doPlayerAddPremiumDays(playerid, days)
		doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. params[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end

	return TRUE
end
 
With this script say this...

function onSay(cid, words, param)
local param, playerid, days = string.explode(param, ","), getPlayerByNameWildcard(param[1]), tonumber(param[2])

if(isPlayer(playerid) == TRUE and days) then
doPlayerAddPremiumDays(playerid, days)
doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. params[1] .." received ".. days .." premium days.")
else
doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
end

return TRUE
end

Say:
Either the first param isn't an online player or the second param isn't a number.
 
Second say this.
[10/01/2010 10:59:15] data/talkactions/scripts/premmy.lua:2: attempt to index global 'params' (a nil value)
[10/01/2010 10:59:15] stack traceback:
[10/01/2010 10:59:15] data/talkactions/scripts/premmy.lua:2: in function <data/talkactions/scripts/premmy.lua:1>
 
Lua:
function onSay(cid, words, param)
	local param, playerid, days = string.explode(param, ","), getCreatureByName(param[1]), tonumber(param[2])

	if(isPlayer(playerid) == TRUE and days) then
		doPlayerAddPremiumDays(playerid, days)
		doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. param[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end

	return TRUE
end
 
This one should do it ^^
Lua:
function onSay(cid, words, param)
local param = string.explode(param, ",")
local player = getPlayerByNameWildcard(param[1])
local days = tonumber(param[2])
	if isPlayer(player) and days then
		doPlayerAddPremiumDays(player, param[2])
		doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. param[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end
return true
end
 
Code:
function onSay(cid, words, param)
	local param = string.explode(param, ",")
	local playerid, days = getCreatureByName(param[1]), tonumber(param[2])

	if(isPlayer(playerid) == TRUE and days) then
		doPlayerAddPremiumDays(playerid, days)
		doPlayerSendTextMessage(playerid, MESSAGE_INFO_DESCR, "You have just received ".. days .." premium days. Please re-login for the premium account to take effect.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player ".. param[1] .." received ".. days .." premium days.")
	else
		doPlayerSendCancel(cid, "Either the first param isn't an online player or the second param isn't a number.")
	end

	return TRUE
end
 
Uhmm.. If any of the above worked... Try this:

Code:
local days = 5

function onSay(cid,words,param)
params = string.explode(param, ",")
playerid = getCreatureByName(params[1])
	if(params[2]) then
		days = params[2]
	end

doPlayerAddPremiumDays(playerid, days)
doPlayerPopupFYI(playerid, "You received "..days.." premium days.\nPlease, logout to take effect.")				
doPlayerPopupFYI(cid, "Player "..params[1].." received "..days.." premium days.")				

return TRUE
end

It must work x)
I corrected the part when checking if the days where more than "0". Now.. If u don't write how many premium days to add, the default would be "5". You can change it, where it says "local days = 5".
 
Back
Top