#Paper Posted December 5, 2010 Posted December 5, 2010 1: How i can enable colorcodes in dxDrawText? (Color Codes in NameTags) 2: What's wrong? addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() executeSQLCreateTable ( "pointsystem", "points INT, serial TEXT" ) end) addEventHandler ("onPlayerJoin",getRootElement(), function() local serial = getPlayerSerial(source) executeSQLUpdate ( "pointsystem", "serial = '"..serial.."'") end) addEventHandler ("onPlayerRaceWasted",getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local givepoints2 = tonumber(Points[1]["points"]) + 3 executeSQLUpdate ( "pointsystem", "points = '"..givepoints2.."'","serial = '" .. serial .. "'" ) outputChatBox("#ff0000You reicive 3 points!",getRootElement(),255,0,0,true) end) function checkWinAndIfWinGiveWinCash () local getrank = exports.race:getPlayerRank(source) if (getrank == 1) then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local player = allAlivePlayers[1] local playerCount = getPlayerCount() local pointsToWin = playerCount * 2 local givepoints = tonumber(Points[1]["points"]) + pointsToWin executeSQLUpdate ( "pointsystem", "points = '"..givepoints.."'","serial = '" .. serial .. "'" ) outputChatBox ("#ff0000["..getPlayerName(player).." #ff0000wins 10 points]",getRootElement(),255,0,0,true) end end addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash) addEventHandler ("onPlayerQuit",getRootElement(),checkWinAndIfWinGiveWinCash)
Aibo Posted December 5, 2010 Posted December 5, 2010 1. viewtopic.php?f=91&t=30227#p328304 2. if you post some code, at least say what problem exactly are you having with it, not just "what's wrong". addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() executeSQLCreateTable ( "pointsystem", "points INT, serial TEXT" ) end) addEventHandler ("onPlayerJoin",getRootElement(), function() local serial = getPlayerSerial(source) -- executeSQLUpdate ( "pointsystem", "serial = '"..serial.."'") -- ^^^ this query will affect ALL rows and set this serial everywhere. -- use condition string end) addEventHandler ("onPlayerRaceWasted",getRootElement(), function() local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local givepoints2 = tonumber(Points[1]["points"]) + 3 executeSQLUpdate ( "pointsystem", "points = '"..givepoints2.."'","serial = '" .. serial .. "'" ) -- ^^^ SQL update will work if player's serial already in DB -- if it's not you should use executeSQLInsert() outputChatBox("#ff0000You reicive 3 points!",getRootElement(),255,0,0,true) end) function checkWinAndIfWinGiveWinCash () local getrank = exports.race:getPlayerRank(source) if (getrank == 1) then local serial = getPlayerSerial(source) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local player = allAlivePlayers[1] -- where is allAlivePlayers defined? local playerCount = getPlayerCount() local pointsToWin = playerCount * 2 local givepoints = tonumber(Points[1]["points"]) + pointsToWin executeSQLUpdate ( "pointsystem", "points = '"..givepoints.."'","serial = '" .. serial .. "'" ) outputChatBox ("#ff0000["..getPlayerName(player).." #ff0000wins "..pointsToWin.." points]",getRootElement(),255,0,0,true) end end addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash) addEventHandler ("onPlayerQuit",getRootElement(),checkWinAndIfWinGiveWinCash) strange events you use, and i'd advise you lo load data from DB on player join and save it back on exit.
#Paper Posted December 5, 2010 Author Posted December 5, 2010 1. viewtopic.php?f=91&t=30227#p328304 don't works T_T
Aibo Posted December 5, 2010 Posted December 5, 2010 1. viewtopic.php?f=91&t=30227#p328304 don't works T_T works, i've tested, check your syntax.
#Paper Posted December 5, 2010 Author Posted December 5, 2010 works, i've tested, check your syntax. where i must insert this code here? http://pastebin.com/3Xvex6Pt
Aibo Posted December 5, 2010 Posted December 5, 2010 add the dxDrawColorText function somewhere there, and use it instead of dxDrawText. arguments are the same but i havent made text alignment support there (yet?), so "center", "bottom" wont work.
#Paper Posted December 8, 2010 Author Posted December 8, 2010 2. if you post some code, at least say what problem exactly are you having with it, not just "what's wrong".... strange events you use, and i'd advise you lo load data from DB on player join and save it back on exit. i try to fix, but the same problem; don't work! local rootElement= getRootElement() addEvent("onMapStarting") addEvent("onPlayerPickupRacePickup") addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() executeSQLCreateTable ( "pointsystem", "points INT, serial TEXT" ) end) addEventHandler ("onPlayerJoin",getRootElement(), function() local serial = getPlayerSerial(player) local gets = getElementData (player, "checkserial") if gets then outputDebugString ( getPlayerName(player).." already in DB!" ) else setElementData (player, "checkserial" ) executeSQLInsert ( "pointsystem", "serial = '"..serial.."'") end end) addEventHandler ("onPlayerWasted",getRootElement(), function() local serial = getPlayerSerial(player) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local givepoints2 = tonumber(Points) + 3 executeSQLUpdate ( "pointsystem", "points = '"..givepoints2.."'","serial = '" .. serial .. "'" ) -- ^^^ SQL update will work if player's serial already in DB -- if it's not you should use executeSQLInsert() outputChatBox("#ff0000You reicive 3 points!",getRootElement(),255,0,0,true) end) function checkWinAndIfWinGiveWinCash () local getrank = exports.race:getPlayerRank(player) if (getrank == 1) then local serial = getPlayerSerial(player) local Points = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local playerCount = getPlayerCount() local pointsToWin = playerCount * 2 local givepoints = tonumber(Points) + pointsToWin executeSQLUpdate ( "pointsystem", "points = '"..givepoints.."'","serial = '" .. serial .. "'" ) outputChatBox ("#ff0000["..getPlayerName(player).." #ff0000wins "..pointsToWin.." points]",getRootElement(),255,0,0,true) end end addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash) addEventHandler ("onPlayerQuit",getRootElement(),checkWinAndIfWinGiveWinCash) function hunterBonus(pickupID, pickupType, vehicleModel) if info == "Destruction derby" then if pickupType == "vehiclechange" then if vehicleModel == 425 then local serial = getPlayerSerial(player) local Money = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") Money = tonumber(Money) + 5 outputChatBox("*"..getPlayerName(player).." gets the hunter!",25,125,225) outputChatBox("*You reicive 5 Points!",player,25,125,225) setElementData(source ,"B Points", Money) executeSQLUpdate ( "pointsystem", "points = '"..Money.."'","serial = '" .. serial .. "'") end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterBonus) function RespawnTime(mapInfo,mapOptions) mapinfo = mapInfo.modename respawntime = mapOptions.respawntime setTime (12, 0) setWeather (0) end addEventHandler("onMapStarting",getRootElement(),RespawnTime) function checkMoney (player,cmd) local serial = getPlayerSerial(player) local Money = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") outputChatBox("You Have "..tonumber(Money).." Points!" , player,255,255,0) end --Scoreboard 'B' Column & Refreshing addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn( "Points") exports.scoreboard:removeScoreboardColumn( "checkpoint") end) addEventHandler ("onPlayerJoin",getRootElement(), function() local serial = getPlayerSerial(source) local AchB = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") setElementData(source, "Points", tonumber(AchB)) end) --- Cash !Command function PubMoney(message,messageType) if message == "!points" or message =="!Points" then local serial = getPlayerSerial(player) local Money = executeSQLSelect ( "pointsystem", "points","serial = '" .. serial .. "'") local name = getPlayerName(player) outputChatBox(name.." has $"..tonumber(Money),255,255,0,true) end end addEventHandler("onPlayerChat",getRootElement(),PubMoney) addCommandHandler( "Points", checkMoney ) addCommandHandler( "points", checkMoney ) addEventHandler("onPlayerWasted", rootElement , DestructionMoney2)
Aibo Posted December 8, 2010 Posted December 8, 2010 again, you've posted 100+ lines of code saying "don't work". what doesnt work exactly?
#Paper Posted December 8, 2010 Author Posted December 8, 2010 again, you've posted 100+ lines of code saying "don't work". what doesnt work exactly? all... i do !points and don't return the point, all functions don't works <_<
Aibo Posted December 8, 2010 Posted December 8, 2010 1. if you want to make !commands, i'd advise you to create normal command first (with addCommandHandler) and then trigger them (see viewtopic.php?f=91&t=30392#p329405) 2. player is not defined in PubMoney function, use source 3. executeSQLSelect returns a table (and it can be empty). if you want the first result, use Money[1].points, where «points» is column name from your SQL table 4. start using «/debugscript 3» it will help you greatly
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