proracer Posted January 13, 2011 Share Posted January 13, 2011 Hello all! I started to script simple points and ranks system.But I don't know a function to call when example there are 10 players in server and when you die first it gives you 0 pts, if you die second example 2 pts etc... Any idea all? It's for Race DM mode. Link to comment
#Paper Posted January 13, 2011 Share Posted January 13, 2011 Hello all! I started to script simple points and ranks system.But I don't know a function to call when example there are 10 players in server and when you die first it gives you 0 pts, if you die second example 2 pts etc... Any idea all? It's for Race DM mode. function die () local getrank = exports.race:getPlayerRank(source) if ( getrank <= 3 ) then --FUNCTION FOR GIVE THE POINTS UDER 3rd RANK elseif ( getrank == 2) then --FUNCTION FOR GIVE THE POINTS IN 2nd RANK elseif ( getrank == 1 ) then --FUNCTION FOR GIVE THE POINTS UDER 1st RANK end end addEventHandler("onPlayerWasted", getRootElement(), die) i think that's must work... Link to comment
proracer Posted January 13, 2011 Author Share Posted January 13, 2011 Thanks I will try it.I thought that was only for Racing mode but now I see it isn't.Thx Link to comment
#Paper Posted January 13, 2011 Share Posted January 13, 2011 Thanks I will try it.I thought that was only for Racing mode but now I see it isn't.Thx you will do that for all modes? Link to comment
proracer Posted January 13, 2011 Author Share Posted January 13, 2011 No, I want it only for Race deathmatch / destruction derby mode. Link to comment
#Paper Posted January 13, 2011 Share Posted January 13, 2011 No, I want it only for Race deathmatch / destruction derby mode. ah ok, my code works? Link to comment
proracer Posted January 13, 2011 Author Share Posted January 13, 2011 I have 1 more question.I'm struggling to create that if server have example 1 guy (only you) you will gain no points.And if player number increases by 1 it will increate points by 0.5.Do you have any idea how? EDIT: I have idea but it would take along time and I don't know if it would work. So for example like this: if (getPlayerCount() == 1) then addPoints = tonumber(addPoints[1]["Points"]) * 0 elseif (getPlayerCount() ==2) then addPoints = tonumber(addPoints[1]["Points"]) * 0.2 elseif (getPlayerCount() ==3) then addPoints = tonumber(addPoints[1]["Points"]) * 0.4 Link to comment
#Paper Posted January 13, 2011 Share Posted January 13, 2011 I have 1 more question.I'm struggling to create that if server have example 1 guy (only you) you will gain no points.And if player number increases by 1 it will increate points by 0.5.Do you have any idea how?EDIT: I have idea but it would take along time and I don't know if it would work. So for example like this: if (getPlayerCount() == 1) then addPoints = tonumber(addPoints[1]["Points"]) * 0 elseif (getPlayerCount() ==2) then addPoints = tonumber(addPoints[1]["Points"]) * 0.2 elseif (getPlayerCount() ==3) then addPoints = tonumber(addPoints[1]["Points"]) * 0.4 You can do that: local pointstogive = getPlayerCount() * 2 addPoints = tonumber(pointstogive) Link to comment
SDK Posted January 13, 2011 Share Posted January 13, 2011 If I'd were you, I would store the amount of alive players at the map start, since players join/leave during maps. local current_players = 1 addEvent('onRaceStateChanging', true) addEvent('onRaceStateChanging', root, function(newState, oldState) if oldState == 'GridCountdown' and newState == 'Running' then current_players = # getAlivePlayers() end end) Link to comment
proracer Posted January 13, 2011 Author Share Posted January 13, 2011 Yeah but I'm trying that the code works first.But of course it doesn't.Check it out... Points system: addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement()) function dmPoints(thePlayer) local playername = getPlayerName(thePlayer) local serial = getPlayerSerial(thePlayer) local Points = executeSQLSelect (Points, "point", "accountname = '"..getAccountName(account).."'") local Rank = executeSQLSelect(Ranks, "rank", "accountname = '"..getAccountName(account).."'") local getrank = exports.race:getPlayerRank(source) local addPoints = getPlayerCount()*1.5 local addPoints2 = tonumber(addPoints) if getrank == 1 then addPoints3 = tonumber(addPoints[1]["Points"]) + 10 outputChatBox(playername.." won "..addPoints2.."Congratulations!" ,getRootElement(),255,255,0) Rank = nil setElementData(thePlayer ,"PlayerPoints", addPoints3) setElementData(thePlayer ,"data.playername",playername,true) setElementData(thePlayer ,"PlayerRanks",Ranks) executeSQLUpdate(ranks, "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate(points, "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") end end Main points system: local root = getRootElement() function resourceStart() executeSQLCreateTable(Points, "accountname TEXT, point INT") executeSQLCreateTable(Ranks, "accountname TEXT, rank INT") outputChatBox ("Points and Rank system by Pr0RaC3R has started.") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStart) function login1(prev, account, autologin) local re = executeSQLSelect(Points, "point", "accountname = '"..getAccountName(account).."'") local re2 = executeSQLSelect(Ranks, "rank", "accountname = '"..getAccountName(account).."'") if re and #re > 0 then setElementData(source, "Ranks", tonumber(re2[1] ["rank"] setElementData(source, "Points", tonumber(re3[1]["point"]) or 0) else executeSQLInsert(Ranks, "'0', '"..getAccountName(account).."'", "rank, accountname") executeSQLInsert(Points, "'0', '"..getAccountName(account).."'", "point, accountname") end end addEventHandler("onPlayerLogin", getRootElement(), login1) function onPlayerQuit() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then executeSQLUpdate(ranks, "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate(points, "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) addEventHandler("onPlayerLogout", getRootElement(), onPlayerQuit) function publicstatsinfo( stats ) local askdname = getPlayerName ( source ) local ranks = getElementData(source,"Ranks") local points = getElementData(source,"Points") local stats_int = tonumber( stats ) outputChatBox( "* ".. askdname .." Stats are:", 255, 12, 15 ) outputChatBox( "* Rank: ".. ranks .."", 255, 12, 15 ) outputChatBox( "* Total Points gained: ".. points .."", 255, 12, 15 ) end addEvent("stats", true) addEventHandler( "stats",getRootElement(),publicstatsinfo ) function checkCommand ( message, messageType ) if ( messageType == 0 ) then if ( message == "!stats" ) then setTimer( triggerEvent, 100, 1, "stats", source ) end end end addEventHandler ( "onPlayerChat", getRootElement(), checkCommand ) ------------------ Link to comment
SDK Posted January 13, 2011 Share Posted January 13, 2011 Before telling it doesn't work, at least try debugging it and/or telling us error messages: https://wiki.multitheftauto.com/wiki/Debugging Link to comment
proracer Posted January 13, 2011 Author Share Posted January 13, 2011 I don't really get that debugging.But I tried it and it looked like this. if getrank == 1 then outputDebugString("entered if") Its just the segment of the code. Other example: executeSQLUpdate(ranks, "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate(points, "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") outputDebugString("entered if") If that's it... it outputted no errors. Link to comment
proracer Posted January 14, 2011 Author Share Posted January 14, 2011 It won't even create a table.I don't know why. (btw sorry for double-post) I edited the script a little and fixed some SQL errors but still nothing. Basic SQL functions in script. function createTables() executeSQLCreateTable("Points", "accountname TEXT, point INT") executeSQLCreateTable("Ranks", "accountname TEXT, rank INT") outputChatBox ("Points and Rank system by Pr0RaC3R has started.") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) function login1(prev, account, autologin) local re = executeSQLSelect("Points", "point", "accountname = '"..getAccountName(account).."'") local re2 = executeSQLSelect("Ranks", "rank", "accountname = '"..getAccountName(account).."'") if re and #re > 0 then setElementData(source, "Ranks", tonumber(re2[1] ["rank"]) or 0) setElementData(source, "Points", tonumber(re[1]["point"]) or 0) else executeSQLInsert("Ranks", "'0', '"..getAccountName(account).."'", "rank, accountname") executeSQLInsert("Points", "'0', '"..getAccountName(account).."'", "point, accountname") end end addEventHandler("onPlayerLogin", getRootElement(), login1) function onPlayerQuit() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then executeSQLUpdate("ranks", "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate("points", "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) addEventHandler("onPlayerLogout", getRootElement(), onPlayerQuit) function publicstatsinfo( stats ) local askdname = getPlayerName ( source ) local ranks = getElementData(source,"Ranks") local points = getElementData(source,"Points") local stats_int = tonumber( stats ) outputChatBox( "* ".. askdname .." Stats are:", 255, 12, 15 ) outputChatBox( "* Rank: ".. ranks .."", 255, 12, 15 ) outputChatBox( "* Total Points gained: ".. points .."", 255, 12, 15 ) end addEvent("stats", true) addEventHandler( "stats",getRootElement(),publicstatsinfo ) function checkCommand ( message, messageType ) if ( messageType == 0 ) then if ( message == "!stats" ) then setTimer( triggerEvent, 100, 1, "stats", source ) end end end addEventHandler ( "onPlayerChat", getRootElement(), checkCommand ) ------------------ Main points system: function DestructionMoney2(thePlayer) local playername = getPlayerName(thePlayer) local serial = getPlayerSerial(thePlayer) local Points = executeSQLSelect (Points, "point", "accountname = '"..getAccountName(account).."'") local Rank = executeSQLSelect(Ranks, "rank", "accountname = '"..getAccountName(account).."'") local getrank = exports.race:getPlayerRank(source) local placement = tostring(getrank) local addPoints = getPlayerCount()*1.5 local addPoints2 = tonumber(addPoints) outputChatBox(playername.." won "..addPoints2.."Congratulations!" ,getRootElement(),255,255,0) setElementData(thePlayer ,"PlayerPoints", Points) setElementData(thePlayer ,"data.playername",playername,true) setElementData(thePlayer ,"PlayerRanks",Ranks) executeSQLUpdate(ranks, "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate(points, "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") end Link to comment
proracer Posted January 14, 2011 Author Share Posted January 14, 2011 Sorry for triple-post.I just wanted to notify if anyone can help because know it gets an error on first script @ line 38 : attempt to concatenate local 'ranks' a boolean value. Can someone help? Btw, I forgot to change type of this script to serversided lol. Link to comment
#Paper Posted January 14, 2011 Share Posted January 14, 2011 Yeah but I'm trying that the code works first.But of course it doesn't.Check it out...Points system: addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement()) function dmPoints(thePlayer) local playername = getPlayerName(thePlayer) local serial = getPlayerSerial(thePlayer) local Points = executeSQLSelect (Points, "point", "accountname = '"..getAccountName(account).."'") local Rank = executeSQLSelect(Ranks, "rank", "accountname = '"..getAccountName(account).."'") local getrank = exports.race:getPlayerRank(source) local addPoints = getPlayerCount()*1.5 local addPoints2 = tonumber(addPoints) if getrank == 1 then addPoints3 = tonumber(addPoints[1]["Points"]) + 10 outputChatBox(playername.." won "..addPoints2.."Congratulations!" ,getRootElement(),255,255,0) Rank = nil setElementData(thePlayer ,"PlayerPoints", addPoints3) setElementData(thePlayer ,"data.playername",playername,true) setElementData(thePlayer ,"PlayerRanks",Ranks) executeSQLUpdate(ranks, "rank = '"..getElementData(source,"Ranks").."'", "accountname = '"..getAccountName(acc).."'") executeSQLUpdate(points, "point = '"..getElementData(source,"Points").."'", "accountname = '"..getAccountName(acc).."'") end end I think that you must trigger the event (addEvent("onPlayerDestructionDerbyWin",true)), if you inserted that funcition, i don't saw it Link to comment
proracer Posted January 16, 2011 Author Share Posted January 16, 2011 Hello all.I have tried new code for points system.But problem is in retrieving rows from table. addEvent("onMapStarting") function recover(playerSource) if (isGuestAccount(getPlayerAccount(playerSource)) == false) then accountname = getAccountName (getPlayerAccount(playerSource)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then executeSQLDropTable("DMPoints") outputChatBox("Successfully Recovered. Please restart the resource. /restart points") end end end addCommandHandler("recover",recover) function createTables() executeSQLCreateTable("DMPoints","serial STRING,points INT") outputChatBox("Points System by -[xXx]-Pr0RaC3R version 0.1 started!", getRootElement(), 255,140,0) outputChatBox("Points database is successfully loaded.", getRootElement(), 255,140,0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) function ClientReady(g_player) local serial = getPlayerSerial(g_player) local playername = getPlayerName(g_player) CheckPlayer = executeSQLSelect ( "DMPoints", "serial", "serial = '" .. serial .. "'" ) outputChatBox("Now we have retrieved the rows from a table.") if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then executeSQLInsert ( "DMPoints", "'"..serial.."','0'" ) outputChatBox("Rows are now really inserted.") end end addEvent("onClientReady",true) addEventHandler("onClientReady",getRootElement(),ClientReady) function stats(psource,cname,tplayer) if not getPlayerFromName(tplayer) then tplayer = psource else tplayer = getPlayerFromName(tplayer) end local serial = getPlayerSerial(tplayer) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Let's retrieve rows again. \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />") outputChatBox(getPlayerName(tplayer).. "has:" ..Points[1]['points'].. "points.", getRootElement(), 255,140,0) end addCommandHandler("stats",stats) addCommandHandler("st",stats) function addPoints1(thePlayer, mapInfo, mapOptions, gameOptions) info = mapInfo.modename if mapInfo.modename == "Destruction derby" then local playername = getPlayerName(thePlayer) local serial = getPlayerSerial(thePlayer) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("*Wins: "..playername.." took 10 Points for winning the match!",getRootElement(),255,255,0) Points = tonumber(Points[1]["points"]) + 10 setElementData(thePlayer ,"points", Points) setElementData(thePlayer ,"data.playername",playername,true) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Let's update our database. \"{SMILIES_PATH}/icon_razz.gif\" alt=\"\" title=\"Razz\" />") end end function hunterPointsBonus(pickupID, pickupType, vehicleModel) if info == "Destruction derby" then if pickupType == "vehiclechange" then if vehicleModel == 425 then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Now we are retrieving the rows from database again.") Points = tonumber(Points[1]["points"]) + 5 outputChatBox("*Hunter: "..getPlayerName(source).." gets a 5 points hunter bonus!",source,25,125,225) setElementData(source ,"points", Points) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Again some updating. <33") end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterPointsBonus) function RespawnTime(mapInfo,mapOptions) mapinfo = mapInfo.modename respawntime = mapOptions.respawntime end addEventHandler("onMapStarting",getRootElement(),RespawnTime) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Points") end) addEventHandler ( "onPlayerJoin", getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") setElementData(source, "points", tonumber(Points[1]["points"])) end) addEventHandler("onMapStarting", getRootElement() , addPoints1) Error @ line 42: attempt to index global 'points' (a nil value) Link to comment
Timic Posted January 16, 2011 Share Posted January 16, 2011 Try this addEvent("onMapStarting") function recover(playerSource) if (isGuestAccount(getPlayerAccount(playerSource)) == false) then accountname = getAccountName (getPlayerAccount(playerSource)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then executeSQLDropTable("DMPoints") outputChatBox("Successfully Recovered. Please restart the resource. /restart points") end end end addCommandHandler("recover",recover) function createTables() executeSQLCreateTable("DMPoints","serial STRING,points INT") outputChatBox("Points System by -[xXx]-Pr0RaC3R version 0.1 started!", getRootElement(), 255,140,0) outputChatBox("Points database is successfully loaded.", getRootElement(), 255,140,0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) function ClientReady(g_player) local serial = getPlayerSerial(g_player) local playername = getPlayerName(g_player) CheckPlayer = executeSQLSelect ( "DMPoints", "serial", "serial = '" .. serial .. "'" ) outputChatBox("Now we have retrieved the rows from a table.") if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then executeSQLInsert ( "DMPoints", "'"..serial.."','0'" ) outputChatBox("Rows are now really inserted.") end end addEvent("onClientReady",true) addEventHandler("onClientReady",getRootElement(),ClientReady) function stats(psource,cname,tplayer) if not getPlayerFromName(tplayer) then tplayer = psource else tplayer = getPlayerFromName(tplayer) end local serial = getPlayerSerial(tplayer) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Let's retrieve rows again. <!-- s:) --><img src=\"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" /><!-- s:) -->") outputChatBox(getPlayerName(tplayer).. "has:" ..Points.. "points.", getRootElement(), 255,140,0) end addCommandHandler("stats",stats) addCommandHandler("st",stats) function addPoints1(thePlayer, mapInfo, mapOptions, gameOptions) info = mapInfo.modename if mapInfo.modename == "Destruction derby" then local playername = getPlayerName(thePlayer) local serial = getPlayerSerial(thePlayer) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("*Wins: "..playername.." took 10 Points for winning the match!",getRootElement(),255,255,0) Points = tonumber(Points[1]["points"]) + 10 setElementData(thePlayer ,"points", Points) setElementData(thePlayer ,"data.playername",playername,true) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Let's update our database. <!-- s:P --><img src=\"{SMILIES_PATH}/icon_razz.gif\" alt=\"\" title=\"Razz\" /><!-- s:P -->") end end function hunterPointsBonus(pickupID, pickupType, vehicleModel) if info == "Destruction derby" then if pickupType == "vehiclechange" then if vehicleModel == 425 then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Now we are retrieving the rows from database again.") Points = tonumber(Points[1]["points"]) + 5 outputChatBox("*Hunter: "..getPlayerName(source).." gets a 5 points hunter bonus!",source,25,125,225) setElementData(source ,"points", Points) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Again some updating. <33") end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterPointsBonus) function RespawnTime(mapInfo,mapOptions) mapinfo = mapInfo.modename respawntime = mapOptions.respawntime end addEventHandler("onMapStarting",getRootElement(),RespawnTime) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Points") end) addEventHandler ( "onPlayerJoin", getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") setElementData(source, "points", tonumber(Points[1]["points"])) end) addEventHandler("onMapStarting", getRootElement() , addPoints1) Link to comment
proracer Posted January 16, 2011 Author Share Posted January 16, 2011 I have already tried it but still return error just different.Still thanks tho. Link to comment
#Paper Posted January 17, 2011 Share Posted January 17, 2011 I have already tried it but still return error just different.Still thanks tho. see the SQL Select... Link to comment
proracer Posted January 17, 2011 Author Share Posted January 17, 2011 Yes I know there is somewhere with retrieving the row but I don't know what is it. New code same error: @line 42 addEvent("onMapStarting") function recover(playerSource) if (isGuestAccount(getPlayerAccount(playerSource)) == false) then accountname = getAccountName (getPlayerAccount(playerSource)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then executeSQLDropTable("DMPoints") outputChatBox("Successfully Recovered. Please restart the resource. /restart points") end end end addCommandHandler("recover",recover) function createTables() executeSQLCreateTable("DMPoints","serial STRING,points INT") outputChatBox("Points System by -[xXx]-Pr0RaC3R version 0.1 started!", getRootElement(), 255,140,0) outputChatBox("Points database is successfully loaded.", getRootElement(), 255,140,0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) function ClientReady(g_player) local serial = getPlayerSerial(g_player) local playername = getPlayerName(g_player) CheckPlayer = executeSQLSelect ( "DMPoints", "serial", "serial = '" .. serial .. "'" ) outputChatBox("Now we have retrieved the rows from a table.") if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then executeSQLInsert ( "DMPoints","'"..serial.."','0'" ) outputChatBox("Rows are now really inserted.") end end addEvent("onClientReady",true) addEventHandler("onClientReady",getRootElement(),ClientReady) function stats(psource,cname,tplayer) if not getPlayerFromName(tplayer) then tplayer = psource else tplayer = getPlayerFromName(tplayer) end local serial = getPlayerSerial(tplayer) local addPts2 = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Let's retrieve rows again. \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />") outputChatBox(getPlayerName(tplayer).. "has:"..addPts2[1]['points'].."points.", getRootElement(), 255,140,0) end addCommandHandler("stats",stats) addCommandHandler("st",stats) function addPoints1(mapInfo,mapOptions,gameOptions) info = mapInfo.modename if mapInfo.modename == "Destruction derby" then local players = getElementsByType("player") for k,v in ipairs(players) do local serial = getPlayerSerial(v) local addPts = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") addPts = tonumber(addPts[1]['points']) + 10 executeSQLUpdate ( "DMPoints", "points = '"..DDAttempts.."'","serial = '" .. serial .. "'") setElementData(v,"data.pts",addPts,true) end end end function hunterPointsBonus(pickupID, pickupType, vehicleModel) if info == "Destruction derby" then if pickupType == "vehiclechange" then if vehicleModel == 425 then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Now we are retrieving the rows from database again.") Points = tonumber(Points[1]["points"]) + 5 outputChatBox("*Hunter: "..getPlayerName(source).." gets a 5 points hunter bonus!",source,25,125,225) setElementData(source ,"points", Points) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Again some updating. <33") end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterPointsBonus) function RespawnTime(mapInfo,mapOptions) mapinfo = mapInfo.modename respawntime = mapOptions.respawntime end addEventHandler("onMapStarting",getRootElement(),RespawnTime) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Points") end) addEventHandler ( "onPlayerJoin", getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") setElementData(source, "points", tonumber(Points[1]["points"])) end) addEventHandler("onMapStarting", getRootElement() , addPoints1) Link to comment
#Paper Posted January 17, 2011 Share Posted January 17, 2011 Yes I know there is somewhere with retrieving the row but I don't know what is it.New code same error: @line 42 addEvent("onMapStarting") function recover(playerSource) if (isGuestAccount(getPlayerAccount(playerSource)) == false) then accountname = getAccountName (getPlayerAccount(playerSource)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then executeSQLDropTable("DMPoints") outputChatBox("Successfully Recovered. Please restart the resource. /restart points") end end end addCommandHandler("recover",recover) function createTables() executeSQLCreateTable("DMPoints","serial STRING,points INT") outputChatBox("Points System by -[xXx]-Pr0RaC3R version 0.1 started!", getRootElement(), 255,140,0) outputChatBox("Points database is successfully loaded.", getRootElement(), 255,140,0) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) function ClientReady(g_player) local serial = getPlayerSerial(g_player) local playername = getPlayerName(g_player) CheckPlayer = executeSQLSelect ( "DMPoints", "serial", "serial = '" .. serial .. "'" ) outputChatBox("Now we have retrieved the rows from a table.") if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then executeSQLInsert ( "DMPoints","'"..serial.."','0'" ) outputChatBox("Rows are now really inserted.") end end addEvent("onClientReady",true) addEventHandler("onClientReady",getRootElement(),ClientReady) function stats(psource,cname,tplayer) if not getPlayerFromName(tplayer) then tplayer = psource else tplayer = getPlayerFromName(tplayer) end local serial = getPlayerSerial(tplayer) local addPts2 = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Let's retrieve rows again. \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />") outputChatBox(getPlayerName(tplayer).. "has:"..addPts2[1]['points'].."points.", getRootElement(), 255,140,0) end addCommandHandler("stats",stats) addCommandHandler("st",stats) function addPoints1(mapInfo,mapOptions,gameOptions) info = mapInfo.modename if mapInfo.modename == "Destruction derby" then local players = getElementsByType("player") for k,v in ipairs(players) do local serial = getPlayerSerial(v) local addPts = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") addPts = tonumber(addPts[1]['points']) + 10 executeSQLUpdate ( "DMPoints", "points = '"..DDAttempts.."'","serial = '" .. serial .. "'") setElementData(v,"data.pts",addPts,true) end end end function hunterPointsBonus(pickupID, pickupType, vehicleModel) if info == "Destruction derby" then if pickupType == "vehiclechange" then if vehicleModel == 425 then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") outputChatBox("Now we are retrieving the rows from database again.") Points = tonumber(Points[1]["points"]) + 5 outputChatBox("*Hunter: "..getPlayerName(source).." gets a 5 points hunter bonus!",source,25,125,225) setElementData(source ,"points", Points) executeSQLUpdate ( "DMPoints", "points = '"..Points.."'","serial = '" .. serial .. "'") outputChatBox("Again some updating. <33") end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterPointsBonus) function RespawnTime(mapInfo,mapOptions) mapinfo = mapInfo.modename respawntime = mapOptions.respawntime end addEventHandler("onMapStarting",getRootElement(),RespawnTime) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Points") end) addEventHandler ( "onPlayerJoin", getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "DMPoints", "points","serial = '" .. serial .. "'") setElementData(source, "points", tonumber(Points[1]["points"])) end) addEventHandler("onMapStarting", getRootElement() , addPoints1) sostitute line 42: outputChatBox(getPlayerName(tplayer).. "has:"..addPts2[1]['points'].."points.") Link to comment
proracer Posted January 17, 2011 Author Share Posted January 17, 2011 No, there is still an error. Link to comment
#Paper Posted January 18, 2011 Share Posted January 18, 2011 No, there is still an error. lol idk what to do 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