Some Jass problems

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Some Jass problems

Post by JJ2197 »

What I am trying to do is make it display a message when a player trains a unit, and I want it to display a differnt message for if player 1 where to build it or player 2 etc...

Heres what I've got...

globals

Code: Select all

trigger trig
Functions

Code: Select all

function utp1 takes nothing returns boolean
return ( GetOwningPlayer(GetTrainedUnit()) == Player(0) )
endfunction
function utp2 takes nothing returns boolean
return ( GetOwningPlayer(GetTrainedUnit()) == Player(1) )
endfunction
function isut takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTrainedUnit()) == 'h00A' ) ) then
return false
endif
return true
endfunction
function wptu takes nothing returns nothing
if (utp1())then
call DisplayTextToForce( GetPlayersAll(), "Player 1" )
call DisableTrigger( GetTriggeringTrigger() )
endif
if (utp2())then
call DisplayTextToForce( GetPlayersAll(), "Player 2" )
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
function hptu takes nothing returns nothing 
set trig = CreateTrigger( )
call TriggerRegisterPlayerUnitEvent(trig,GetTriggerPlayer(),EVENT_PLAYER_UNIT_TRAIN_FINISH,Condition( function isut ))
call TriggerAddAction(trig,function wptu)                                  
endfunction
Function main

Code: Select all

call hptu()
What am I doing wrong?
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
User avatar
trb92
Senior Member
Posts: 132
Joined: February 20th, 2007, 8:40 pm
Title: Random Noob
Location: Canada!!!

Re: Some Jass problems

Post by trb92 »

Code: Select all

call TriggerRegisterPlayerUnitEvent(trig,GetTriggerPlayer(),EVENT_PLAYER_UNIT_TRAIN_FINISH,Condition( function isut ))
Won't work, there isn't a triggering player at that part, you need to actually specify player(0), player (1), etc.
Easiest way is:

Code: Select all

function hptu takes nothing returns nothing
local integer i  = 0 
set trig = CreateTrigger( )
loop
exitwhen i>11
call TriggerRegisterPlayerUnitEvent(trig, Player(i),EVENT_PLAYER_UNIT_TRAIN_FINISH,Condition( function isut ))
set i = i + 1
endloop
call TriggerAddAction(trig,function wptu)                                  
endfunction
If you knew a woman who was pregnant, who had 8 kids already,
three who were deaf, two who were blind, one mentally retarded, and she had syphilis; would you recommend that she have an abortion?

Answer:
Spoiler:
If you said yes, you just killed Beethoven...
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: Some Jass problems

Post by JJ2197 »

Okay... now how would I change condition wptu?
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: Some Jass problems

Post by Xantan »

To triggering player
GhettoChild
Old Wrinkly Member
Posts: 272
Joined: January 27th, 2007, 4:46 pm
Title: OxyContin
Location: Denver, Colorado

Re: Some Jass problems

Post by GhettoChild »

That JASS is coded worse than Enron's mainframe or something lol. I'll help you improve it once I'm done playing here.
You know why the Yankees always win, Frank?
'Cause they have Mickey Mantle?
No, it's 'cause the other teams can't stop staring at those damn pinstripes.
User avatar
weirdone2
Forum Staff
Posts: 926
Joined: June 3rd, 2007, 8:03 pm

Re: Some Jass problems

Post by weirdone2 »

So let me get this you want to make a msg appear when some1 trains a unit?
HINDYhat
Senior Member
Posts: 101
Joined: June 1st, 2007, 9:05 pm

Re: Some Jass problems

Post by HINDYhat »

Code: Select all

function isut takes nothing returns boolean
    return GetUnitTypeId(GetTrainedUnit()) == 'h00A'
endfunction
function wptu takes nothing returns nothing
    local integer i=0
    loop
        exitwhen i>11
        call DisplayTextToPlayer(Player(i),0,0,"Player "+I2S(GetPlayerId(GetOwningPlayer(GetTrainedUnit()))+1))
        set i=i+1
    endloop
    call DisableTrigger( GetTriggeringTrigger() )
endfunction
function hptu takes nothing returns nothing
    local integer i=0
    set trig = CreateTrigger( )
    loop
        exitwhen i>11
        call TriggerRegisterPlayerUnitEvent(trig,Player(0),EVENT_PLAYER_UNIT_TRAIN_FINISH,Condition( function isut ))
        set i=i+1
    endloop
    call TriggerAddAction(trig,function wptu)
endfunction
That should work.

Please indent your script next time :D
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: Some Jass problems

Post by JJ2197 »

Sorry... I just hate indents >.<
they annoy me...
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
HINDYhat
Senior Member
Posts: 101
Joined: June 1st, 2007, 9:05 pm

Re: Some Jass problems

Post by HINDYhat »

Auto-indent with JassCraft.
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: Some Jass problems

Post by JJ2197 »

Anyways it looks like what you did is backwards... like you got it only set for it to look if only player 1 has done it rather anyone...

Also it didn't seem to work... I have trigger trig = null in the globals.... that's supposed to be like that right?
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate