WB Coding Custom button var number for multiplayer server

Users who are viewing this thread

I've spent quite a long time trying to figure out how to get this working for my multiplayer NW server. Basically, I want the var2 number for the "custom_button_instant" to determine the item the player receives when they use the button. It works perfectly in single player mode with this script :


Code:
("custom_button_instant",spr_use_time(0),"0","cannon_button_collision", [
(ti_on_scene_prop_use,
[
(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":instance_id"),
(prop_instance_get_variation_id_2, ":button_type", ":instance_id"),

(try_begin),
    (eq, ":button_type", 1),
    (agent_get_item_slot, ":item_id", ":agent_id", 4), #ek_head
    (gt,":item_id",-1), # even have a item there?
    (agent_unequip_item, ":agent_id", ":item_id", 4), #ek_head
    (agent_equip_item, ":agent_id", "itm_pirate_hat"),
(else_try),
    (eq, ":button_type", 2),
    (agent_get_item_slot, ":item_id", ":agent_id", 4), #ek_head
    (gt,":item_id",-1), # even have a item there?
    (agent_unequip_item, ":agent_id", ":item_id", 4), #ek_head
    (agent_equip_item, ":agent_id", "itm_rus_partisan_hat3"),
(try_end),
]),
]),

But it doesn't work in multiplayer. It simply does nothing in multiplayer.

This next script, on the other hand, works in multiplayer when the var2 number is set to "1", but does nothing when its set to 2

Code:
("custom_button_instant",spr_use_time(0),"0","cannon_button_collision", [
(ti_on_scene_prop_use,
[
(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":instance_id"),
(prop_instance_get_variation_id_2, ":button_type", ":instance_id"),

(try_begin),
    (eq, ":button_type", 1),
    (multiplayer_send_3_int_to_player, ":agent_id", multiplayer_event_return_agent_set_item, ":agent_id", "itm_rus_pavlovsk_ranker", 4),
(else_try),
    (eq, ":button_type", 2),
    (agent_equip_item,":agent_id","itm_spyglass"),
(else_try),
    (eq, ":button_type", 3),
    (try_for_players, ":player_no", 1),
        (player_is_active, ":player_no"),
        (multiplayer_send_3_int_to_player, ":agent_id", multiplayer_event_return_agent_set_item, ":agent_id", "itm_pirate_hat", 4),
    (try_end),
]),
]),

I'm very confused why the first one can't work in multiplayer, and ideally if someone could give me a way to make it work with the same format would be my best bet. The second script also confuses me, that it would work for "eq, button type 1" but doesnt do **** for button type 2. Any insight or help is greatly appreciated!
 
Last edited by a moderator:

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
I formated now your post, please look it up and do it similar in the future. Also use intendation, it helps you at reading the code (intendation is making four empty spaces in front of each new level. Every time a try-operation goes up, you go one level deeper, every time a try end comes, one level less). In your case you would have noticed that you forgot about a try_end at your second script for example.
 
Upvote 0

Pitch

Squire
WBNWVCM&BWF&S
First script won't work because its made purely for client.
Other players and whats most important - server, has no idea what are you trying to do. And server wouldn't allow that anyway (or at least shouldn't).

Second script works because its made correctly. It uses NW event to inform server and other players about inventory change of particular agent.
I have no idea why var2 eq 2 doesnt work. Weapons are synced out of the box. Sounds fishy to me.
Try replacing code of it - use multiplayer_event_return_agent_set_item event as well.
 
Upvote 0
Top Bottom