koragg Posted July 13, 2016 Share Posted July 13, 2016 Hello everyone, so I downloaded this resource : https://community.multitheftauto.com/in ... s&id=12294 and wanted to edit it so that the player receives coins for doing WinStreaks as well. I did the following (in rank.lua file) and it does show client msg in chatbox and everything but it does not give any coins at all. Please, I wasted a lot of time on this, trying different things but in the end coins weren't given to me for doing a WinStreak (despite messages showing correct ammount in chat). addEvent("onPlayerRaceWinStreak") function winstreak(playerName) local playerName = getPlayerName(source) local playerNamenick = string.gsub(playerName, "#%x%x%x%x%x%x", "") local accountid = getAccountName(getPlayerAccount(source)) local players = getElementsByType("player") local serial = getPlayerSerial(source) local uyelik = getPlayerAccount(source) local statlar = executeSQLQuery("SELECT * FROM Scores WHERE AccountId = ? AND PlayerName = ?", accountid, playerName) local coins = 0 if not PlayerData[playerName] then ResetPlayerData(source) end local minPlayers = 1 or 0 if #players < minPlayers then PlayerData[playerName].Streaks = 0 return end local wins = PlayerData[playerName].Streaks or 0 wins = wins + 1 local playernames = getPlayerName(source) if wins == 2 then --kazanmasesleri("data/sounds/kidLaugh.wav") --outputChatBox(""..playerNamenick.." has done a WinStreak of "..wins.."!", getRootElement(), 0,255,255) coins = 3 exports.messages:outputGameMessage(""..playerNamenick.." earned "..coins.." KnightCoins for his WinStreak of "..wins.."", getRootElement(), 2, 255, 0, 0) local mesaj = "You earned "..coins.." KnightCoins for your WinStreak of "..wins.."!" triggerClientEvent(source ,"serverMEsajlarAl", source, mesaj) points = tonumber(statlar[1]["Points"]) cash = tonumber(statlar[1]["Cash"]) + coins toptimes = tonumber(statlar[1]["TopTimes"]) executeSQLQuery("UPDATE Scores SET Points = ?, Cash = ?, TopTimes = ? WHERE AccountId = '"..accountid.."' AND PlayerName = '"..playerName.."'", points, cash, toptimes) setElementData ( source ,"data.cash", cash, true) end PS: This is just one part of the code (only for WinStreak of 2) but others are the same so I don't think they're needed here. Also I don't know if this should be added to update in one of the other files of the resource as well. That's why I need someone with a bit more knowledge to try help me out Link to comment
koragg Posted July 14, 2016 Author Share Posted July 14, 2016 Any errors in debugscript 3? Nothing in debugscript :\ 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