Login

russian armor

Problems with Sync error WCP

13 Nov 2016, 20:58 PM
#1
avatar of Maiden116

Posts: 8

Hello guys, I have encounter with a problem that i can't find a way to solve it.

I have develop a kind of ability tree. I manage to create all the UI and buttons and works on single player.
But when i create a multiplayer match when i try to give the upgrade to the player, the game crash with a SYNC ERROR.

Here is how it looks the UI, the little box above the doctrine name is a button which calls the upgrade.


Here is the button code.
Code
--BUTTON
self._docButtonIcon = nil;
self._docButton = Button(nil, "ModIcons_e4872dc0e3ff4b6f8bcf957cea423757_demo");
self._docButton:setLocation(134, 125);
self._docButton:setSize(64, 64);
self._docButton:setCallback(function(tag)
self:setSelected(true);
Command_PlayerBroadcastMessage(Game_GetLocalPlayer(), Game_GetLocalPlayer(), Doctrine_CHOOSE_CALLBACK, tag)
end)
self:add(self._docButton);
--BUTTON


The button calls a Command_PlayerBroadcastMessage who sends to all the players the player who send the menssage.

The messagecallback is this
Code
function messageCallback(player, messageType, message)

if messageType == Doctrine_CHOOSE_CALLBACK then
if player == LocalPlayer then
local doc = BP_GetUpgradeBlueprint(message);
Player_CompleteUpgrade(LocalPlayer, doc);
Command_PlayerUpgrade( LocalPlayer, doc , true, false );

doctrinePanelSelected = getSelectedDoctrine(doctrinesPanelsArray);
if doctrinePanelSelected then
local docObjetct = factions[Player_GetRaceIndex(LocalPlayer)].doctrines[doctrinePanelSelected:getIndex()];

abilityPanel:setDoctrine(docObjetct,LocalPlayer);
rootPanel:remove(doctrinePanel1);
rootPanel:remove(doctrinePanel2);
rootPanel:remove(doctrinePanel3);
toogleDoctrine = false;
end
end
end
end


But when i call the "Player_CompleteUpgrade(LocalPlayer, doc);" the game crash with a SYNC ERROR.

Anyone knows a way to do this?? or to avoid the SYNC ERROR.

Or a way to know who is clicking the button
13 Nov 2016, 22:15 PM
#2
avatar of eliw00d
Honorary Member Badge

Posts: 756 | Subs: 8

Code
if player == LocalPlayer then

That is why. You should only check if a player is the local player for UI-related functions. Just use the player you are passed in the callback.

Another way to think of it is like this: everything except the UI is synchronized in multiplayer. So, anything that affects ONLY the local player will not be synchronized and cause sync errors to happen.

Also, cool to see someone using my API. Hopefully it has been useful. :)
14 Nov 2016, 01:44 AM
#3
avatar of Maiden116

Posts: 8

Yes , it has been really usefull , i think i'll implement the new version on the second version of ability tree.

I'll try to figure out how to do the upgrades without that comparison.
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

563 users are online: 563 guests
1 post in the last 24h
28 posts in the last week
143 posts in the last month
Registered members: 45162
Welcome our newest member, SilasHollingswor
Most online: 2043 users on 29 Oct 2023, 01:04 AM