Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   JASS/AI scripts tutorials (http://www.wc3c.net/forumdisplay.php?f=650)
-   -   Multiboard per player tutorial (http://www.wc3c.net/showthread.php?t=81262)

kaldoreielf 03-13-2006 06:15 AM

Multiboard per player tutorial
 
Hello! and welcome to my Multiboard per player tutorial! now lets get started...

WHAT YOU NEED:

1. World Editor
2. Basic JASS knowledge



VARIABLES:
I have 10 players in my map, so I use 10 different multiboard variables, called Multiboard[ARRAY]. The array is the player number, for example, player one is Multiboard[1], player two is Multiboard[2] and so on.

One Integar variable called i.

Now make a GUI trigger and call it whatever you want, then go to Edit, Convert to Custom text. This will make the GUI trigger into JASS format.
Now put this text in the JASS trigger:
JASS:
Collapse JASS:
function *TRIGGERNAME* takes nothing returns nothing
    local integer i = 1
    call TriggerSleepAction( 0.00 )

    loop
        exitwhen i > 12
        set udg_Multiboard[i] = CreateMultiboardBJ( ROWS, COLUMNS, "TITLE" )
        call MultiboardDisplayBJ( false, udg_Multiboard[i] )
        set i = i + 1
    endloop

    set i = 1
    loop
        exitwhen i > 12
        if ConvertedPlayer(i) == GetLocalPlayer() then
            call MultiboardDisplayBJ( true, udg_Multiboard[i] )
        endif
        set i = i + 1
    endloop
endfunction
Now where it says *TRIGGERNAME* type in the exact name of this JASS trigger, if it isn't exact, it won't work.
To see if it works, right click the trigger and click Enable trigger, then do it again, if it works the trigger will turn back on, if not, it will show you the errors.

This will now show one single Multiboard for each player.why it works; What happens is all 12 multiboards are created on everyone's computer and they are all hidden, and then each player's board is made visible on their respective computer via GetLocalPlayer().

To Customize: If you have less than 12 players in the game, change the stars to the number of players:

JASS:
Collapse JASS:
function *TRIGGERNAME* takes nothing returns nothing
    local integer i = 1
    call TriggerSleepAction( 0.00 )

    loop
        exitwhen i > ***
        set udg_Multiboard[i] = CreateMultiboardBJ( 3, 5, "Title" )
        call MultiboardDisplayBJ( false, udg_Multiboard[i] )
        set i = i + 1
    endloop

    set i = 1
    loop
        exitwhen i > ***
        if ConvertedPlayer(i) == GetLocalPlayer() then
            call MultiboardDisplayBJ( true, udg_Multiboard[i] )
        endif
        set i = i + 1
    endloop
endfunction

Now to setup the Multiboard for your players, create a new GUI trigger.
I have made an RPG map, and I use this multiboard system to show skill levels, this is how it worked:
Trigger:
Trigger:
SetupPlayerOne
Collapse Events
Time - Elapsed game time is 0.05 seconds
Conditions
Collapse Actions
Multiboard - Set the text for Multiboard[1] item in column 1, row 1 to Cooking
Multiboard - Set the text for Multiboard[1] item in column 1, row 2 to Fishing
Multiboard - Set the text for Multiboard[1] item in column 1, row 3 to Fletching
Multiboard - Set the text for Multiboard[1] item in column 1, row 4 to Herblaw
Multiboard - Set the text for Multiboard[1] item in column 1, row 5 to Mining
Multiboard - Set the text for Multiboard[1] item in column 1, row 6 to Smithing
Multiboard - Set the width for Multiboard[1] item in column 0, row 0 to 5.50% of the total screen width
Multiboard - Set the display style for Multiboard[1] item in column 0, row 0 to Show text and Hide icons
Multiboard - Set the text for Multiboard[1] item in column 2, row 1 to (String(Cooking[1]))
Multiboard - Set the text for Multiboard[1] item in column 2, row 2 to (String(Fishing[1]))
Multiboard - Set the text for Multiboard[1] item in column 2, row 3 to (String(Fletching[1]))
Multiboard - Set the text for Multiboard[1] item in column 2, row 4 to (String(Herblaw[1]))
Multiboard - Set the text for Multiboard[1] item in column 2, row 5 to (String(Mining[1]))
Multiboard - Set the text for Multiboard[1] item in column 2, row 6 to (String(Smithing[1]))
I have setup all rows and columns now for player one, if you wish to do this for other players, repeat and change Multiboard[1] to Multiboard[PlayerNumber]
Credit to Vuen also, for helping me with the tutorial.
Have fun, and I hoped this helped you out, enjoy!

Added By BertTheJasser:
Collapse JASS:
function CreateMultiboardEx_ColumnCount takes nothing returns integer
   return 4 //How many columns the mb will have
endfunction

function CreateMultiboardEx_RowCount takes nothing returns integer
   return 4 //How many rows the mb will have
endfunction

function CreateMultiboardEx_Width takes integer row,integer column returns real
   return 0.06 //the width of a signle item
endfunction

function CreateMultiboardEx_Val takes integer row,integer column returns string
   return "" //the string shown at that position
endfunction

function CreateMultiboardEx_Icon takes integer row,integer column returns string
   return "" //the icon shown at that position
endfunction

function UpdateMultiboardEx takes multiboard mb,integer row,integer column,string val,string icon,real width returns nothing
local multiboarditem mbi=MultiboardGetItem(mb,row,column)
 call MultiboardSetItemStyle(mbi,val!="",icon!="")
 if val!="" then
     call MultiboardSetItemValue(mbi,val)
 endif
 if icon!="" then
     call MultiboardSetItemIcon(mbi,icon)
 endif
 call MultiboardSetItemWidth(mbi,width)
 call MultiboardReleaseItem(mbi)
 set mbi=null
endfunction

//use p==null if you wanna create a mb for all players
function CreateMultiboardEx takes player p returns multiboard
local multiboard mb=CreateMultiboard()
local multiboarditem mbi
local string val
local string icon
local integer column=0
local integer row=0
    if p==null then
        call MultiboardDisplay(mb,true)
    else
        call MultiboardDisplay(mb,GetLocalPlayer()==p)
    endif
    loop
        exitwhen row>CreateMultiboardEx_RowCount()
        set column=0
        loop
            exitwhen column>CreateMultiboardEx_columnCount()
            set val=CreateMultiboardEx_Val(row,column)
            set icon=CreateMultiboardEx_Icon(row,column)
            set mbi=MultiboardGetItem(mb,row,column)
            call MultiboardSetItemStyle(mbi,val!="",icon!="")
            if val!="" then
                call MultiboardSetItemValue(mbi,val)
            endif
            if icon!="" then
                call MultiboardSetItemIcon(mbi,icon)
            endif
            call MultiboardSetItemWidth(mbi,CreateMultiboardEx_Width(row,column))
            call MultiboardReleaseItem(mbi)
            set column=column+1
        endloop
        set row=row+1
    endloop
set mbi=null
set bj_lastCreatedMultiboard=mb
set mb=null
return bj_lastCreatedMultiboard
endfunction


operator 05-11-2006 07:20 PM

Nice, I have been looking for sumthing like this

Thunder_Eye 05-12-2006 04:27 PM

In the first example why are you using JASS?

kaldoreielf 05-12-2006 10:12 PM

Because this is a JASS tutorial in multiboards.

BertTheJasser 05-20-2006 10:33 AM

Update:
Collapse JASS:
function CreateMultiboardEx_ColumnCount takes nothing returns integer
   return 4 //How many columns the mb will have
endfunction

function CreateMultiboardEx_RowCount takes nothing returns integer
   return 4 //How many rows the mb will have
endfunction

function CreateMultiboardEx_Width takes integer row,integer column returns real
   return 0.06 //the width of a signle item
endfunction

function CreateMultiboardEx_Val takes integer row,integer column returns string
   return "" //the string shown at that position
endfunction

function CreateMultiboardEx_Icon takes integer row,integer column returns string
   return "" //the icon shown at that position
endfunction

function UpdateMultiboardEx takes multiboard mb,integer row,integer column,string val,string icon,real width returns nothing
local multiboarditem mbi=MultiboardGetItem(mb,row,column)
 call MultiboardSetItemStyle(mbi,val!="",icon!="")
 if val!="" then
     call MultiboardSetItemValue(mbi,val)
 endif
 if icon!="" then
     call MultiboardSetItemIcon(mbi,icon)
 endif
 call MultiboardSetItemWidth(mbi,width)
 call MultiboardReleaseItem(mbi)
 set mbi=null
endfunction

//use p==null if you wanna create a mb for all players
function CreateMultiboardEx takes player p returns multiboard
local multiboard mb=CreateMultiboard()
local multiboarditem mbi
local string val
local string icon
local integer column=0
local integer row=0
    if p==null then
        call MultiboardDisplay(mb,true)
    else
        call MultiboardDisplay(mb,GetLocalPlayer()==p)
    endif
    loop
        exitwhen row>CreateMultiboardEx_RowCount()
        set column=0
        loop
            exitwhen column>CreateMultiboardEx_columnCount()
            set val=CreateMultiboardEx_Val(row,column)
            set icon=CreateMultiboardEx_Icon(row,column)
            set mbi=MultiboardGetItem(mb,row,column)
            call MultiboardSetItemStyle(mbi,val!="",icon!="")
            if val!="" then
                call MultiboardSetItemValue(mbi,val)
            endif
            if icon!="" then
                call MultiboardSetItemIcon(mbi,icon)
            endif
            call MultiboardSetItemWidth(mbi,CreateMultiboardEx_Width(row,column))
            call MultiboardReleaseItem(mbi)
            set column=column+1
        endloop
        set row=row+1
    endloop
set mbi=null
set bj_lastCreatedMultiboard=mb
set mb=null
return bj_lastCreatedMultiboard
endfunction

Now it should work.

Kahlar 05-24-2006 01:03 AM

Nice tut.

taste 08-25-2006 07:49 AM

just wondering, does this mean that by default using the CreateMultiboardBJ function, the multiboard is only created for player1? and not the other players in a network game?

Chocobo 03-03-2007 02:33 PM

Quote:

Originally Posted by taste
just wondering, does this mean that by default using the CreateMultiboardBJ function, the multiboard is only created for player1? and not the other players in a network game?


It's using GetLocalPlayer()..

undeadorcjerk 05-05-2007 03:08 PM

I must be an idiot or something, but i would be greatful if sometold me what i was doing wrong.

Im on the first part, i copied and pasted the jass into my trigger then replaced *triggername* with the trigger's name.

When i test to see if it works, it says there is an error on line 25, it says it expects a name. thats my problem.

Thx if you help.

Mapz_Maker 07-05-2007 04:35 PM

always nice to see someone manipulate and simplify my code, lol.
I wrote the original per player multiboard tutorial (on wc3c), except it was a menu, which is better!

eliw00d 10-24-2007 01:35 AM

it doesn't work
 
nevermind.


All times are GMT. The time now is 05:48 AM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services