--L_ACT_CANNON.lua -- Client Side require('o_mis') -- global vars ------------------------------- function onStartup(self) -- Spawn the platform -- local mypos = self:GetPosition().pos -- RESMGR:LoadObject { -- objectTemplate = platformTemplateID, -- x = mypos.x, -- y = mypos.y, -- z = mypos.z, -- rw = 1, -- owner = self -- } -- Load client side parameters Here self:SetColor{ iLEGOColorID = 0 } self:SetVar("OverRideScore", true) self:SetVar("FoundFriendGuild", false) myTotalScore = 0 self:SetVar("mySCORE", 0) self:SetVar("Started", false) self:SetVar("Time", 1) GAMEOBJ:GetZoneControlID():NotifyClientObject{ name ="storeCannonClient" , paramObj = self} end function onScriptNetworkVarUpdate(self,msg) for index,value in pairs(msg.tableOfVars) do if index == "initialskill" then self:SetVar("CBSkill", value) end end end function addTimer(self) if self:GetVar("Started") and self:GetVar("Time") then local cTimer = self:GetVar("Time") -1 self:SetVar("Time", cTimer) UI:SendMessage("ChageUI", { {"sgTimer", tostring(cTimer) } }) GAMEOBJ:GetTimer():AddTimerWithCancel( 1 , "Count", self ) if cTimer < 0 then GAMEOBJ:GetTimer():CancelAllTimers(self) self:SetVar("Started", false) UI:SendMessage("ChageUI", { {"sgTimer", " " } }) self:SetVar("Time", GAMEOBJ:GetZoneControlID():GetVar("timelimit")) end end end function onTimerDone(self,msg) if msg.name =="Count" then addTimer(self) end end function onNotifyObject(self, msg) if msg.name == "currentScore" then self:SetVar("mySCORE", msg.param2) --print("SCOrE lll =="..tostring( msg.param2)) end end function onSendActivitySummaryLeaderboardData(self, msg) if (msg) then self:SetVar("HoldingTopScore", false) local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID()) local MaxCount = msg.leaderboardData["Result[0].RowCount"] n = 1 b = 1 q = 1 d = 1 tableValues = {} storedScore = {} finalTable = {} name_value = 0 score_value = 0 name = 0 score = 0 for i = 0, MaxCount do tableValues[(n)] = msg.leaderboardData["Result[0].Row["..i.."].name"] n = n + 1 tableValues[(n)] = msg.leaderboardData["Result[0].Row["..i.."].Score"] n = n + 1 if msg.leaderboardData["Result[0].Row["..i.."].Relationship"] then if msg.leaderboardData["Result[0].Row["..i.."].Relationship"] ~= 0 then self:SetVar("FoundFriendGuild", true ) end end end self:SetVar("LeaderTable", tableValues) wtf = implode(",",self:GetVar("LeaderTable")) self:SetVar("LeaderString", wtf) UI:SendMessage("LeaderUI", { {"sgLeaderUI", wtf} } ) for j = 1, #tableValues do if tableValues[j] == player:GetName().name then name = j score = (j + 1) if name ~= 1 then name_value = (j - 2) score_value = (j - 1) elseif name_value == 3 then name_value = 1 score_value = 2 elseif j == 1 then name_value = 1 score_value = 2 end self:SetVar("FoundPlayer", true ) break end end self:SetVar("name",name ) self:SetVar("score",score ) self:SetVar("tableValues",tableValues ) self:SetVar("name_value",name_value ) self:SetVar("score_value",score_value ) if self:GetVar("FoundPlayer") and self:GetVar("FoundFriendGuild") then UI:SendMessage("UpdateSG", { {"opponentScore", tostring(tableValues[score_value]) }, {"opponentName", tostring(tableValues[name_value]) } } ) elseif not self:GetVar("FoundFriendGuild") and self:GetVar("FoundPlayer") then UI:SendMessage("UpdateSG", { {"opponentScore", tostring(tableValues[self:GetVar("score")]) }, {"opponentName", tostring(tableValues[ self:GetVar("name")]) } } ) end GAMEOBJ:GetZoneControlID():NotifyClientZoneObject{ name= "ClientZone_SetNextBest", paramStr = tostring(tableValues[score_value]) } end end function onNotifyClientObject(self, msg) if msg.name == "count" then self:SetVar("Time", GAMEOBJ:GetZoneControlID():GetVar("timelimit")) self:SetVar("Started", true) self:SetVar("TotalTime", msg.parma1) UI:SendMessage("ChageUI", { {"sgTimer", tostring(msg.param1) } }) GAMEOBJ:GetTimer():AddTimerWithCancel( 1 , "Count", self ) end if msg.name == "Stop" then GAMEOBJ:GetTimer():CancelAllTimers( self ) self:SetVar("Started", false) UI:SendMessage("ChageUI", { {"sgTimer", " " } }) self:SetVar("Time", GAMEOBJ:GetZoneControlID():GetVar("timelimit")) end if msg.name == "cbskill" then self:SetVar("CBSkill", msg.param1) end if msg.name == "updateScore" then self:SetVar("HoldingTopScore",false) if self:GetVar("tableValues")[self:GetVar("score_value")] and not self:GetVar("HoldingTopScore") then if msg.param1 > self:GetVar("tableValues")[self:GetVar("score_value")] and not self:GetVar("HoldingTopScore") and self:GetVar("FoundFriendGuild") then for i = 1, #self:GetVar("tableValues") do if type(self:GetVar("tableValues")[i]) == "number" then if (msg.param1 > self:GetVar("tableValues")[i]) then self:SetVar("name_value" , i - 3) self:SetVar("score_value" , i - 2 ) if self:GetVar("name_value") == -1 then self:SetVar("name_value" , self:GetVar("name" )) self:SetVar("score_value" , self:GetVar("score")) self:SetVar("HoldingTopScore",true) end break end end end end top_Name = self:GetVar("tableValues")[self:GetVar("name_value")] top_Score = self:GetVar("tableValues")[self:GetVar("score_value")] if self:GetVar("tableValues")[self:GetVar("score_value")] and self:GetVar("FoundFriendGuild") then if self:GetVar("HoldingTopScore") == true then UI:SendMessage("UpdateSG", { {"opponentScore", tostring(msg.param1) }, {"opponentName", top_Name } } ) else UI:SendMessage("UpdateSG", { {"opponentScore", tostring(top_Score) }, {"opponentName", top_Name } } ) end end elseif self:GetVar("HoldingTopScore") then UI:SendMessage("UpdateSG", { {"opponentScore", tostring(msg.param1) }, {"opponentName", top_Name } } ) end if not self:GetVar("FoundFriendGuild") and self:GetVar("FoundPlayer") then local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID()) for i = 1, #self:GetVar("tableValues") do if self:GetVar("tableValues")[i] == player:GetName().name then self:SetVar("name_value" , i) self:SetVar("score_value" , i + 1 ) top_Name = self:GetVar("tableValues")[self:GetVar("name_value")] top_Score = self:GetVar("tableValues")[self:GetVar("score_value")] end end end if (top_Score) then if (msg.param1 > top_Score) and not self:GetVar("FoundFriendGuild") and self:GetVar("FoundPlayer") then UI:SendMessage("UpdateSG", { {"opponentScore", tostring(msg.param1) }, {"opponentName", top_Name } } ) self:SetVar("HoldingTopScore",true) end end end end function onShootingGalleryFire(self, msg) local CBskillID = self:GetVar("CBSkill") self:CastSkill{skillID = CBskillID, lastClickedPosit=msg.targetPos, bUsedMouse=true}--, optionalTargetID = msg.objId} self:PlayFXEffect{effectType = "onfire"} self:PlayFXEffect{effectType = "onfire2"} getActivityUser(self):PlayFXEffect{effectType = "SG-fire"} end function getActivityUser(self) local targetID = self:GetActivityUser().userID if (targetID == 0 or targetID == nil) then return nil else return targetID end end