Jump to content

setvip warning


Sendy

Recommended Posts

Hello, please can anyone help me with my warning? 
bad argument getAccountPlayer
i need /setvip account if account is online

function SETVIP (source, accountName)
local account1 = getAccountName(getPlayerAccount(source))
local serial = serial
local nick = nick
local time = time
local time2 = time2
local VIP = vip
	local account = getAccount(accountName)
	if getAccountPlayer(account) then
		local player = getAccountPlayer(account)
		givePlayerMoney(player, 500000)
		outputChatBox("VIP: " .. accountName .. "", player, 255, 255, 255, true)	
	end
end
addCommandHandler("setvip", SETVIP)
Link to comment

Try this out :

function SETVIP (source, command, accountName)
  local account1 = getAccountName(getPlayerAccount(source))
  local serial = serial
  local nick = nick
  local time = time
  local time2 = time2
  local VIP = vip
	local account = getAccount(accountName)
	if getAccountPlayer(account) then
	  local player = getAccountPlayer(account)
		givePlayerMoney(player, 500000)
		outputChatBox("VIP: " .. accountName, player, 255, 255, 255, true)	
	end
end
addCommandHandler("setvip", SETVIP)

 

  • Thanks 1
Link to comment
Quote

function SETVIP (source, accountName)
local account1 = getAccountName(getPlayerAccount(source))
local serial = serial
local nick = nick
local time = time
local time2 = time2
local VIP = vip
local player = getAccountPlayer(account1)
givePlayerMoney(player, 500000)
outputChatBox("VIP: "..account1, player, 255, 255, 255, true)	
end
addCommandHandler("setvip", SETVIP)

 

try

Edited by Furzy
  • Thanks 1
Link to comment
7 hours ago, DeadthStrock said:

Try this out :


function SETVIP (source, command, accountName)
  local account1 = getAccountName(getPlayerAccount(source))
  local serial = serial
  local nick = nick
  local time = time
  local time2 = time2
  local VIP = vip
	local account = getAccount(accountName)
	if getAccountPlayer(account) then
	  local player = getAccountPlayer(account)
		givePlayerMoney(player, 500000)
		outputChatBox("VIP: " .. accountName, player, 255, 255, 255, true)	
	end
end
addCommandHandler("setvip", SETVIP)

 

Thanks working but i have 2x warning here can you please help? :(

WARNING: Bad argument @ 'getAccount' [Expected string at argument 1, got nil]
WARNING: Bad argument @ 'getAccountPlayer' [Expected account at argument 1, got boolean]

 

function DeleteVIP (command, accountName)
local result = dbQuery(database,"SELECT * FROM vip")
local poll = dbPoll(result, -1)
for i,v in ipairs(poll) do
local time = getRealTime()
if (tonumber(v["viptime"]) < tonumber(time.timestamp)) and (tonumber(v["viptime"]) > 0) then
dbExec(database, "DELETE FROM vip WHERE id = ?", tonumber(v["id"]))
local account = getAccount(accountName)
if getAccountPlayer(account) == tostring(v["acc"]) then
local player = getAccountPlayer(account)
outputChatBox("VIP: " .. accountName .. " ", player, 255, 255, 255, true)
		end
	end
end
dbFree(result)
end
setTimer(DeleteVIP, 6000000, 1)

 

Edited by Sendy
  • Like 1
Link to comment
6 hours ago, Sendy said:

 


function DeleteVIP (command, accountName)
local result = dbQuery(database,"SELECT * FROM vip")
local poll = dbPoll(result, -1)
for i,v in ipairs(poll) do
local time = getRealTime()
if (tonumber(v["viptime"]) < tonumber(time.timestamp)) and (tonumber(v["viptime"]) > 0) then
dbExec(database, "DELETE FROM vip WHERE id = ?", tonumber(v["id"]))
local account = getAccount(accountName)
if getAccountPlayer(account) == tostring(v["acc"]) then
local player = getAccountPlayer(account)
outputChatBox("VIP: " .. accountName .. " ", player, 255, 255, 255, true)
		end
	end
end
dbFree(result)
end
setTimer(DeleteVIP, 6000000, 1)

 

If that peace of code run according to the timer, you can't add accountName as a handler function argument of DeleteVIP. You had to discover accountName variable before started running the line 8.

  • Thanks 1
Link to comment
function DeleteVIP (command, accountName)
local result = dbQuery(database,"SELECT * FROM vip")
local poll = dbPoll(result, -1)
for i,v in ipairs(poll) do
local time = getRealTime()
if (tonumber(v["viptime"]) < tonumber(time.timestamp)) and (tonumber(v["viptime"]) > 0) then
dbExec(database, "DELETE FROM vip WHERE id = ?", tonumber(v["id"]))
local account = getAccount(accountName)
if getAccountPlayer(account) == tostring(v["acc"]) then
local player = getAccountPlayer(account)
outputChatBox("VIP: " .. accountName .. " ", player, 255, 255, 255, true)
		end
	end
end
dbFree(result)
end
setTimer(DeleteVIP, 6000000, 0)

In line 8 you had to define the 'accountName' variable. Got it ?

Edited by DeadthStrock
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...