Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function GetVotePoints(player) -- Returns player's vote points or 0
- local Q = WorldDBQuery("SELECT vp FROM votepoints WHERE accID = "..player:GetAccountId())
- if(Q) then
- return Q:GetColumn(0):GetULong()
- end
- return 0
- end
- local function UpdateVotePoints(player, change) -- Updates player's vote points with the change (IE -5)
- if ((change or 0) == 0) then
- return -- change was nothing, dont do anything
- end
- local accID = player:GetAccountId()
- local newvp = GetVotePoints(player) + change
- if (newvp <= 0) then
- WorldDBQuery("DELETE FROM votepoints WHERE accID = "..accID) -- Remove from DB if vp is 0
- else
- WorldDBQuery("REPLACE INTO votepoints (accID, vp) VALUES ("..accID..", "..newvp..")") -- update / create new data
- end
- end
- -- any code here that uses GetVotePoints(player) to get the vote points and/or UpdateVotePoints(player, change)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement