Baseplate Posted May 3, 2013 Posted May 3, 2013 So, I made this script and I'm not sure if it works or not as this is my first time with SQLite. addEventHandler("onResourceStart", resourceRoot, function() exports.scoreboard:addScoreboardColumn("VIP", 3) executeSQLCreateTable("VIP", "account TEXT") end ) addCommandHandler("addVIP", function(player, cmd, account) if (getElementData(player, "thePlayerStaffLevel") == 5) then local targetaccount = getAccountName(account) executeSQLInsert("VIP", targetaccount) exports.DxChat:sayServerMessage(player, "You have succefully added "..account.." as VIP", 0, 255, 0) else exports.DxChat:sayServerMessage(player, "You don't have sufficient rights", 0, 255, 0) end end ) addCommandHandler("delVIP", function(player, cmd, account) if (getElementData(player, "thePlayerStaffLevel") == 5) then local targetaccount = getAccountName(account) executeSQLDelete("VIP", targetaccount) exports.DxChat:sayServerMessage(player, "You have succefully deleted "..account.." and he is no longer a VIP", 0, 255, 0) else exports.DxChat:sayServerMessage(player, "You don't have sufficient rights", 0, 255, 0) end end ) addEventHandler("onPlayerLogin", root, function() local result = executeSQLSelect( "VIP", "account") if (type(result) == "table" and #result == 1) then local thePlayer = getAccountPlayer(result) setElementData(thePlayer, "VIP", "Yes") else setElementData(thePlayer, "VIP", "No") end end ) P.S:Before saying "why don't you test it yourself?" I don't have MTA, thanks.
Castillo Posted May 3, 2013 Posted May 3, 2013 No, that won't work, because of the following problems: 1: You are trying to get an account name from a string, not an account element. 2: Your SQL functions are all wrongly used. addEventHandler ( "onResourceStart", resourceRoot, function ( ) exports.scoreboard:addScoreboardColumn ( "VIP", 3 ) executeSQLCreateTable ( "VIP", "account TEXT" ) end ) addCommandHandler ( "addVIP", function ( player, cmd, account ) if ( getElementData ( player, "thePlayerStaffLevel" ) == 5 ) then executeSQLInsert ( "VIP", "'".. account .."'" ) exports.DxChat:sayServerMessage ( player, "You have succefully added ".. account .." as VIP", 0, 255, 0 ) else exports.DxChat:sayServerMessage ( player, "You don't have sufficient rights", 0, 255, 0 ) end end ) addCommandHandler ( "delVIP", function ( player, cmd, account ) if ( getElementData ( player, "thePlayerStaffLevel" ) == 5 ) then executeSQLDelete ( "VIP", "account = '".. account .."'" ) exports.DxChat:sayServerMessage ( player, "You have succefully deleted ".. account .." and he is no longer a VIP", 0, 255, 0 ) else exports.DxChat:sayServerMessage ( player, "You don't have sufficient rights", 0, 255, 0 ) end end ) addEventHandler ( "onPlayerLogin", root, function ( _, account ) local result = executeSQLSelect ( "VIP", "account", "account = '".. getAccountName ( account ) .."'" ) if ( type ( result ) == "table" and #result == 1 ) then setElementData ( source, "VIP", "Yes" ) else setElementData ( source, "VIP", "No" ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted May 4, 2013 Author Posted May 4, 2013 Thanks mate, it's just my first time and I just find it all clear now
Castillo Posted May 4, 2013 Posted May 4, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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