Sendy Posted February 5, 2019 Share Posted February 5, 2019 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
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 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) 1 Link to comment
Furzy Posted February 5, 2019 Share Posted February 5, 2019 (edited) 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 February 5, 2019 by Furzy 1 Link to comment
Sendy Posted February 5, 2019 Author Share Posted February 5, 2019 (edited) 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 February 5, 2019 by Sendy 1 Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 First, I think you have missed some details on 'addCommandHandler' page. Go and read that page completely one more time. https://wiki.multitheftauto.com/wiki/AddCommandHandler In server side, there are some parameters on handler function. 1. Player who command 2.The Command 3.Arguments [ from the command ] *Your handler function does not configured correctly. 1 Link to comment
Sendy Posted February 5, 2019 Author Share Posted February 5, 2019 What i don't need addCommandHandler.. Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 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. 1 Link to comment
Sendy Posted February 5, 2019 Author Share Posted February 5, 2019 its setTimer(DeleteVIP, 60000, 0) sorry Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 Can you please tell me, what happens every 1 minute when running this DeleteVIP function ? 1 Link to comment
Sendy Posted February 5, 2019 Author Share Posted February 5, 2019 checking if vip is expired Link to comment
Z4Zy Posted February 5, 2019 Share Posted February 5, 2019 (edited) 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 February 5, 2019 by DeadthStrock 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now